Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 04697b95363702139b5a111d371ef9c4 > files > 87

gcc-4.1.2-46.el5_4.2.src.rpm

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.dg/torture/pr37731-1.c: New.
	* gcc.dg/torture/pr37731-2.c: Likewise.

--- gcc/expmed.c	(revision 140946)
+++ gcc/expmed.c	(revision 140947)
@@ -3075,7 +3075,8 @@ expand_mult (enum machine_mode mode, rtx
 	{
 	  /* 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)))
--- gcc/testsuite/gcc.dg/torture/pr37731-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr37731-1.c	(revision 140947)
@@ -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;
+}
--- gcc/testsuite/gcc.dg/torture/pr37731-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr37731-2.c	(revision 140947)
@@ -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;
+}