This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix combiner to create canonical CONST_INTs (PR rtl-optimization/53519)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 May 2012 07:24:44 +0200
- Subject: [PATCH] Fix combiner to create canonical CONST_INTs (PR rtl-optimization/53519)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
GEN_INT (GET_MODE_MASK (mode)) isn't canonical CONST_INT for mode,
because it is zero extended rather than sign-extended for GET_MODE_BITSIZE
(mode) < HOST_BITS_PER_WIDE_INT modes.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?
2012-05-30 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/53519
* combine.c (simplify_shift_const_1) <case NOT>: Use constm1_rtx
instead of GEN_INT (GET_MODE_MASK (mode)) as second operand of XOR.
* gcc.c-torture/compile/pr53519.c: New test.
--- gcc/combine.c.jj 2012-05-12 10:21:06.000000000 +0200
+++ gcc/combine.c 2012-05-29 21:53:23.448801930 +0200
@@ -10284,8 +10284,7 @@ simplify_shift_const_1 (enum rtx_code co
break;
/* Make this fit the case below. */
- varop = gen_rtx_XOR (mode, XEXP (varop, 0),
- GEN_INT (GET_MODE_MASK (mode)));
+ varop = gen_rtx_XOR (mode, XEXP (varop, 0), constm1_rtx);
continue;
case IOR:
--- gcc/testsuite/gcc.c-torture/compile/pr53519.c.jj 2012-05-29 22:02:16.593763702 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr53519.c 2012-05-29 22:01:10.000000000 +0200
@@ -0,0 +1,26 @@
+/* PR rtl-optimization/53519 */
+
+int a, b, c, d, e;
+
+short int
+foo (short int x)
+{
+ return a == 0 ? x : 0;
+}
+
+short int
+bar (int x, int y)
+{
+ return x + y;
+}
+
+void
+baz (void)
+{
+ if (!e)
+ {
+ int f = foo (65535 ^ b);
+ if (bar (!6L <= ~f, ~e) == c)
+ d = 0;
+ }
+}
Jakub