summaryrefslogtreecommitdiff
path: root/gcc48-pr82274.patch
diff options
context:
space:
mode:
Diffstat (limited to 'gcc48-pr82274.patch')
-rw-r--r--gcc48-pr82274.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc48-pr82274.patch b/gcc48-pr82274.patch
new file mode 100644
index 0000000..5a330b9
--- /dev/null
+++ b/gcc48-pr82274.patch
@@ -0,0 +1,40 @@
+2017-10-13 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/82274
+ * libgcc2.c (__mulvDI3): If both operands have
+ the same highpart of -1 and the topmost bit of lowpart is 0,
+ multiplication overflows even if both lowparts are 0.
+
+ * gcc.dg/pr82274-1.c: New test.
+
+--- libgcc/libgcc2.c 2017/10/13 16:50:13 253733
++++ libgcc/libgcc2.c 2017/10/13 17:19:12 253734
+@@ -375,7 +375,8 @@
+ }
+ else
+ {
+- if (uu.s.high == (Wtype) -1 && vv.s.high == (Wtype) - 1)
++ if ((uu.s.high & vv.s.high) == (Wtype) -1
++ && (uu.s.low | vv.s.low) != 0)
+ {
+ DWunion ww = {.ll = (UDWtype) (UWtype) uu.s.low
+ * (UDWtype) (UWtype) vv.s.low};
+--- /dev/null
++++ gcc/testsuite/gcc.dg/pr82274-1.c
+@@ -0,0 +1,16 @@
++/* PR target/82274 */
++/* { dg-do run } */
++/* { dg-shouldfail "trapv" } */
++/* { dg-options "-ftrapv" } */
++
++int
++main ()
++{
++#ifdef __SIZEOF_INT128__
++ volatile __int128 m = -(((__int128) 1) << (__CHAR_BIT__ * __SIZEOF_INT128__ / 2));
++#else
++ volatile long long m = -(1LL << (__CHAR_BIT__ * __SIZEOF_LONG_LONG__ / 2));
++#endif
++ m = m * m;
++ return 0;
++}