[testsuite] strength reduction bug

Jakub Jelinek jakub@redhat.com
Sat Aug 19 12:59:00 GMT 2000


Hi!

This test fails at least on ia32 with -O2, -O2 -fno-strength-reduce fixes it.
gcc disregards the sp -= cnt subtraction and assumes the loop is executed at
most once while it should be executed cnt + 1 times.

2000-08-19  Jakub Jelinek  <jakub@redhat.com>

	* gcc.c-torture/execute/20000819-1.c: New test.

--- gcc/testsuite/gcc.c-torture/execute/20000819-1.c.jj	Sat Aug 19 21:53:53 2000
+++ gcc/testsuite/gcc.c-torture/execute/20000819-1.c	Sat Aug 19 21:51:59 2000
@@ -0,0 +1,17 @@
+int a[2] = { 2, 0 };
+
+void foo(int *sp, int cnt)
+{
+  int *p, *top;
+
+  top = sp; sp -= cnt;
+
+  for(p = sp; p <= top; p++)
+    if (*p < 2) exit(0);
+}
+
+int main()
+{
+  foo(a + 1, 1);
+  abort();
+}

	Jakub


More information about the Gcc-patches mailing list