[llvm] [InstCombine] Do not keep samesign when speculatively executing icmps (PR #127007)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 20:19:13 PST 2025
================
@@ -5636,6 +5636,11 @@ Instruction *InstCombinerImpl::foldICmpWithMinMax(Instruction &I,
return false;
return std::nullopt;
};
+ // Remove samesign here since it is illegal to keep it when we speculatively
+ // execute comparisons. For example, `icmp samesign ult umax(X, -46), -32`
+ // cannot be decomposed into `(icmp samesign ult X, -46) or (icmp samesign ult
+ // -46, -32)`. `X` is allowed to be non-negative here.
+ Pred = static_cast<CmpInst::Predicate>(Pred);
----------------
dtcxzyw wrote:
`samesign` flag is still needed before this line. We can avoid `isKnownNonNegative` queries if samesign is set.
https://github.com/llvm/llvm-project/pull/127007
More information about the llvm-commits
mailing list