LLVM codgen improvement, count bits intrinsics

NaN divide at by.zero
Sat Apr 27 20:25:01 UTC 2019


Where do you sugest to LLVM people that codegem could be 
improved? The bit scan forward and reverse both test for zero and 
do jumps (when you want zero defined), when they could be doing 
conditional moves because both instructions st the zero flag if 
the input is zero. Basically...

import ldc.intrinsics;
alias llvm_bsf = llvm_cttz;

void foo(int a)
{
     a = llvm_bsf(a,false);
     writeln(a);
}

compiles to this...

         test    ebx, ebx
         je      .LBB0_1
         bsf     ebx, ebx
         jmp     .LBB0_3
.LBB0_1:
         mov     ebx, 32
.LBB0_3:

where it could just be

         mov     edi,32
         bsf     ebx,ebx
         cmovz   ebx,edi




More information about the digitalmars-d-ldc mailing list