aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2024-04-17 13:16:08 -0700
committerGitHub <noreply@github.com>2024-04-17 13:16:08 -0700
commite15f47f2675a5400464aec00219658882df5e3fa (patch)
tree5f0e24f026b34cdf16111019d19738e1b4011d04 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
parent60b90b523323f8196a9e4a68b1f33358624c09eb (diff)
downloadllvm-e15f47f2675a5400464aec00219658882df5e3fa.zip
llvm-e15f47f2675a5400464aec00219658882df5e3fa.tar.gz
llvm-e15f47f2675a5400464aec00219658882df5e3fa.tar.bz2
[InstCombine] Don't use dominating conditions to transform sub into xor. (#88566)
Other passes are unable to reverse this transform if we use dominating conditions. Fixes #88239.
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index c59b867..df7f028 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -2281,8 +2281,10 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
if (match(Op0, m_APInt(Op0C))) {
if (Op0C->isMask()) {
// Turn this into a xor if LHS is 2^n-1 and the remaining bits are known
- // zero.
- KnownBits RHSKnown = computeKnownBits(Op1, 0, &I);
+ // zero. We don't use information from dominating conditions so this
+ // transform is easier to reverse if necessary.
+ KnownBits RHSKnown = llvm::computeKnownBits(
+ Op1, 0, SQ.getWithInstruction(&I).getWithoutDomCondCache());
if ((*Op0C | RHSKnown.Zero).isAllOnes())
return BinaryOperator::CreateXor(Op1, Op0);
}