[PATCH] D46336: [InstCombine] Apply binary operator simplifications to associative/commutative cases.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 4 08:44:15 PDT 2018


spatel added a comment.

In https://reviews.llvm.org/D46336#1087038, @yamauchi wrote:

> In https://reviews.llvm.org/D46336#1085279, @spatel wrote:
>
> > I think part of this has already landed with:
> >  https://reviews.llvm.org/rL331311
>
>
> What's 'this'? I am not clear how https://reviews.llvm.org/rL331311 (partially?) helps with the bitcheck combining this patch is aiming for. Do you mean a similar approach could be taken?


I was assuming from the name of this and similar tests:
"bit-check-combine1"
that 'this' was looking for any-bit-set / any-bit-clear / all-bits-set / all-bits-clear. Maybe the patterns you're looking for don't look like what I am matching though? If I run -instcombine on the first test, it is already substantially reduced...and at that point, it just looks like a problem for -reassociation?

  define i1 @bit-check-combine1(i32 %a, i32 %b) {
  entry:
    %0 = and i32 %b, 8
    %1 = and i32 %b, 16
    %2 = and i32 %b, 32
    %3 = and i32 %a, 7   <--- we got lucky on this one and found the reduction
    %4 = or i32 %3, %0
    %5 = or i32 %4, %1    <--- reassociate the 'or' operands, so we can factor out the mask ops
    %6 = or i32 %5, %2
    %7 = icmp eq i32 %6, 0
    ret i1 %7
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D46336





More information about the llvm-commits mailing list