--- Comment #3 from ubizjak at gmail dot com 2009-09-29 20:45 ---
This is not alpha specific, but generic tree issue.
The _.optimized dump:
bb 2:
if (x_2(D) == 0)
goto bb 4;
else
goto bb 3;
bb 3:
D.2022_3 = x_2(D) + -1;
D.2023_4 = D.2022_3 x_2(D);
D.2016_9 =
--- Comment #4 from ubizjak at gmail dot com 2009-09-29 20:53 ---
In fact, this implements short-cut of boolean OR. Function returns early for x
== 0 and should not execute right part of OR expression in this case. Something
like:
if (x == 0 || (x (x - 1)) == 0)
return 1;
else
--- Comment #5 from falk at debian dot org 2009-09-29 21:02 ---
Of course the optimization would be wrong if the second clause had side
effects, but it doesn't and this will frequently be the case. So this is
definitely a valid and in my opinion worthwhile optimization.
--
--- Additional Comments From falk at debian dot org 2005-05-20 07:43
---
It's slightly improved now on mainline, but still an unneccesary branch:
le1_bit: lda v0,1
lda t0,-1(a0)
beq a0,L1
and a0,t0,t0
cmpeq t0,0,v0
L1: ret
--
--- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-04
18:19 ---
I think this is fixed on the mainline, for x86, in 4.0.0 we get:
movl4(%esp), %edx
testl %edx, %edx
je .L2
leal-1(%edx), %eax
xorl%ecx, %ecx