]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/60930 (Wrong folding of - ((unsigned long long) a * (unsigned...
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 2 May 2014 21:51:09 +0000 (21:51 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Fri, 2 May 2014 21:51:09 +0000 (21:51 +0000)
[gcc]

2014-05-02  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/60930
* gimple-ssa-strength-reduction.c (create_mul_imm_cand):  Reject
creating a multiply candidate by folding two constant
multiplicands when the result overflows.

[gcc/testsuite]

2014-05-02  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/60930
* gcc.dg/torture/pr60930.c:  New test.

From-SVN: r210021

gcc/ChangeLog
gcc/gimple-ssa-strength-reduction.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr60930.c [new file with mode: 0644]

index fe509cb4e0267cb1aa04a376f85990ab23780a2e..0eeafbfca2432ccf30edee0f8425c8c21d7bfddb 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-02  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/60930
+       * gimple-ssa-strength-reduction.c (create_mul_imm_cand):  Reject
+       creating a multiply candidate by folding two constant
+       multiplicands when the result overflows.
+
 2014-05-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.h (TARGET_SIMD): Take AARCH64_ISA_SIMD
index 5cda3873eb33529f20a02d3016aa6e424ad2cd72..95fab746fe04a04234a7fd4b6dc126a3d36adf61 100644 (file)
@@ -735,15 +735,18 @@ create_mul_imm_cand (gimple gs, tree base_in, tree stride_in, bool speed)
             X = Y * c
             ============================
             X = (B + i') * (S * c)  */
-         base = base_cand->base_expr;
-         index = base_cand->index;
          temp = tree_to_double_int (base_cand->stride)
                 * tree_to_double_int (stride_in);
-         stride = double_int_to_tree (TREE_TYPE (stride_in), temp);
-         ctype = base_cand->cand_type;
-         if (has_single_use (base_in))
-           savings = (base_cand->dead_savings 
-                      + stmt_cost (base_cand->cand_stmt, speed));
+         if (double_int_fits_to_tree_p (TREE_TYPE (stride_in), temp))
+           {
+             base = base_cand->base_expr;
+             index = base_cand->index;
+             stride = double_int_to_tree (TREE_TYPE (stride_in), temp);
+             ctype = base_cand->cand_type;
+             if (has_single_use (base_in))
+               savings = (base_cand->dead_savings 
+                          + stmt_cost (base_cand->cand_stmt, speed));
+           }
        }
       else if (base_cand->kind == CAND_ADD
               && operand_equal_p (base_cand->stride, integer_one_node, 0))
index 30ab576432213765193b06710cfcaf0fabbf0822..33367de6ca376cc667dba269d6633a70caa8f1e8 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-02  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/60930
+       * gcc.dg/torture/pr60930.c:  New test.
+
 2014-04-30  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        Back port from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr60930.c b/gcc/testsuite/gcc.dg/torture/pr60930.c
new file mode 100644 (file)
index 0000000..5e35f19
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+int x = 1;
+
+__attribute__((noinline, noclone)) void
+foo (unsigned long long t)
+{
+  asm volatile ("" : : "r" (&t));
+  if (t == 1)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+#if __SIZEOF_LONG_LONG__ >= 8
+  unsigned long long t = 0xffffffffffffffffULL * (0xffffffffUL * x);
+  if (t != 0xffffffff00000001ULL)
+    foo (t);;
+#endif
+  return 0;
+}