[llvm] [InstCombine] fold (A + B - C == B) -> (A == C). (PR #76129)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 28 23:59:56 PST 2023
================
@@ -4565,6 +4607,11 @@ Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I,
if (Instruction *NewICmp = foldICmpXNegX(I, Builder))
return NewICmp;
+ if (BO0) {
----------------
dtcxzyw wrote:
Could you please add a test that commutes the operands of icmp? I don't think the complexity-based canonicalization always places `B` in RHS.
```
define i1 @icmp_common_add_sub_commuted(i32 %a, i32 %bb, i32 %c){
%b = mul %bb, %bb ; thwart complexity-based canonicalization
%add = add i32 %a, %b
%sub = sub i32 %add, %c
%cmp = icmp eq i32 %b, %sub
ret i1 %cmp
}
```
https://github.com/llvm/llvm-project/pull/76129
More information about the llvm-commits
mailing list