aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/badshift.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/badshift.c')
-rw-r--r--gcc/testsuite/gcc.dg/torture/badshift.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/badshift.c b/gcc/testsuite/gcc.dg/torture/badshift.c
new file mode 100644
index 00000000000..dec71cfa2d1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/badshift.c
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/20532 */
+
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-options "-march=i386" { target { i?86-*-* && ilp32 } } } */
+
+/* We used to optimize the DImode shift-by-32 to zero because in combine
+ we turned:
+
+ (v << 31) + (v << 31)
+
+ into:
+
+ (v * (((HOST_WIDE_INT)1 << 31) + ((HOST_WIDE_INT)1 << 31)))
+
+ With a 32-bit HOST_WIDE_INT, the coefficient overflowed to zero. */
+
+unsigned long long int badshift(unsigned long long int v)
+{
+ return v << 31 << 1;
+}
+
+extern void abort ();
+
+int main() {
+ if (badshift (1) == 0)
+ abort ();
+ return 0;
+}