https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79389
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 22 Feb 2017, ubizjak at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79389 > > Uroš Bizjak <ubizjak at gmail dot com> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |jakub at gcc dot gnu.org > > --- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> --- > The testcase for missing if-conversion: > > --cut here-- > extern double Random_nextDouble (void); > > int foo (int Num_samples) > { > int count; > int under_curve = 0; > > for (count=0; count<Num_samples; count++) > { > double x= Random_nextDouble (); > double y= Random_nextDouble (); > if ( x*x + y*y <= 1.0) > under_curve ++; > } > > return under_curve; > } > --cut here-- > > gcc -O2: > > xorl %ebx, %ebx > ... > .L5: > call Random_nextDouble > movsd %xmm0, 8(%rsp) > call Random_nextDouble > movsd 8(%rsp), %xmm1 > ++> leal 1(%rbx), %eax > mulsd %xmm0, %xmm0 > mulsd %xmm1, %xmm1 > movsd .LC0(%rip), %xmm2 > addsd %xmm0, %xmm1 > ucomisd %xmm1, %xmm2 > --> cmovnb %eax, %ebx > addl $1, %ebp > cmpl %ebp, %r12d > jne .L5 > > gcc -O3 is even more "innovative": > > xorl %r12d, %r12d > ... > .L2: > call Random_nextDouble > movsd %xmm0, 8(%rsp) > call Random_nextDouble > movsd 8(%rsp), %xmm1 > mulsd %xmm0, %xmm0 > mulsd %xmm1, %xmm1 > movsd .LC0(%rip), %xmm2 > addsd %xmm0, %xmm1 > ucomisd %xmm1, %xmm2 > --> jnb .L13 > addl $1, %ebx > cmpl %ebx, %ebp > jne .L2 > > .L13: > addl $1, %ebx > ++> addl $1, %r12d > cmpl %ebp, %ebx > jne .L2 > > IF-conversion to SETcc + ZEXT + ADD would avoid cmove/jump in this short loop. > > (I'm not sure if tree or RTL ifconvert pass should catch this situation.) There is only RTL ifconvert left.