]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/37731 (long long may not work correctly on 32bit host)
authorH.J. Lu <hongjiu.lu@intel.com>
Tue, 7 Oct 2008 18:50:46 +0000 (18:50 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Tue, 7 Oct 2008 18:50:46 +0000 (11:50 -0700)
gcc/

2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>

Backport from mainline:
2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/37731
* expmed.c (expand_mult): Properly check DImode constant in
CONST_DOUBLE.

gcc/testsuite/

2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>

Backport from mainline:
2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/37731
* gcc.dg/torture/pr37731-1.c: New.
* gcc.dg/torture/pr37731-2.c: Likewise.

From-SVN: r140950

gcc/ChangeLog
gcc/expmed.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr37731-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr37731-2.c [new file with mode: 0644]

index 7957e493d6263852d821f4c12878bc70ff86f535..e14d0e34ee4e78068d49c31b87e01c177d9e1955 100644 (file)
@@ -1,3 +1,12 @@
+2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline:
+       2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/37731
+       * expmed.c (expand_mult): Properly check DImode constant in
+       CONST_DOUBLE.
+
 2008-09-28  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR middle-end/36575
index d392197d8e94a5fd4f40820d9a7eab8fa69e6a4d..8de9e4d208bb7016700f219b490dd4586e7ddef5 100644 (file)
@@ -3163,7 +3163,8 @@ expand_mult (enum machine_mode mode, rtx op0, rtx op1, rtx target,
        {
          /* If we are multiplying in DImode, it may still be a win
             to try to work with shifts and adds.  */
-         if (CONST_DOUBLE_HIGH (op1) == 0)
+         if (CONST_DOUBLE_HIGH (op1) == 0
+             && CONST_DOUBLE_LOW (op1) > 0)
            coeff = CONST_DOUBLE_LOW (op1);
          else if (CONST_DOUBLE_LOW (op1) == 0
                   && EXACT_POWER_OF_2_OR_ZERO_P (CONST_DOUBLE_HIGH (op1)))
index 8f400bc47acb60b49d9acbdb3f04b16d002dea73..360c91a9aebbbbf09ea65bd99a95a2c3571beca9 100644 (file)
@@ -1,3 +1,12 @@
+2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       Backport from mainline:
+       2008-10-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/37731
+       * expmed.c (expand_mult): Properly check DImode constant in
+       CONST_DOUBLE.
+
 2008-09-28  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/conv_decimal.adb: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr37731-1.c b/gcc/testsuite/gcc.dg/torture/pr37731-1.c
new file mode 100644 (file)
index 0000000..5c156b1
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+
+extern void abort ();
+
+unsigned long long xh = 1;
+
+int
+main ()
+{
+  unsigned long long yh = 0xffffffffull;
+  unsigned long long z = xh * yh;
+
+  if (z != yh)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr37731-2.c b/gcc/testsuite/gcc.dg/torture/pr37731-2.c
new file mode 100644 (file)
index 0000000..a7f8f1e
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+
+extern void abort ();
+
+long long xh = 1;
+
+int
+main ()
+{
+  long long yh = 0xffffffffll;
+  long long z = xh * yh;
+
+  if (z != yh)
+    abort ();
+
+  return 0;
+}