diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-08 07:26:27 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-07-08 07:26:27 +0000 |
commit | e7f8b8569d7686bb8b203b0394ddd3ed8ca45c2a (patch) | |
tree | de73e8f14fd2859092455bcb84b437c9ad016747 | |
parent | 1d1ce0cfeea9e9efa9c4c23a900b2dad76dd2f04 (diff) | |
download | gcc-e7f8b8569d7686bb8b203b0394ddd3ed8ca45c2a.tar.gz |
* unroll.c (reg_dead_after_loop): Check for reg in REG_EQUAL and
REG_EQUIV notes as well.
* g++.dg/opt/strength-reduce.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@69076 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/strength-reduce.C | 51 | ||||
-rw-r--r-- | gcc/unroll.c | 6 |
4 files changed, 65 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84a6e50e080..c2621df17df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-07-08 Jakub Jelinek <jakub@redhat.com> + + * unroll.c (reg_dead_after_loop): Check for reg in REG_EQUAL and + REG_EQUIV notes as well. + 2003-07-08 Kazu Hirata <kazu@cs.umass.edu> * doc/md.texi: Fix the description of addmodecc. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5ee11fb1bab..79d98c1e9db 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-07-08 Jakub Jelinek <jakub@redhat.com> + + * g++.dg/opt/strength-reduce.C: New test. + 2003-07-07 Roger Sayle <roger@eyesopen.com> PR target/10979 diff --git a/gcc/testsuite/g++.dg/opt/strength-reduce.C b/gcc/testsuite/g++.dg/opt/strength-reduce.C new file mode 100644 index 00000000000..7c4619a36fa --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/strength-reduce.C @@ -0,0 +1,51 @@ +// This testcase was miscompiled on s390x, because strength-reduction +// did not see biv in C::foo as used after loop, but it was used +// in a REG_EQUAL note. +// { dg-do run } +// { dg-options "-O2" } + +extern "C" void abort (void); + +struct C +{ + int foo (char ch, int offset = 0x7fffffff) const; + int bar (int offset, char c) const; + char *a; +}; + +int C::bar (int offset, char c) const +{ + char ch = a[offset]; + if (ch < c) + return -1; + if (ch > c) + return 1; + return 0; +} + +int C::foo (char ch, int offset) const +{ + int len = __builtin_strlen (a); + if (len == 0) + return 0x7fffffff; + if (offset >= len) + offset = len - 1; + + while (bar (offset, ch) != 0) + { + if (offset == 0) + return 0x7fffffff; + offset--; + } + + return offset; +} + +int main (void) +{ + C c; + c.a = "/some/dir/file.ext"; + if (c.foo ('/') != 9) + abort (); + return 0; +} diff --git a/gcc/unroll.c b/gcc/unroll.c index 955136e0b03..e557cb2c1e5 100644 --- a/gcc/unroll.c +++ b/gcc/unroll.c @@ -2899,11 +2899,15 @@ reg_dead_after_loop (const struct loop *loop, rtx reg) code = GET_CODE (insn); if (GET_RTX_CLASS (code) == 'i') { - rtx set; + rtx set, note; if (reg_referenced_p (reg, PATTERN (insn))) return 0; + note = find_reg_equal_equiv_note (insn); + if (note && reg_overlap_mentioned_p (reg, XEXP (note, 0))) + return 0; + set = single_set (insn); if (set && rtx_equal_p (SET_DEST (set), reg)) break; |