re PR middle-end/90095 (wrong code with -Os -fno-tree-bit-ccp)
authorJakub Jelinek <jakub@redhat.com>
Wed, 17 Apr 2019 13:28:39 +0000 (15:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 17 Apr 2019 13:28:39 +0000 (15:28 +0200)
PR middle-end/90095
* internal-fn.c (expand_mul_overflow): Don't set SUBREG_PROMOTED_VAR_P
on lowpart SUBREGs.

* gcc.dg/pr90095-1.c: New test.
* gcc.dg/pr90095-2.c: New test.

From-SVN: r270410

gcc/ChangeLog
gcc/internal-fn.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr90095-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr90095-2.c [new file with mode: 0644]

index 3820fae8ee7523c02c39cc6dc889aff80f7048da..0e9aeb4a91eae72dd377dc9f00d50e5e7e0c5db6 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/90095
+       * internal-fn.c (expand_mul_overflow): Don't set SUBREG_PROMOTED_VAR_P
+       on lowpart SUBREGs.
+
 2019-04-17  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.c (arc_init): Format diagnostic string.
index 4f2ef45a0ff45ebbb8518e0f3e6e897b63d78001..04081f36c4d31ecfba4099e50412345c67e1f58f 100644 (file)
@@ -1753,22 +1753,9 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1,
          /* If both op0 and op1 are sign (!uns) or zero (uns) extended from
             hmode to mode, the multiplication will never overflow.  We can
             do just one hmode x hmode => mode widening multiplication.  */
-         rtx lopart0s = lopart0, lopart1s = lopart1;
-         if (GET_CODE (lopart0) == SUBREG)
-           {
-             lopart0s = shallow_copy_rtx (lopart0);
-             SUBREG_PROMOTED_VAR_P (lopart0s) = 1;
-             SUBREG_PROMOTED_SET (lopart0s, uns ? SRP_UNSIGNED : SRP_SIGNED);
-           }
-         if (GET_CODE (lopart1) == SUBREG)
-           {
-             lopart1s = shallow_copy_rtx (lopart1);
-             SUBREG_PROMOTED_VAR_P (lopart1s) = 1;
-             SUBREG_PROMOTED_SET (lopart1s, uns ? SRP_UNSIGNED : SRP_SIGNED);
-           }
          tree halfstype = build_nonstandard_integer_type (hprec, uns);
-         ops.op0 = make_tree (halfstype, lopart0s);
-         ops.op1 = make_tree (halfstype, lopart1s);
+         ops.op0 = make_tree (halfstype, lopart0);
+         ops.op1 = make_tree (halfstype, lopart1);
          ops.code = WIDEN_MULT_EXPR;
          ops.type = type;
          rtx thisres
index 937057421e4594f42a8619b07aa6090f07ed4bb5..3fb6092b3bfda79583d6298f5e46f72537fa51bb 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/90095
+       * gcc.dg/pr90095-1.c: New test.
+       * gcc.dg/pr90095-2.c: New test.
+
 2019-04-17  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR fortran/90048
diff --git a/gcc/testsuite/gcc.dg/pr90095-1.c b/gcc/testsuite/gcc.dg/pr90095-1.c
new file mode 100644 (file)
index 0000000..03968ba
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR middle-end/90095 */
+/* { dg-do run } */
+/* { dg-options "-Os -fno-tree-bit-ccp" } */
+
+unsigned long long a;
+unsigned int b;
+
+int
+main ()
+{
+  unsigned int c = 255, d = c |= b;
+  if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4 || __SIZEOF_LONG_LONG__ != 8)
+    return 0;
+  d = __builtin_mul_overflow (-(unsigned long long) d, (unsigned char) - c, &a);
+  if (d != 0)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr90095-2.c b/gcc/testsuite/gcc.dg/pr90095-2.c
new file mode 100644 (file)
index 0000000..43f67e1
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR middle-end/90095 */
+/* { dg-do run } */
+/* { dg-options "-Os -fno-tree-bit-ccp -fno-split-wide-types" } */
+
+#include "pr90095-1.c"