Blame SOURCES/gcc48-pr82274.patch

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