re PR rtl-optimization/78378 (wrong code when combining shift + mult + zero_extend)
authorJakub Jelinek <jakub@redhat.com>
Wed, 16 Nov 2016 23:22:16 +0000 (00:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 16 Nov 2016 23:22:16 +0000 (00:22 +0100)
PR rtl-optimization/78378
* combine.c (make_extraction): Use force_to_mode for non-{REG,MEM}
inner only if pos is 0.  Fix up formatting.

* gcc.c-torture/execute/pr78378.c: New test.

From-SVN: r242526

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr78378.c [new file with mode: 0644]

index 5e5e55c96403552883f3f6ddc2842ff25fcf7625..f7121991a1bdffc400a2402429bf76a4611e955d 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/78378
+       * combine.c (make_extraction): Use force_to_mode for non-{REG,MEM}
+       inner only if pos is 0.  Fix up formatting.
+
 2016-11-17  Alan Modra  <amodra@gmail.com>
 
        PR rtl-optimization/78325
index ca5ddae9c78c22a6dfce04367015c7ebb855dfa0..5f920c4a55e9413aa5fd46a2eeb891d5bbb809ca 100644 (file)
@@ -7382,6 +7382,7 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
   if (tmode != BLKmode
       && ((pos_rtx == 0 && (pos % BITS_PER_WORD) == 0
           && !MEM_P (inner)
+          && (pos == 0 || REG_P (inner))
           && (inner_mode == tmode
               || !REG_P (inner)
               || TRULY_NOOP_TRUNCATION_MODES_P (tmode, inner_mode)
@@ -7458,10 +7459,9 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos,
        }
       else
        new_rtx = force_to_mode (inner, tmode,
-                            len >= HOST_BITS_PER_WIDE_INT
-                            ? HOST_WIDE_INT_M1U
-                            : (HOST_WIDE_INT_1U << len) - 1,
-                            0);
+                                len >= HOST_BITS_PER_WIDE_INT
+                                ? HOST_WIDE_INT_M1U
+                                : (HOST_WIDE_INT_1U << len) - 1, 0);
 
       /* If this extraction is going into the destination of a SET,
         make a STRICT_LOW_PART unless we made a MEM.  */
index 8958f86b898e556ffd1f681238a9c6cc2bc729d2..20fcf383322f5bee178e0775eeaff08722792d18 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/78378
+       * gcc.c-torture/execute/pr78378.c: New test.
+
 2016-11-16  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gcc.dg/tree-prof/section-attr-1.c: New file.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr78378.c b/gcc/testsuite/gcc.c-torture/execute/pr78378.c
new file mode 100644 (file)
index 0000000..05c1f9c
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR rtl-optimization/78378 */
+
+unsigned long long __attribute__ ((noinline, noclone))
+foo (unsigned long long x)
+{
+  x <<= 41;
+  x /= 232;
+  return 1 + (unsigned short) x;
+}
+
+int
+main ()
+{
+  unsigned long long x = foo (1);
+  if (x != 0x2c24)
+    __builtin_abort();
+  return 0;
+}