41 lines
1.1 KiB
Diff
41 lines
1.1 KiB
Diff
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;
|
|
+}
|