Blame SOURCES/gcc48-pr82274.patch

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