Commit 37bf20ee by Roger Sayle Committed by Roger Sayle

optabs.c (prepare_float_lib_cmp): Avoid searching for REG_RETVAL instruction by…

optabs.c (prepare_float_lib_cmp): Avoid searching for REG_RETVAL instruction by using LCT_CONST and then calling...


	* optabs.c (prepare_float_lib_cmp): Avoid searching for REG_RETVAL
	instruction by using LCT_CONST and then calling emit_libcall_block
	ourselves.

Co-Authored-By: Zack Weinberg <zack@codesourcery.com>

From-SVN: r72171
parent cd2ac05b
2003-10-06 Roger Sayle <roger@eyesopen.com>
Zack Weinberg <zack@codesourcery.com>
* optabs.c (prepare_float_lib_cmp): Avoid searching for REG_RETVAL
instruction by using LCT_CONST and then calling emit_libcall_block
ourselves.
2003-10-06 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> 2003-10-06 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
PR optimization/11974 PR optimization/11974
......
...@@ -3878,9 +3878,8 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, ...@@ -3878,9 +3878,8 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison,
rtx y = protect_from_queue (*py, 0); rtx y = protect_from_queue (*py, 0);
enum machine_mode orig_mode = GET_MODE (x); enum machine_mode orig_mode = GET_MODE (x);
enum machine_mode mode; enum machine_mode mode;
rtx before_call; rtx value, target, insns, equiv;
rtx libfunc = 0; rtx libfunc = 0;
rtx result;
for (mode = orig_mode; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode)) for (mode = orig_mode; mode != VOIDmode; mode = GET_MODE_WIDER_MODE (mode))
{ {
...@@ -3905,11 +3904,6 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, ...@@ -3905,11 +3904,6 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison,
y = convert_to_mode (mode, y, 0); y = convert_to_mode (mode, y, 0);
} }
before_call = get_last_insn ();
result = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST_MAKE_BLOCK,
word_mode, 2, x, mode, y, mode);
/* If we're optimizing attach a REG_EQUAL note describing the semantics /* If we're optimizing attach a REG_EQUAL note describing the semantics
of the libcall to the RTL. The allows the RTL optimizers to delete of the libcall to the RTL. The allows the RTL optimizers to delete
the libcall if the condition can be determined at compile-time. */ the libcall if the condition can be determined at compile-time. */
...@@ -3917,86 +3911,79 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison, ...@@ -3917,86 +3911,79 @@ prepare_float_lib_cmp (rtx *px, rtx *py, enum rtx_code *pcomparison,
&& ! side_effects_p (x) && ! side_effects_p (x)
&& ! side_effects_p (y)) && ! side_effects_p (y))
{ {
/* Search backwards through the insns emitted above looking for if (comparison == UNORDERED)
the instruction with the REG_RETVAL note. */
rtx last = get_last_insn ();
while (last != before_call)
{ {
if (find_reg_note (last, REG_RETVAL, NULL)) rtx temp = simplify_gen_relational (NE, word_mode, mode, x, x);
break; equiv = simplify_gen_relational (NE, word_mode, mode, y, y);
last = PREV_INSN (last); equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode, word_mode,
temp, const_true_rtx, equiv);
} }
else
if (last != before_call)
{ {
rtx equiv; equiv = simplify_gen_relational (comparison, word_mode, mode, x, y);
if (comparison == UNORDERED) if (! FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison))
{ {
rtx temp = simplify_gen_relational (NE, word_mode, rtx true_rtx, false_rtx;
mode, x, x);
equiv = simplify_gen_relational (NE, word_mode, switch (comparison)
mode, y, y);
equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode,
word_mode, temp,
const_true_rtx, equiv);
}
else
{
equiv = simplify_gen_relational (comparison, word_mode,
mode, x, y);
if (! FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison))
{ {
rtx true_rtx, false_rtx; case EQ:
true_rtx = const0_rtx;
false_rtx = const_true_rtx;
break;
switch (comparison) case NE:
{ true_rtx = const_true_rtx;
case EQ: false_rtx = const0_rtx;
true_rtx = const0_rtx; break;
false_rtx = const_true_rtx;
break; case GT:
true_rtx = const1_rtx;
case NE: false_rtx = const0_rtx;
true_rtx = const_true_rtx; break;
false_rtx = const0_rtx;
break; case GE:
true_rtx = const0_rtx;
case GT: false_rtx = constm1_rtx;
true_rtx = const1_rtx; break;
false_rtx = const0_rtx;
break; case LT:
true_rtx = constm1_rtx;
case GE: false_rtx = const0_rtx;
true_rtx = const0_rtx; break;
false_rtx = constm1_rtx;
break; case LE:
true_rtx = const0_rtx;
case LT: false_rtx = const1_rtx;
true_rtx = constm1_rtx; break;
false_rtx = const0_rtx;
break; default:
abort ();
case LE:
true_rtx = const0_rtx;
false_rtx = const1_rtx;
break;
default:
abort ();
}
equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode,
word_mode, equiv,
true_rtx, false_rtx);
} }
equiv = simplify_gen_ternary (IF_THEN_ELSE, word_mode,
word_mode, equiv,
true_rtx, false_rtx);
} }
set_unique_reg_note (last, REG_EQUAL, equiv);
} }
} }
else
equiv = NULL_RTX;
start_sequence ();
value = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST,
word_mode, 2, x, mode, y, mode);
insns = get_insns ();
end_sequence ();
target = gen_reg_rtx (word_mode);
emit_libcall_block (insns, target, value, equiv);
if (comparison == UNORDERED if (comparison == UNORDERED
|| FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison)) || FLOAT_LIB_COMPARE_RETURNS_BOOL (mode, comparison))
comparison = NE; comparison = NE;
*px = result; *px = target;
*py = const0_rtx; *py = const0_rtx;
*pmode = word_mode; *pmode = word_mode;
*pcomparison = comparison; *pcomparison = comparison;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment