Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Ken Raeburn
Wed, 28 Feb 1990 21:40
superfluous assignment not removed
Author: Ken Raeburn
Date: Wed, 28 Feb 1990 21:40
Date: Wed, 28 Feb 1990 21:40
43 lines
1501 bytes
1501 bytes
(This is a really minor one....)
(1.37; vax; -O -fcombine-regs -fstrength-reduce -fforce-mem)
Source file:
int foo (int ii) {
int i = ii;
if (i == 2) {
i = 2;
}
return i;
}
(Granted, the source file is silly; but I've seen similar code using
enumerated values or preprocessor macros with conceptually different
-- but numerically identical -- values.)
Assembly code:
#NO_APP
gcc_compiled.:
.text
.align 1
.globl _foo
_foo:
.word 0x0
movl 4(ap),r0
cmpl r0,$2
jneq L1
movl $2,r0 # r0 is already 2
L1:
ret
According to the texinfo file, the REG_EQUAL notes are used only for
the insns that set registers, so I'm not sure how it would be tagged,
but the known value of i should be recognized inside the `then'
branch, and the assignment suppressed.
Similar results are obtained by making the comparison "!=" (in which
case it is the comparison and references to `i' and `ii' that are
superfluous, since 2 is always returned), but I expect that is
somewhat harder to optimize.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads