+2004-03-09 Roger Sayle <roger@eyesopen.com>
+
+ * simplify-rtx.c (simplify_const_relational_operation): New function
+ renamed from simplify_relational_operation.
+ (simplify_relational_operation): Change prototype to accept an
+ additional mode argument. Call simplify_const_relational_operation.
+ (simplify_gen_relational): Update simplify_relational_operation call.
+ (simplify_ternary_operation): Update simplify_relational_operation
+ subroutine call to use simplify_const_relational_operation instead.
+
+ * rtl.h (simplify_const_relational_operation): Prototype here.
+ (simplify_relational_operation): Add addtional mode argument.
+
+ * combine.c (combine_simplify_rtx): Update calls to
+ simplify_relational_operation.
+ (simplify_set): Likewise.
+ (gen_binary): Likewise.
+ * cse.c (fold_rtx): Likewise.
+ * dojump.c (compare_from_rtx): Likewise.
+ (do_compare_rtx_and_jump): Likewise.
+ * integrate.c (subst_constants): Likewise.
+ * unroll.c (simplify_cmp_and_jump_insns): Likewise.
+
2004-03-09 Kazu Hirata <kazu@cs.umass.edu>
* config/m32r/m32r.md: Remove all define_peephole's.
if (cmp_mode == VOIDmode)
cmp_mode = op0_mode;
}
- temp = simplify_relational_operation (code, cmp_mode,
+ temp = simplify_relational_operation (code, mode, cmp_mode,
XEXP (x, 0), XEXP (x, 1));
}
-#ifdef FLOAT_STORE_FLAG_VALUE
- if (temp != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
- {
- if (temp == const0_rtx)
- temp = CONST0_RTX (mode);
- else
- temp = CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE (mode),
- mode);
- }
-#endif
break;
case RTX_COMM_ARITH:
case RTX_BIN_ARITH:
tmp_mode = GET_MODE (op1);
else
tmp_mode = compare_mode;
- tmp = simplify_relational_operation (old_code, tmp_mode, op0, op1);
+ tmp = simplify_const_relational_operation (old_code, tmp_mode,
+ op0, op1);
if (tmp != NULL_RTX)
{
rtx pat = PATTERN (other_insn);
if (op_mode == VOIDmode)
op_mode = GET_MODE (op1);
- result = simplify_relational_operation (code, op_mode, op0, op1);
+ result = simplify_relational_operation (code, mode, op_mode, op0, op1);
}
else
result = simplify_binary_operation (code, mode, op0, op1);
}
}
- new = simplify_relational_operation (code,
+ new = simplify_relational_operation (code, mode,
(mode_arg0 != VOIDmode
? mode_arg0
: (GET_MODE (const_arg0
: folded_arg1)),
const_arg0 ? const_arg0 : folded_arg0,
const_arg1 ? const_arg1 : folded_arg1);
-#ifdef FLOAT_STORE_FLAG_VALUE
- if (new != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
- {
- if (new == const0_rtx)
- new = CONST0_RTX (mode);
- else
- new = (CONST_DOUBLE_FROM_REAL_VALUE
- (FLOAT_STORE_FLAG_VALUE (mode), mode));
- }
-#endif
break;
case RTX_BIN_ARITH:
do_pending_stack_adjust ();
ucode = unsignedp ? unsigned_condition (code) : code;
- if ((tem = simplify_relational_operation (ucode, mode, op0, op1)) != 0)
+ tem = simplify_const_relational_operation (ucode, mode, op0, op1);
+ if (tem != 0)
return tem;
#if 0
do_pending_stack_adjust ();
ucode = unsignedp ? unsigned_condition (code) : code;
- if ((tem = simplify_relational_operation (ucode, mode, op0, op1)) != 0)
+ tem = simplify_const_relational_operation (ucode, mode, op0, op1);
+ if (tem != 0)
{
if (tem == const_true_rtx)
{
if (op_mode == VOIDmode)
op_mode = GET_MODE (XEXP (x, 1));
- new = simplify_relational_operation (code, op_mode,
+ new = simplify_relational_operation (code, GET_MODE (x), op_mode,
XEXP (x, 0), XEXP (x, 1));
-#ifdef FLOAT_STORE_FLAG_VALUE
- if (new != 0 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
- {
- enum machine_mode mode = GET_MODE (x);
- if (new == const0_rtx)
- new = CONST0_RTX (mode);
- else
- {
- REAL_VALUE_TYPE val;
-
- /* Avoid automatic aggregate initialization. */
- val = FLOAT_STORE_FLAG_VALUE (mode);
- new = CONST_DOUBLE_FROM_REAL_VALUE (val, mode);
- }
- }
-#endif
break;
}
/* We have compare of two VOIDmode constants for which
we recorded the comparison mode. */
rtx temp =
- simplify_relational_operation (GET_CODE (op0),
- map->compare_mode,
- XEXP (op0, 0),
- XEXP (op0, 1));
+ simplify_const_relational_operation (GET_CODE (op0),
+ map->compare_mode,
+ XEXP (op0, 0),
+ XEXP (op0, 1));
if (temp == const0_rtx)
new = XEXP (x, 2);
rtx);
extern rtx simplify_ternary_operation (enum rtx_code, enum machine_mode,
enum machine_mode, rtx, rtx, rtx);
+extern rtx simplify_const_relational_operation (enum rtx_code,
+ enum machine_mode, rtx, rtx);
extern rtx simplify_relational_operation (enum rtx_code, enum machine_mode,
- rtx, rtx);
+ enum machine_mode, rtx, rtx);
extern rtx simplify_gen_binary (enum rtx_code, enum machine_mode, rtx, rtx);
extern rtx simplify_gen_unary (enum rtx_code, enum machine_mode, rtx,
enum machine_mode);
if (cmp_mode != VOIDmode)
{
- tem = simplify_relational_operation (code, cmp_mode, op0, op1);
-
+ tem = simplify_relational_operation (code, mode, cmp_mode, op0, op1);
if (tem)
- {
-#ifdef FLOAT_STORE_FLAG_VALUE
- if (GET_MODE_CLASS (mode) == MODE_FLOAT)
- {
- REAL_VALUE_TYPE val;
- if (tem == const0_rtx)
- return CONST0_RTX (mode);
- if (tem != const_true_rtx)
- abort ();
- val = FLOAT_STORE_FLAG_VALUE (mode);
- return CONST_DOUBLE_FROM_REAL_VALUE (val, mode);
- }
-#endif
- return tem;
- }
+ return tem;
}
/* For the following tests, ensure const0_rtx is op1. */
Don't use this for relational operations such as EQ or LT.
Use simplify_relational_operation instead. */
+
rtx
simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
rtx op0, rtx op1)
is VOIDmode, both operands must also be VOIDmode and we compare the
operands in "infinite precision".
- If no simplification is possible, this function returns zero. Otherwise,
- it returns either const_true_rtx or const0_rtx. */
+ If no simplification is possible, this function returns zero.
+ Otherwise, it returns either const_true_rtx or const0_rtx. */
rtx
-simplify_relational_operation (enum rtx_code code, enum machine_mode mode,
- rtx op0, rtx op1)
+simplify_const_relational_operation (enum rtx_code code,
+ enum machine_mode mode,
+ rtx op0, rtx op1)
{
int equal, op0lt, op0ltu, op1lt, op1ltu;
rtx tem;
/* We cannot do this for == or != if tem is a nonzero address. */
&& ((code != EQ && code != NE) || ! nonzero_address_p (tem))
&& code != GTU && code != GEU && code != LTU && code != LEU)
- return simplify_relational_operation (signed_condition (code),
- mode, tem, const0_rtx);
+ return simplify_const_relational_operation (signed_condition (code),
+ mode, tem, const0_rtx);
if (flag_unsafe_math_optimizations && code == ORDERED)
return const_true_rtx;
abort ();
}
}
+
+/* Like simplify_binary_operation except used for relational operators.
+ MODE is the mode of the result, and CMP_MODE is the mode of the operands.
+ If CMP_MODE is VOIDmode, both operands must also be VOIDmode and we
+ compare the operands in "infinite precision". */
+
+rtx
+simplify_relational_operation (enum rtx_code code,
+ enum machine_mode mode ATTRIBUTE_UNUSED,
+ enum machine_mode cmp_mode, rtx op0, rtx op1)
+{
+ rtx tmp;
+
+ tmp = simplify_const_relational_operation (code, cmp_mode, op0, op1);
+ if (tmp)
+ {
+#ifdef FLOAT_STORE_FLAG_VALUE
+ if (GET_MODE_CLASS (mode) == MODE_FLOAT)
+ {
+ if (tmp == const0_rtx)
+ return CONST0_RTX (mode);
+ return CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALE (mode),
+ mode);
+ }
+#endif
+ return tmp;
+ }
+
+ return NULL_RTX;
+}
\f
/* Simplify CODE, an operation with result mode MODE and three operands,
OP0, OP1, and OP2. OP0_MODE was the mode of OP0 before it became
rtx temp;
if (cmp_mode == VOIDmode)
cmp_mode = op0_mode;
- temp = simplify_relational_operation (GET_CODE (op0), cmp_mode,
- XEXP (op0, 0), XEXP (op0, 1));
+ temp = simplify_const_relational_operation (GET_CODE (op0),
+ cmp_mode,
+ XEXP (op0, 0),
+ XEXP (op0, 1));
/* See if any simplifications were possible. */
if (temp == const0_rtx)
case RTX_COMPARE:
case RTX_COMM_COMPARE:
- temp = simplify_relational_operation (code,
+ temp = simplify_relational_operation (code, mode,
((GET_MODE (XEXP (x, 0))
!= VOIDmode)
? GET_MODE (XEXP (x, 0))
: GET_MODE (XEXP (x, 1))),
XEXP (x, 0), XEXP (x, 1));
-#ifdef FLOAT_STORE_FLAG_VALUE
- if (temp != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
- {
- if (temp == const0_rtx)
- temp = CONST0_RTX (mode);
- else
- temp = CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE (mode),
- mode);
- }
-#endif
return temp;
case RTX_EXTRA:
{
rtx t, insn;
- t = simplify_relational_operation (code, mode, op0, op1);
+ t = simplify_const_relational_operation (code, mode, op0, op1);
if (!t)
{
enum rtx_code scode = signed_condition (code);