[PATCH] D123453: [InstCombine] Fold mul nuw+lshr exact to a single multiplication when the latter is a factor
    chenglin.bi via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Apr  9 20:44:05 PDT 2022
    
    
  
bcl5980 added a comment.
In D123453#3441216 <https://reviews.llvm.org/D123453#3441216>, @lebedev.ri wrote:
> For example, what about this:
> ~~https://alive2.llvm.org/ce/z/aov-GB <https://alive2.llvm.org/ce/z/aov-GB>~~
> https://alive2.llvm.org/ce/z/ox4wAt (no need for `exact`, only `nuw`)
  %t0 = lshr i8 %C1, %C2
  %t1 = shl i8 %t0, %C2
  %precond = icmp eq i8 %t1, %C1
  call void @llvm.assume(i1 %precond)
This is the proof of exact. We can't remove exact check in the code. Or we need to do something like:
  if (Op0->hasOneUse()) {
    APInt NewMulC = MulC->lshr(ShAmtC);
    if (MulC->eq(NewMulC.shl(ShAmtC)))
      return BinaryOperator::CreateNUWMul(X, ConstantInt::get(Ty, NewMulC));
  }
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123453/new/
https://reviews.llvm.org/D123453
    
    
More information about the llvm-commits
mailing list