Blame SOURCES/gcc48-pr82274.patch

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