[llvm] [InstCombine] Allow overflowing selects to work on communative arguments (PR #90812)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 09:16:16 PDT 2024
================
@@ -2075,12 +2075,23 @@ foldOverflowingAddSubSelect(SelectInst &SI, InstCombiner::BuilderTy &Builder) {
Value *FalseVal = SI.getFalseValue();
WithOverflowInst *II;
- if (!match(CondVal, m_ExtractValue<1>(m_WithOverflowInst(II))) ||
- !match(FalseVal, m_ExtractValue<0>(m_Specific(II))))
+ if (!match(CondVal, m_ExtractValue<1>(m_WithOverflowInst(II))))
return nullptr;
Value *X = II->getLHS();
Value *Y = II->getRHS();
+ if (!match(FalseVal, m_ExtractValue<0>(m_Specific(II)))) {
+ // Communinative adds can get missed, so check for X and Y being swapped
----------------
topperc wrote:
Communinative -> Commutative?
https://github.com/llvm/llvm-project/pull/90812
More information about the llvm-commits
mailing list