This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
fold_const.c/tree_swap_operands_p change from Oct 11 breaks m68k
- From: Gunther Nikl <gni at gecko dot de>
- To: gcc at gcc dot gnu dot org
- Cc: Roger Sayle <roger at eyesopen dot com>
- Date: Sat, 25 Oct 2003 18:00:11 +0200
- Subject: fold_const.c/tree_swap_operands_p change from Oct 11 breaks m68k
Hello!
The following code is miscompiled under m68k after your change to
fold-const.c/tree_swap_operands_p:
void foo (unsigned long j)
{
unsigned int i;
for (i = 0; i < (j>>5); ++i)
;
}
(Similiar code is in GCC which is broken for me since your change)
Compiled with -O before your change:
foo: clr.l %d1
move.l 4(%sp),%d0
lsr.l #5,%d0
move.l %d0,%a0
cmp.l %d1,%d0 <- good
jbls .L7
.L5: addq.l #1,%d1
cmp.l %d1,%a0
jbhi .L5
.L7: rts
After your change
foo: clr.l %d1
move.l 4(%sp),%d0
lsr.l #5,%d0
move.l %d0,%a0
jbls .L7
.L5: addq.l #1,%d1
cmp.l %a0,%d1
jbcs .L5
.L7: rts
the cmp.l (compare) instruction is missing. Before your change
tree_swap_operands_p returned false and now it returns true because
of the additional tests.
Whether your code is correct or the m68k backend has a bug which is
now uncovered I don't know. I used a cross-compiler to m68k-linux for
my tests.
Gunther