Blame SOURCES/gcc48-pr82274.patch

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