|
42 | 42 | #include "llvm/Support/KnownBits.h" |
43 | 43 | #include "llvm/Transforms/InstCombine/InstCombiner.h" |
44 | 44 | #include <cassert> |
45 | | -#include <cstddef> |
46 | | -#include <iostream> |
47 | 45 | #include <utility> |
48 | 46 |
|
49 | 47 | #define DEBUG_TYPE "instcombine" |
|
52 | 50 | using namespace llvm; |
53 | 51 | using namespace PatternMatch; |
54 | 52 |
|
| 53 | + |
55 | 54 | /// Replace a select operand based on an equality comparison with the identity |
56 | 55 | /// constant of a binop. |
57 | 56 | static Instruction *foldSelectBinOpIdentity(SelectInst &Sel, |
@@ -1714,6 +1713,7 @@ tryToReuseConstantFromSelectInComparison(SelectInst &Sel, ICmpInst &Cmp, |
1714 | 1713 | if (Pred == CmpInst::ICMP_ULT && match(X, m_Add(m_Value(), m_Constant()))) |
1715 | 1714 | return nullptr; |
1716 | 1715 |
|
| 1716 | + |
1717 | 1717 | Value *SelVal0, *SelVal1; // We do not care which one is from where. |
1718 | 1718 | match(&Sel, m_Select(m_Value(), m_Value(SelVal0), m_Value(SelVal1))); |
1719 | 1719 | // At least one of these values we are selecting between must be a constant |
@@ -2004,8 +2004,7 @@ Value *InstCombinerImpl::foldSelectWithConstOpToBinOp(ICmpInst *Cmp, |
2004 | 2004 | /// %b_sub' = usub.sat(y, IntConst2 - MostSignificantBit) |
2005 | 2005 | /// %or = or %a_sub', %b_sub' |
2006 | 2006 | /// %and = and %or, MostSignificantBit |
2007 | | -/// If the args are vectors |
2008 | | -/// |
| 2007 | +/// Likewise, for vector arguments as well. |
2009 | 2008 | static Instruction *foldICmpUSubSatWithAndForMostSignificantBitCmp( |
2010 | 2009 | SelectInst &SI, ICmpInst *ICI, InstCombiner::BuilderTy &Builder) { |
2011 | 2010 | auto *CI = dyn_cast<ICmpInst>(SI.getCondition()); |
@@ -4332,9 +4331,10 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) { |
4332 | 4331 | bool IsCastNeeded = LHS->getType() != SelType; |
4333 | 4332 | Value *CmpLHS = cast<CmpInst>(CondVal)->getOperand(0); |
4334 | 4333 | Value *CmpRHS = cast<CmpInst>(CondVal)->getOperand(1); |
4335 | | - if (IsCastNeeded || (LHS->getType()->isFPOrFPVectorTy() && |
4336 | | - ((CmpLHS != LHS && CmpLHS != RHS) || |
4337 | | - (CmpRHS != LHS && CmpRHS != RHS)))) { |
| 4334 | + if (IsCastNeeded || |
| 4335 | + (LHS->getType()->isFPOrFPVectorTy() && |
| 4336 | + ((CmpLHS != LHS && CmpLHS != RHS) || |
| 4337 | + (CmpRHS != LHS && CmpRHS != RHS)))) { |
4338 | 4338 | CmpInst::Predicate MinMaxPred = getMinMaxPred(SPF, SPR.Ordered); |
4339 | 4339 |
|
4340 | 4340 | Value *Cmp; |
|
0 commit comments