[llvm] [InstCombine] Set disjoint flag when turning Add into Or. (PR #72702)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 20 08:47:49 PST 2023
================
@@ -1571,8 +1571,11 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
// A+B --> A|B iff A and B have no bits set in common.
WithCache<const Value *> LHSCache(LHS), RHSCache(RHS);
- if (haveNoCommonBitsSet(LHSCache, RHSCache, SQ.getWithInstruction(&I)))
- return BinaryOperator::CreateOr(LHS, RHS);
+ if (haveNoCommonBitsSet(LHSCache, RHSCache, SQ.getWithInstruction(&I))) {
+ auto *Or = BinaryOperator::CreateOr(LHS, RHS);
+ Or->setIsDisjoint();
+ return Or;
+ }
----------------
goldsteinn wrote:
Think there are a few places where `xor` -> `or` where we could also add `disjoint`.
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp#L4485
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L296
https://github.com/llvm/llvm-project/pull/72702
More information about the llvm-commits
mailing list