[Bug rtl-optimization/17935] Two consecutive movzbl are generated
kazu at cs dot umass dot edu
gcc-bugzilla@gcc.gnu.org
Sun Dec 12 17:57:00 GMT 2004
------- Additional Comments From kazu at cs dot umass dot edu 2004-12-12 17:57 -------
With today's mainline, I get
bar:
movl 4(%esp), %eax
testb $1, (%eax)
jne .L2
movl 8(%esp), %eax
testb $1, (%eax)
jne .L2
movl $1, %eax
movzbl %al, %eax
ret
.p2align 2,,3
.L2:
xorl %eax, %eax
movzbl %al, %eax
ret
Still we have a similar problem. movl (or xorl) followed by movzbl is
meaningless.
It turns out that the fix for PR 14843 can fix this at tree level.
Here is the resulting assembly with my patch for PR 14843.
bar:
movl 4(%esp), %eax
testb $1, (%eax)
jne .L2
movl 8(%esp), %eax
testb $1, (%eax)
jne .L2
movl $1, %eax
ret
.p2align 2,,3
.L2:
xorl %eax, %eax
ret
The reason my patch fixes this is because it removes casts before expansion.
Without my patch:
bar (p, q)
{
int iftmp.0;
<bb 0>:
if (p->f0 != 0) goto <L3>; else goto <L0>;
<L0>:;
if (q->f0 != 0) goto <L3>; else goto <L7>;
<L7>:;
iftmp.0 = 1;
goto <bb 4> (<L8>);
<L3>:;
iftmp.0 = 0;
<L8>:;
return (int) (_Bool) iftmp.0; <-- Notice these casts
}
With my patch:
bar (p, q)
{
int D.1122;
<bb 0>:
if (p->f0 != 0) goto <L3>; else goto <L0>;
<L0>:;
if (q->f0 != 0) goto <L3>; else goto <L7>;
<L7>:;
D.1122 = 1;
goto <bb 4> (<L8>);
<L3>:;
D.1122 = 0;
<L8>:;
return D.1122; <-- Casts are gone!
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17935
More information about the Gcc-bugs
mailing list