[LLVMdev] InstCombine adds bit masks, confuses self, others

Rafael Espíndola rafael.espindola at gmail.com
Tue Apr 17 04:36:47 PDT 2012


> I am not sure how best to fix this. If possible, InstCombine's canonicalization shouldn't hide arithmetic progressions behind bit masks. At least, it seems these transformations should be disabled unless (X >> C).hasOneUse(). They aren't exactly optimizations.
>
> This:
>
>  %div = lshr i32 %a, 2
>  store i32 %div, i32* %p, align 4, !tbaa !0
>  %add = shl nuw nsw i32 %div, 1
>
> is better than this:
>
>  %div = lshr i32 %a, 2
>  store i32 %div, i32* %p, align 4, !tbaa !0
>  %0 = lshr i32 %a, 1
>  %add = and i32 %0, 2147483646

I think we could try your hasOneUse idea. If we are going to keep
%div, we may as well keep using it and save one instruction in the
canonical form.

> /jakob

Cheers,
Rafael




More information about the llvm-dev mailing list