Blame SOURCES/gcc48-pr82274.patch

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