Patchwork Fix combiner to create canonical CONST_INTs (PR rtl-optimization/53519)

login
register
mail settings
Submitter Jakub Jelinek
Date May 30, 2012, 5:24 a.m.
Message ID <20120530052444.GJ16117@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/161855/
State New
Headers show

Comments

Jakub Jelinek - May 30, 2012, 5:24 a.m.
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.


	Jakub
Richard Sandiford - May 30, 2012, 6:24 a.m.
Jakub Jelinek <jakub@redhat.com> writes:
> 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.

OK, thanks.

Richard

Patch

--- 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;
+    }
+}