Blame SOURCES/gcc48-pr82274.patch

22033d
2017-10-13  Jakub Jelinek  <jakub@redhat.com>
22033d
22033d
	PR target/82274
22033d
	* libgcc2.c (__mulvDI3): If both operands have
22033d
	the same highpart of -1 and the topmost bit of lowpart is 0,
22033d
	multiplication overflows even if both lowparts are 0.
22033d
22033d
	* gcc.dg/pr82274-1.c: New test.
22033d
22033d
--- libgcc/libgcc2.c	2017/10/13 16:50:13	253733
22033d
+++ libgcc/libgcc2.c	2017/10/13 17:19:12	253734
22033d
@@ -375,7 +375,8 @@
22033d
 		}
22033d
 	      else
22033d
 		{
22033d
-		  if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
22033d
+		  if ((uu.s.high & vv.s.high) == (Wtype) -1
22033d
+		      && (uu.s.low | vv.s.low) != 0)
22033d
 		    {
22033d
 		      DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
22033d
 				    * (UDWtype) (UWtype) vv.s.low};
22033d
--- /dev/null
22033d
+++ gcc/testsuite/gcc.dg/pr82274-1.c
22033d
@@ -0,0 +1,16 @@
22033d
+/* PR target/82274 */
22033d
+/* { dg-do run } */
22033d
+/* { dg-shouldfail "trapv" } */
22033d
+/* { dg-options "-ftrapv" } */
22033d
+
22033d
+int
22033d
+main ()
22033d
+{
22033d
+#ifdef __SIZEOF_INT128__
22033d
+  volatile __int128 m = -(((__int128) 1) << (__CHAR_BIT__ * __SIZEOF_INT128__ / 2));
22033d
+#else
22033d
+  volatile long long m = -(1LL << (__CHAR_BIT__ * __SIZEOF_LONG_LONG__ / 2));
22033d
+#endif
22033d
+  m = m * m;
22033d
+  return 0;
22033d
+}