aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-03-23 01:53:44 +0000
committerAlan Modra <amodra@gcc.gnu.org>2002-03-23 12:23:44 +1030
commitd4c5ac1fc5857f14c10c7d4b5f7023cc666d5d64 (patch)
tree8ac22506bd9df94e134942c4c2aa113b8ddc8236 /gcc
parent84bf8c2c66eafc037581dec88287221403d12258 (diff)
downloadgcc-d4c5ac1fc5857f14c10c7d4b5f7023cc666d5d64.zip
gcc-d4c5ac1fc5857f14c10c7d4b5f7023cc666d5d64.tar.gz
gcc-d4c5ac1fc5857f14c10c7d4b5f7023cc666d5d64.tar.bz2
combine.c (simplify_comparison): When widening modes, ignore sign extension on CONST_INTs.
* combine.c (simplify_comparison): When widening modes, ignore sign extension on CONST_INTs. From-SVN: r51216
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/combine.c18
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e2a2102..b95a707 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-23 Alan Modra <amodra@bigpond.net.au>
+
+ * combine.c (simplify_comparison): When widening modes, ignore
+ sign extension on CONST_INTs.
+
2002-03-22 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/xtensa.c (print_operand): Fix incorrect mode
diff --git a/gcc/combine.c b/gcc/combine.c
index 0f17559..88495a6 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -10975,14 +10975,22 @@ simplify_comparison (code, pop0, pop1)
tmode = GET_MODE_WIDER_MODE (tmode))
if (have_insn_for (COMPARE, tmode))
{
+ int zero_extended;
+
/* If the only nonzero bits in OP0 and OP1 are those in the
narrower mode and this is an equality or unsigned comparison,
we can use the wider mode. Similarly for sign-extended
values, in which case it is true for all comparisons. */
- if (((code == EQ || code == NE
- || code == GEU || code == GTU || code == LEU || code == LTU)
- && (nonzero_bits (op0, tmode) & ~GET_MODE_MASK (mode)) == 0
- && (nonzero_bits (op1, tmode) & ~GET_MODE_MASK (mode)) == 0)
+ zero_extended = ((code == EQ || code == NE
+ || code == GEU || code == GTU
+ || code == LEU || code == LTU)
+ && (nonzero_bits (op0, tmode)
+ & ~GET_MODE_MASK (mode)) == 0
+ && ((GET_CODE (op1) == CONST_INT
+ || (nonzero_bits (op1, tmode)
+ & ~GET_MODE_MASK (mode)) == 0)));
+
+ if (zero_extended
|| ((num_sign_bit_copies (op0, tmode)
> GET_MODE_BITSIZE (tmode) - GET_MODE_BITSIZE (mode))
&& (num_sign_bit_copies (op1, tmode)
@@ -10999,6 +11007,8 @@ simplify_comparison (code, pop0, pop1)
XEXP (op0, 1)));
op0 = gen_lowpart_for_combine (tmode, op0);
+ if (zero_extended && GET_CODE (op1) == CONST_INT)
+ op1 = GEN_INT (INTVAL (op1) & GET_MODE_MASK (mode));
op1 = gen_lowpart_for_combine (tmode, op1);
break;
}