unroll.c (reg_dead_after_loop): Check for reg in REG_EQUAL and REG_EQUIV notes as well.

* 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.

From-SVN: r69076
This commit is contained in:
Jakub Jelinek 2003-07-08 09:26:27 +02:00 committed by Jakub Jelinek
parent 4b5cc2b304
commit 8df63efa77
4 changed files with 65 additions and 1 deletions

View file

@ -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.

View file

@ -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

View file

@ -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;
}

View file

@ -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;