diff --git a/llvm/include/llvm/Analysis/InstSimplifyFolder.h b/llvm/include/llvm/Analysis/InstSimplifyFolder.h --- a/llvm/include/llvm/Analysis/InstSimplifyFolder.h +++ b/llvm/include/llvm/Analysis/InstSimplifyFolder.h @@ -48,38 +48,38 @@ //===--------------------------------------------------------------------===// Value *FoldAdd(Value *LHS, Value *RHS, bool HasNUW = false, bool HasNSW = false) const override { - return SimplifyAddInst(LHS, RHS, HasNUW, HasNSW, SQ); + return simplifyAddInst(LHS, RHS, HasNUW, HasNSW, SQ); } Value *FoldAnd(Value *LHS, Value *RHS) const override { - return SimplifyAndInst(LHS, RHS, SQ); + return simplifyAndInst(LHS, RHS, SQ); } Value *FoldOr(Value *LHS, Value *RHS) const override { - return SimplifyOrInst(LHS, RHS, SQ); + return simplifyOrInst(LHS, RHS, SQ); } Value *FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override { - return SimplifyICmpInst(P, LHS, RHS, SQ); + return simplifyICmpInst(P, LHS, RHS, SQ); } Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef IdxList, bool IsInBounds = false) const override { - return SimplifyGEPInst(Ty, Ptr, IdxList, IsInBounds, SQ); + return simplifyGEPInst(Ty, Ptr, IdxList, IsInBounds, SQ); } Value *FoldSelect(Value *C, Value *True, Value *False) const override { - return SimplifySelectInst(C, True, False, SQ); + return simplifySelectInst(C, True, False, SQ); } Value *FoldExtractValue(Value *Agg, ArrayRef IdxList) const override { - return SimplifyExtractValueInst(Agg, IdxList, SQ); + return simplifyExtractValueInst(Agg, IdxList, SQ); }; Value *FoldInsertValue(Value *Agg, Value *Val, ArrayRef IdxList) const override { - return SimplifyInsertValueInst(Agg, Val, IdxList, SQ); + return simplifyInsertValueInst(Agg, Val, IdxList, SQ); } //===--------------------------------------------------------------------===// diff --git a/llvm/include/llvm/Analysis/InstructionSimplify.h b/llvm/include/llvm/Analysis/InstructionSimplify.h --- a/llvm/include/llvm/Analysis/InstructionSimplify.h +++ b/llvm/include/llvm/Analysis/InstructionSimplify.h @@ -144,162 +144,162 @@ // Please use the SimplifyQuery versions in new code. /// Given operand for an FNeg, fold the result or return null. -Value *SimplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q); +Value *simplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q); /// Given operands for an Add, fold the result or return null. -Value *SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, +Value *simplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q); /// Given operands for a Sub, fold the result or return null. -Value *SimplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, +Value *simplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q); /// Given operands for an FAdd, fold the result or return null. Value * -SimplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF, +simplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for an FSub, fold the result or return null. Value * -SimplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF, +simplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for an FMul, fold the result or return null. Value * -SimplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF, +simplifyFMulInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for the multiplication of a FMA, fold the result or return -/// null. In contrast to SimplifyFMulInst, this function will not perform +/// null. In contrast to simplifyFMulInst, this function will not perform /// simplifications whose unrounded results differ when rounded to the argument /// type. -Value *SimplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF, +Value *simplifyFMAFMul(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for a Mul, fold the result or return null. -Value *SimplifyMulInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyMulInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an SDiv, fold the result or return null. -Value *SimplifySDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifySDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for a UDiv, fold the result or return null. -Value *SimplifyUDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyUDivInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an FDiv, fold the result or return null. Value * -SimplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF, +simplifyFDivInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for an SRem, fold the result or return null. -Value *SimplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifySRemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for a URem, fold the result or return null. -Value *SimplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyURemInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an FRem, fold the result or return null. Value * -SimplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF, +simplifyFRemInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven); /// Given operands for a Shl, fold the result or return null. -Value *SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, +Value *simplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q); /// Given operands for a LShr, fold the result or return null. -Value *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, +Value *simplifyLShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q); /// Given operands for a AShr, fold the result or return nulll. -Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, +Value *simplifyAShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q); /// Given operands for an And, fold the result or return null. -Value *SimplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyAndInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an Or, fold the result or return null. -Value *SimplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an Xor, fold the result or return null. -Value *SimplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); +Value *simplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an ICmpInst, fold the result or return null. -Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for an FCmpInst, fold the result or return null. -Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q); /// Given operands for a SelectInst, fold the result or return null. -Value *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, +Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q); /// Given operands for a GetElementPtrInst, fold the result or return null. -Value *SimplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef Indices, +Value *simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef Indices, bool InBounds, const SimplifyQuery &Q); /// Given operands for an InsertValueInst, fold the result or return null. -Value *SimplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef Idxs, +Value *simplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef Idxs, const SimplifyQuery &Q); /// Given operands for an InsertElement, fold the result or return null. -Value *SimplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx, +Value *simplifyInsertElementInst(Value *Vec, Value *Elt, Value *Idx, const SimplifyQuery &Q); /// Given operands for an ExtractValueInst, fold the result or return null. -Value *SimplifyExtractValueInst(Value *Agg, ArrayRef Idxs, +Value *simplifyExtractValueInst(Value *Agg, ArrayRef Idxs, const SimplifyQuery &Q); /// Given operands for an ExtractElementInst, fold the result or return null. -Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, +Value *simplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQuery &Q); /// Given operands for a CastInst, fold the result or return null. -Value *SimplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, +Value *simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q); /// Given operands for a ShuffleVectorInst, fold the result or return null. /// See class ShuffleVectorInst for a description of the mask representation. -Value *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef Mask, +Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef Mask, Type *RetTy, const SimplifyQuery &Q); //=== Helper functions for higher up the class hierarchy. /// Given operands for a CmpInst, fold the result or return null. -Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operand for a UnaryOperator, fold the result or return null. -Value *SimplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q); +Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q); /// Given operand for a UnaryOperator, fold the result or return null. /// Try to use FastMathFlags when folding the result. -Value *SimplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF, +Value *simplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF, const SimplifyQuery &Q); /// Given operands for a BinaryOperator, fold the result or return null. -Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, +Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q); /// Given operands for a BinaryOperator, fold the result or return null. /// Try to use FastMathFlags when folding the result. -Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF, +Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q); /// Given a callsite, fold the result or return null. -Value *SimplifyCall(CallBase *Call, const SimplifyQuery &Q); +Value *simplifyCall(CallBase *Call, const SimplifyQuery &Q); /// Given a constrained FP intrinsic call, tries to compute its simplified /// version. Returns a simplified result or null. @@ -308,21 +308,21 @@ /// simplification succeeds that the intrinsic is side effect free. As a result, /// successful simplification can be used to delete the intrinsic not just /// replace its result. -Value *SimplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q); +Value *simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q); /// Given an operand for a Freeze, see if we can fold the result. /// If not, this returns null. -Value *SimplifyFreezeInst(Value *Op, const SimplifyQuery &Q); +Value *simplifyFreezeInst(Value *Op, const SimplifyQuery &Q); /// See if we can compute a simplified version of this instruction. If not, /// return null. -Value *SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, +Value *simplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE = nullptr); -/// Like \p SimplifyInstruction but the operands of \p I are replaced with +/// Like \p simplifyInstruction but the operands of \p I are replaced with /// \p NewOps. Returns a simplified value, or null if none was found. Value * -SimplifyInstructionWithOperands(Instruction *I, ArrayRef NewOps, +simplifyInstructionWithOperands(Instruction *I, ArrayRef NewOps, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE = nullptr); diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1984,11 +1984,11 @@ Value *SimpleV = nullptr; if (auto FI = dyn_cast(&I)) - SimpleV = SimplifyBinOp(I.getOpcode(), CLHS ? CLHS : LHS, CRHS ? CRHS : RHS, + SimpleV = simplifyBinOp(I.getOpcode(), CLHS ? CLHS : LHS, CRHS ? CRHS : RHS, FI->getFastMathFlags(), DL); else SimpleV = - SimplifyBinOp(I.getOpcode(), CLHS ? CLHS : LHS, CRHS ? CRHS : RHS, DL); + simplifyBinOp(I.getOpcode(), CLHS ? CLHS : LHS, CRHS ? CRHS : RHS, DL); if (Constant *C = dyn_cast_or_null(SimpleV)) SimplifiedValues[&I] = C; @@ -2018,7 +2018,7 @@ if (!COp) COp = SimplifiedValues.lookup(Op); - Value *SimpleV = SimplifyFNegInst( + Value *SimpleV = simplifyFNegInst( COp ? COp : Op, cast(I).getFastMathFlags(), DL); if (Constant *C = dyn_cast_or_null(SimpleV)) diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -48,28 +48,30 @@ enum { RecursionLimit = 3 }; -STATISTIC(NumExpand, "Number of expansions"); +STATISTIC(NumExpand, "Number of expansions"); STATISTIC(NumReassoc, "Number of reassociations"); -static Value *SimplifyAndInst(Value *, Value *, const SimplifyQuery &, unsigned); +static Value *simplifyAndInst(Value *, Value *, const SimplifyQuery &, + unsigned); static Value *simplifyUnOp(unsigned, Value *, const SimplifyQuery &, unsigned); static Value *simplifyFPUnOp(unsigned, Value *, const FastMathFlags &, const SimplifyQuery &, unsigned); -static Value *SimplifyBinOp(unsigned, Value *, Value *, const SimplifyQuery &, +static Value *simplifyBinOp(unsigned, Value *, Value *, const SimplifyQuery &, unsigned); -static Value *SimplifyBinOp(unsigned, Value *, Value *, const FastMathFlags &, +static Value *simplifyBinOp(unsigned, Value *, Value *, const FastMathFlags &, const SimplifyQuery &, unsigned); -static Value *SimplifyCmpInst(unsigned, Value *, Value *, const SimplifyQuery &, +static Value *simplifyCmpInst(unsigned, Value *, Value *, const SimplifyQuery &, unsigned); -static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, +static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse); -static Value *SimplifyOrInst(Value *, Value *, const SimplifyQuery &, unsigned); -static Value *SimplifyXorInst(Value *, Value *, const SimplifyQuery &, unsigned); -static Value *SimplifyCastInst(unsigned, Value *, Type *, - const SimplifyQuery &, unsigned); -static Value *SimplifyGEPInst(Type *, Value *, ArrayRef, bool, +static Value *simplifyOrInst(Value *, Value *, const SimplifyQuery &, unsigned); +static Value *simplifyXorInst(Value *, Value *, const SimplifyQuery &, + unsigned); +static Value *simplifyCastInst(unsigned, Value *, Type *, const SimplifyQuery &, + unsigned); +static Value *simplifyGEPInst(Type *, Value *, ArrayRef, bool, const SimplifyQuery &, unsigned); -static Value *SimplifySelectInst(Value *, Value *, Value *, +static Value *simplifySelectInst(Value *, Value *, Value *, const SimplifyQuery &, unsigned); static Value *foldSelectWithBinaryOp(Value *Cond, Value *TrueVal, @@ -116,15 +118,11 @@ /// For a boolean type or a vector of boolean type, return false or a vector /// with every element false. -static Constant *getFalse(Type *Ty) { - return ConstantInt::getFalse(Ty); -} +static Constant *getFalse(Type *Ty) { return ConstantInt::getFalse(Ty); } /// For a boolean type or a vector of boolean type, return true or a vector /// with every element true. -static Constant *getTrue(Type *Ty) { - return ConstantInt::getTrue(Ty); -} +static Constant *getTrue(Type *Ty) { return ConstantInt::getTrue(Ty); } /// isSameCompare - Is V equivalent to the comparison "LHS Pred RHS"? static bool isSameCompare(Value *V, CmpInst::Predicate Pred, Value *LHS, @@ -137,7 +135,7 @@ if (CPred == Pred && CLHS == LHS && CRHS == RHS) return true; return CPred == CmpInst::getSwappedPredicate(Pred) && CLHS == RHS && - CRHS == LHS; + CRHS == LHS; } /// Simplify comparison with true or false branch of select: @@ -149,7 +147,7 @@ Value *RHS, Value *Cond, const SimplifyQuery &Q, unsigned MaxRecurse, Constant *TrueOrFalse) { - Value *SimplifiedCmp = SimplifyCmpInst(Pred, LHS, RHS, Q, MaxRecurse); + Value *SimplifiedCmp = simplifyCmpInst(Pred, LHS, RHS, Q, MaxRecurse); if (SimplifiedCmp == Cond) { // %cmp simplified to the select condition (%cond). return TrueOrFalse; @@ -192,17 +190,17 @@ // checks whether folding it does not convert a well-defined value into // poison. if (match(FCmp, m_Zero()) && impliesPoison(TCmp, Cond)) - if (Value *V = SimplifyAndInst(Cond, TCmp, Q, MaxRecurse)) + if (Value *V = simplifyAndInst(Cond, TCmp, Q, MaxRecurse)) return V; // If the true value simplified to true, then the result of the compare // is equal to "Cond || FCmp". if (match(TCmp, m_One()) && impliesPoison(FCmp, Cond)) - if (Value *V = SimplifyOrInst(Cond, FCmp, Q, MaxRecurse)) + if (Value *V = simplifyOrInst(Cond, FCmp, Q, MaxRecurse)) return V; // Finally, if the false value simplified to true and the true value to // false, then the result of the compare is equal to "!Cond". if (match(FCmp, m_One()) && match(TCmp, m_Zero())) - if (Value *V = SimplifyXorInst( + if (Value *V = simplifyXorInst( Cond, Constant::getAllOnesValue(Cond->getType()), Q, MaxRecurse)) return V; return nullptr; @@ -244,12 +242,12 @@ if (!B || B->getOpcode() != OpcodeToExpand) return nullptr; Value *B0 = B->getOperand(0), *B1 = B->getOperand(1); - Value *L = SimplifyBinOp(Opcode, B0, OtherOp, Q.getWithoutUndef(), - MaxRecurse); + Value *L = + simplifyBinOp(Opcode, B0, OtherOp, Q.getWithoutUndef(), MaxRecurse); if (!L) return nullptr; - Value *R = SimplifyBinOp(Opcode, B1, OtherOp, Q.getWithoutUndef(), - MaxRecurse); + Value *R = + simplifyBinOp(Opcode, B1, OtherOp, Q.getWithoutUndef(), MaxRecurse); if (!R) return nullptr; @@ -261,7 +259,7 @@ } // Otherwise, return "L op' R" if it simplifies. - Value *S = SimplifyBinOp(OpcodeToExpand, L, R, Q, MaxRecurse); + Value *S = simplifyBinOp(OpcodeToExpand, L, R, Q, MaxRecurse); if (!S) return nullptr; @@ -271,8 +269,8 @@ /// Try to simplify binops of form "A op (B op' C)" or the commuted variant by /// distributing op over op'. -static Value *expandCommutativeBinOp(Instruction::BinaryOps Opcode, - Value *L, Value *R, +static Value *expandCommutativeBinOp(Instruction::BinaryOps Opcode, Value *L, + Value *R, Instruction::BinaryOps OpcodeToExpand, const SimplifyQuery &Q, unsigned MaxRecurse) { @@ -289,7 +287,7 @@ /// Generic simplifications for associative binary operations. /// Returns the simpler value, or null if none was found. -static Value *SimplifyAssociativeBinOp(Instruction::BinaryOps Opcode, +static Value *simplifyAssociativeBinOp(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { @@ -309,12 +307,13 @@ Value *C = RHS; // Does "B op C" simplify? - if (Value *V = SimplifyBinOp(Opcode, B, C, Q, MaxRecurse)) { + if (Value *V = simplifyBinOp(Opcode, B, C, Q, MaxRecurse)) { // It does! Return "A op V" if it simplifies or is already available. // If V equals B then "A op V" is just the LHS. - if (V == B) return LHS; + if (V == B) + return LHS; // Otherwise return "A op V" if it simplifies. - if (Value *W = SimplifyBinOp(Opcode, A, V, Q, MaxRecurse)) { + if (Value *W = simplifyBinOp(Opcode, A, V, Q, MaxRecurse)) { ++NumReassoc; return W; } @@ -328,12 +327,13 @@ Value *C = Op1->getOperand(1); // Does "A op B" simplify? - if (Value *V = SimplifyBinOp(Opcode, A, B, Q, MaxRecurse)) { + if (Value *V = simplifyBinOp(Opcode, A, B, Q, MaxRecurse)) { // It does! Return "V op C" if it simplifies or is already available. // If V equals B then "V op C" is just the RHS. - if (V == B) return RHS; + if (V == B) + return RHS; // Otherwise return "V op C" if it simplifies. - if (Value *W = SimplifyBinOp(Opcode, V, C, Q, MaxRecurse)) { + if (Value *W = simplifyBinOp(Opcode, V, C, Q, MaxRecurse)) { ++NumReassoc; return W; } @@ -351,12 +351,13 @@ Value *C = RHS; // Does "C op A" simplify? - if (Value *V = SimplifyBinOp(Opcode, C, A, Q, MaxRecurse)) { + if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) { // It does! Return "V op B" if it simplifies or is already available. // If V equals A then "V op B" is just the LHS. - if (V == A) return LHS; + if (V == A) + return LHS; // Otherwise return "V op B" if it simplifies. - if (Value *W = SimplifyBinOp(Opcode, V, B, Q, MaxRecurse)) { + if (Value *W = simplifyBinOp(Opcode, V, B, Q, MaxRecurse)) { ++NumReassoc; return W; } @@ -370,12 +371,13 @@ Value *C = Op1->getOperand(1); // Does "C op A" simplify? - if (Value *V = SimplifyBinOp(Opcode, C, A, Q, MaxRecurse)) { + if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) { // It does! Return "B op V" if it simplifies or is already available. // If V equals C then "B op V" is just the RHS. - if (V == C) return RHS; + if (V == C) + return RHS; // Otherwise return "B op V" if it simplifies. - if (Value *W = SimplifyBinOp(Opcode, B, V, Q, MaxRecurse)) { + if (Value *W = simplifyBinOp(Opcode, B, V, Q, MaxRecurse)) { ++NumReassoc; return W; } @@ -389,7 +391,7 @@ /// try to simplify the binop by seeing whether evaluating it on both branches /// of the select results in the same value. Returns the common value if so, /// otherwise returns null. -static Value *ThreadBinOpOverSelect(Instruction::BinaryOps Opcode, Value *LHS, +static Value *threadBinOpOverSelect(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { // Recursion is always used, so bail out at once if we already hit the limit. @@ -408,11 +410,11 @@ Value *TV; Value *FV; if (SI == LHS) { - TV = SimplifyBinOp(Opcode, SI->getTrueValue(), RHS, Q, MaxRecurse); - FV = SimplifyBinOp(Opcode, SI->getFalseValue(), RHS, Q, MaxRecurse); + TV = simplifyBinOp(Opcode, SI->getTrueValue(), RHS, Q, MaxRecurse); + FV = simplifyBinOp(Opcode, SI->getFalseValue(), RHS, Q, MaxRecurse); } else { - TV = SimplifyBinOp(Opcode, LHS, SI->getTrueValue(), Q, MaxRecurse); - FV = SimplifyBinOp(Opcode, LHS, SI->getFalseValue(), Q, MaxRecurse); + TV = simplifyBinOp(Opcode, LHS, SI->getTrueValue(), Q, MaxRecurse); + FV = simplifyBinOp(Opcode, LHS, SI->getFalseValue(), Q, MaxRecurse); } // If they simplified to the same value, then return the common value. @@ -467,7 +469,7 @@ /// We can simplify %cmp1 to true, because both branches of select are /// less than 3. We compose new comparison by substituting %tmp with both /// branches of select and see if it can be simplified. -static Value *ThreadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS, +static Value *threadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { // Recursion is always used, so bail out at once if we already hit the limit. @@ -513,7 +515,7 @@ /// try to simplify the binop by seeing whether evaluating it on the incoming /// phi values yields the same result for every value. If so returns the common /// value, otherwise returns null. -static Value *ThreadBinOpOverPHI(Instruction::BinaryOps Opcode, Value *LHS, +static Value *threadBinOpOverPHI(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { // Recursion is always used, so bail out at once if we already hit the limit. @@ -538,10 +540,10 @@ Value *CommonValue = nullptr; for (Value *Incoming : PI->incoming_values()) { // If the incoming value is the phi node itself, it can safely be skipped. - if (Incoming == PI) continue; - Value *V = PI == LHS ? - SimplifyBinOp(Opcode, Incoming, RHS, Q, MaxRecurse) : - SimplifyBinOp(Opcode, LHS, Incoming, Q, MaxRecurse); + if (Incoming == PI) + continue; + Value *V = PI == LHS ? simplifyBinOp(Opcode, Incoming, RHS, Q, MaxRecurse) + : simplifyBinOp(Opcode, LHS, Incoming, Q, MaxRecurse); // If the operation failed to simplify, or simplified to a different value // to previously, then give up. if (!V || (CommonValue && V != CommonValue)) @@ -556,7 +558,7 @@ /// comparison by seeing whether comparing with all of the incoming phi values /// yields the same result every time. If so returns the common result, /// otherwise returns null. -static Value *ThreadCmpOverPHI(CmpInst::Predicate Pred, Value *LHS, Value *RHS, +static Value *threadCmpOverPHI(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { // Recursion is always used, so bail out at once if we already hit the limit. if (!MaxRecurse--) @@ -580,11 +582,12 @@ Value *Incoming = PI->getIncomingValue(u); Instruction *InTI = PI->getIncomingBlock(u)->getTerminator(); // If the incoming value is the phi node itself, it can safely be skipped. - if (Incoming == PI) continue; + if (Incoming == PI) + continue; // Change the context instruction to the "edge" that flows into the phi. // This is important because that is where incoming is actually "evaluated" // even though it is used later somewhere else. - Value *V = SimplifyCmpInst(Pred, Incoming, RHS, Q.getWithInstruction(InTI), + Value *V = simplifyCmpInst(Pred, Incoming, RHS, Q.getWithInstruction(InTI), MaxRecurse); // If the operation failed to simplify, or simplified to a different value // to previously, then give up. @@ -612,7 +615,7 @@ /// Given operands for an Add, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, +static Value *simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::Add, Op0, Op1, Q)) return C; @@ -643,8 +646,7 @@ // X + ~X -> -1 since ~X = -X-1 Type *Ty = Op0->getType(); - if (match(Op0, m_Not(m_Specific(Op1))) || - match(Op1, m_Not(m_Specific(Op0)))) + if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) return Constant::getAllOnesValue(Ty); // add nsw/nuw (xor Y, signmask), signmask --> Y @@ -660,12 +662,12 @@ /// i1 add -> xor. if (MaxRecurse && Op0->getType()->isIntOrIntVectorTy(1)) - if (Value *V = SimplifyXorInst(Op0, Op1, Q, MaxRecurse-1)) + if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1)) return V; // Try some generic simplifications for associative operations. - if (Value *V = SimplifyAssociativeBinOp(Instruction::Add, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + simplifyAssociativeBinOp(Instruction::Add, Op0, Op1, Q, MaxRecurse)) return V; // Threading Add over selects and phi nodes is pointless, so don't bother. @@ -680,9 +682,9 @@ return nullptr; } -Value *llvm::SimplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, +Value *llvm::simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, const SimplifyQuery &Query) { - return ::SimplifyAddInst(Op0, Op1, IsNSW, IsNUW, Query, RecursionLimit); + return ::simplifyAddInst(Op0, Op1, IsNSW, IsNUW, Query, RecursionLimit); } /// Compute the base pointer and cumulative constant offsets for V. @@ -729,7 +731,7 @@ /// Given operands for a Sub, see if we can fold the result. /// If not, this returns null. -static Value *SimplifySubInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, +static Value *simplifySubInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::Sub, Op0, Op1, Q)) return C; @@ -775,17 +777,17 @@ Value *X = nullptr, *Y = nullptr, *Z = Op1; if (MaxRecurse && match(Op0, m_Add(m_Value(X), m_Value(Y)))) { // (X + Y) - Z // See if "V === Y - Z" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, Y, Z, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, Y, Z, Q, MaxRecurse - 1)) // It does! Now see if "X + V" simplifies. - if (Value *W = SimplifyBinOp(Instruction::Add, X, V, Q, MaxRecurse-1)) { + if (Value *W = simplifyBinOp(Instruction::Add, X, V, Q, MaxRecurse - 1)) { // It does, we successfully reassociated! ++NumReassoc; return W; } // See if "V === X - Z" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1)) // It does! Now see if "Y + V" simplifies. - if (Value *W = SimplifyBinOp(Instruction::Add, Y, V, Q, MaxRecurse-1)) { + if (Value *W = simplifyBinOp(Instruction::Add, Y, V, Q, MaxRecurse - 1)) { // It does, we successfully reassociated! ++NumReassoc; return W; @@ -797,17 +799,17 @@ X = Op0; if (MaxRecurse && match(Op1, m_Add(m_Value(Y), m_Value(Z)))) { // X - (Y + Z) // See if "V === X - Y" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1)) // It does! Now see if "V - Z" simplifies. - if (Value *W = SimplifyBinOp(Instruction::Sub, V, Z, Q, MaxRecurse-1)) { + if (Value *W = simplifyBinOp(Instruction::Sub, V, Z, Q, MaxRecurse - 1)) { // It does, we successfully reassociated! ++NumReassoc; return W; } // See if "V === X - Z" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1)) // It does! Now see if "V - Y" simplifies. - if (Value *W = SimplifyBinOp(Instruction::Sub, V, Y, Q, MaxRecurse-1)) { + if (Value *W = simplifyBinOp(Instruction::Sub, V, Y, Q, MaxRecurse - 1)) { // It does, we successfully reassociated! ++NumReassoc; return W; @@ -819,9 +821,9 @@ Z = Op0; if (MaxRecurse && match(Op1, m_Sub(m_Value(X), m_Value(Y)))) // Z - (X - Y) // See if "V === Z - X" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, Z, X, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, Z, X, Q, MaxRecurse - 1)) // It does! Now see if "V + Y" simplifies. - if (Value *W = SimplifyBinOp(Instruction::Add, V, Y, Q, MaxRecurse-1)) { + if (Value *W = simplifyBinOp(Instruction::Add, V, Y, Q, MaxRecurse - 1)) { // It does, we successfully reassociated! ++NumReassoc; return W; @@ -832,22 +834,21 @@ match(Op1, m_Trunc(m_Value(Y)))) if (X->getType() == Y->getType()) // See if "V === X - Y" simplifies. - if (Value *V = SimplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse-1)) + if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1)) // It does! Now see if "trunc V" simplifies. - if (Value *W = SimplifyCastInst(Instruction::Trunc, V, Op0->getType(), + if (Value *W = simplifyCastInst(Instruction::Trunc, V, Op0->getType(), Q, MaxRecurse - 1)) // It does, return the simplified "trunc V". return W; // Variations on GEP(base, I, ...) - GEP(base, i, ...) -> GEP(null, I-i, ...). - if (match(Op0, m_PtrToInt(m_Value(X))) && - match(Op1, m_PtrToInt(m_Value(Y)))) + if (match(Op0, m_PtrToInt(m_Value(X))) && match(Op1, m_PtrToInt(m_Value(Y)))) if (Constant *Result = computePointerDifference(Q.DL, X, Y)) return ConstantExpr::getIntegerCast(Result, Op0->getType(), true); // i1 sub -> xor. if (MaxRecurse && Op0->getType()->isIntOrIntVectorTy(1)) - if (Value *V = SimplifyXorInst(Op0, Op1, Q, MaxRecurse-1)) + if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1)) return V; // Threading Sub over selects and phi nodes is pointless, so don't bother. @@ -862,14 +863,14 @@ return nullptr; } -Value *llvm::SimplifySubInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, +Value *llvm::simplifySubInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q) { - return ::SimplifySubInst(Op0, Op1, isNSW, isNUW, Q, RecursionLimit); + return ::simplifySubInst(Op0, Op1, isNSW, isNUW, Q, RecursionLimit); } /// Given operands for a Mul, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyMulInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyMulInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::Mul, Op0, Op1, Q)) return C; @@ -897,12 +898,12 @@ // i1 mul -> and. if (MaxRecurse && Op0->getType()->isIntOrIntVectorTy(1)) - if (Value *V = SimplifyAndInst(Op0, Op1, Q, MaxRecurse-1)) + if (Value *V = simplifyAndInst(Op0, Op1, Q, MaxRecurse - 1)) return V; // Try some generic simplifications for associative operations. - if (Value *V = SimplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + simplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) return V; // Mul distributes over Add. Try some generic simplifications based on this. @@ -913,22 +914,22 @@ // If the operation is with the result of a select instruction, check whether // operating on either branch of the select always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverSelect(Instruction::Mul, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + threadBinOpOverSelect(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) return V; // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Instruction::Mul, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + threadBinOpOverPHI(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) return V; return nullptr; } -Value *llvm::SimplifyMulInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyMulInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyMulInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyMulInst(Op0, Op1, Q, RecursionLimit); } /// Check for common or similar folds of integer division or integer remainder. @@ -1017,7 +1018,7 @@ /// when we can prove a relationship between the operands. static bool isICmpTrue(ICmpInst::Predicate Pred, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { - Value *V = SimplifyICmpInst(Pred, LHS, RHS, Q, MaxRecurse); + Value *V = simplifyICmpInst(Pred, LHS, RHS, Q, MaxRecurse); Constant *C = dyn_cast_or_null(V); return (C && C->isAllOnesValue()); } @@ -1113,13 +1114,13 @@ // If the operation is with the result of a select instruction, check whether // operating on either branch of the select always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) return V; // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) return V; if (isDivZero(Op0, Op1, Q, MaxRecurse, IsSigned)) @@ -1155,13 +1156,13 @@ // If the operation is with the result of a select instruction, check whether // operating on either branch of the select always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) return V; // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) return V; // If X / Y == 0, then X % Y == X. @@ -1173,7 +1174,7 @@ /// Given operands for an SDiv, see if we can fold the result. /// If not, this returns null. -static Value *SimplifySDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifySDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { // If two operands are negated and no signed overflow, return -1. if (isKnownNegation(Op0, Op1, /*NeedNSW=*/true)) @@ -1182,24 +1183,24 @@ return simplifyDiv(Instruction::SDiv, Op0, Op1, Q, MaxRecurse); } -Value *llvm::SimplifySDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifySDivInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifySDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifySDivInst(Op0, Op1, Q, RecursionLimit); } /// Given operands for a UDiv, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyUDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyUDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { return simplifyDiv(Instruction::UDiv, Op0, Op1, Q, MaxRecurse); } -Value *llvm::SimplifyUDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyUDivInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyUDivInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyUDivInst(Op0, Op1, Q, RecursionLimit); } /// Given operands for an SRem, see if we can fold the result. /// If not, this returns null. -static Value *SimplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { // If the divisor is 0, the result is undefined, so assume the divisor is -1. // srem Op0, (sext i1 X) --> srem Op0, -1 --> 0 @@ -1214,19 +1215,19 @@ return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse); } -Value *llvm::SimplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifySRemInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifySRemInst(Op0, Op1, Q, RecursionLimit); } /// Given operands for a URem, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { return simplifyRem(Instruction::URem, Op0, Op1, Q, MaxRecurse); } -Value *llvm::SimplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyURemInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyURemInst(Op0, Op1, Q, RecursionLimit); } /// Returns true if a shift by \c Amount always yields poison. @@ -1259,7 +1260,7 @@ /// Given operands for an Shl, LShr or AShr, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyShift(Instruction::BinaryOps Opcode, Value *Op0, +static Value *simplifyShift(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, bool IsNSW, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q)) @@ -1288,13 +1289,13 @@ // If the operation is with the result of a select instruction, check whether // operating on either branch of the select always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) return V; // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) return V; // If any bits in the shift amount make that value greater than or equal to @@ -1329,11 +1330,11 @@ /// Given operands for an Shl, LShr or AShr, see if we can /// fold the result. If not, this returns null. -static Value *SimplifyRightShift(Instruction::BinaryOps Opcode, Value *Op0, - Value *Op1, bool isExact, const SimplifyQuery &Q, - unsigned MaxRecurse) { +static Value *simplifyRightShift(Instruction::BinaryOps Opcode, Value *Op0, + Value *Op1, bool isExact, + const SimplifyQuery &Q, unsigned MaxRecurse) { if (Value *V = - SimplifyShift(Opcode, Op0, Op1, /*IsNSW*/ false, Q, MaxRecurse)) + simplifyShift(Opcode, Op0, Op1, /*IsNSW*/ false, Q, MaxRecurse)) return V; // X >> X -> 0 @@ -1347,7 +1348,8 @@ // The low bit cannot be shifted out of an exact shift if it is set. if (isExact) { - KnownBits Op0Known = computeKnownBits(Op0, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT); + KnownBits Op0Known = + computeKnownBits(Op0, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT); if (Op0Known.One[0]) return Op0; } @@ -1357,10 +1359,10 @@ /// Given operands for an Shl, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, +static Value *simplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Value *V = - SimplifyShift(Instruction::Shl, Op0, Op1, isNSW, Q, MaxRecurse)) + simplifyShift(Instruction::Shl, Op0, Op1, isNSW, Q, MaxRecurse)) return V; // undef << X -> 0 @@ -1383,18 +1385,18 @@ return nullptr; } -Value *llvm::SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, +Value *llvm::simplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, const SimplifyQuery &Q) { - return ::SimplifyShlInst(Op0, Op1, isNSW, isNUW, Q, RecursionLimit); + return ::simplifyShlInst(Op0, Op1, isNSW, isNUW, Q, RecursionLimit); } /// Given operands for an LShr, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, +static Value *simplifyLShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q, unsigned MaxRecurse) { - if (Value *V = SimplifyRightShift(Instruction::LShr, Op0, Op1, isExact, Q, + if (Value *V = simplifyRightShift(Instruction::LShr, Op0, Op1, isExact, Q, MaxRecurse)) - return V; + return V; // (X << A) >> A -> X Value *X; @@ -1420,16 +1422,16 @@ return nullptr; } -Value *llvm::SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, +Value *llvm::simplifyLShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q) { - return ::SimplifyLShrInst(Op0, Op1, isExact, Q, RecursionLimit); + return ::simplifyLShrInst(Op0, Op1, isExact, Q, RecursionLimit); } /// Given operands for an AShr, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, +static Value *simplifyAShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q, unsigned MaxRecurse) { - if (Value *V = SimplifyRightShift(Instruction::AShr, Op0, Op1, isExact, Q, + if (Value *V = simplifyRightShift(Instruction::AShr, Op0, Op1, isExact, Q, MaxRecurse)) return V; @@ -1453,9 +1455,9 @@ return nullptr; } -Value *llvm::SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, +Value *llvm::simplifyAShrInst(Value *Op0, Value *Op1, bool isExact, const SimplifyQuery &Q) { - return ::SimplifyAShrInst(Op0, Op1, isExact, Q, RecursionLimit); + return ::simplifyAShrInst(Op0, Op1, isExact, Q, RecursionLimit); } /// Commuted variants are assumed to be handled by calling this function again @@ -1572,7 +1574,7 @@ /// with the parameters swapped. static Value *simplifyAndOfICmpsWithSameOperands(ICmpInst *Op0, ICmpInst *Op1) { ICmpInst::Predicate Pred0, Pred1; - Value *A ,*B; + Value *A, *B; if (!match(Op0, m_ICmp(Pred0, m_Value(A), m_Value(B))) || !match(Op1, m_ICmp(Pred1, m_Specific(A), m_Specific(B)))) return nullptr; @@ -1597,7 +1599,7 @@ /// with the parameters swapped. static Value *simplifyOrOfICmpsWithSameOperands(ICmpInst *Op0, ICmpInst *Op1) { ICmpInst::Predicate Pred0, Pred1; - Value *A ,*B; + Value *A, *B; if (!match(Op0, m_ICmp(Pred0, m_Value(A), m_Value(B))) || !match(Op1, m_ICmp(Pred1, m_Specific(A), m_Specific(B)))) return nullptr; @@ -1939,8 +1941,8 @@ return nullptr; } -static Value *simplifyAndOrOfFCmps(const TargetLibraryInfo *TLI, - FCmpInst *LHS, FCmpInst *RHS, bool IsAnd) { +static Value *simplifyAndOrOfFCmps(const TargetLibraryInfo *TLI, FCmpInst *LHS, + FCmpInst *RHS, bool IsAnd) { Value *LHS0 = LHS->getOperand(0), *LHS1 = LHS->getOperand(1); Value *RHS0 = RHS->getOperand(0), *RHS1 = RHS->getOperand(1); if (LHS0->getType() != RHS0->getType()) @@ -1977,8 +1979,8 @@ return nullptr; } -static Value *simplifyAndOrOfCmps(const SimplifyQuery &Q, - Value *Op0, Value *Op1, bool IsAnd) { +static Value *simplifyAndOrOfCmps(const SimplifyQuery &Q, Value *Op0, + Value *Op1, bool IsAnd) { // Look through casts of the 'and' operands to find compares. auto *Cast0 = dyn_cast(Op0); auto *Cast1 = dyn_cast(Op1); @@ -2039,7 +2041,7 @@ /// Given operands for an And, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::And, Op0, Op1, Q)) return C; @@ -2065,8 +2067,7 @@ return Op0; // A & ~A = ~A & A = 0 - if (match(Op0, m_Not(m_Specific(Op1))) || - match(Op1, m_Not(m_Specific(Op0)))) + if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) return Constant::getNullValue(Op0->getType()); // (A | ?) & A = A @@ -2139,8 +2140,8 @@ return V; // Try some generic simplifications for associative operations. - if (Value *V = SimplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + simplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q, MaxRecurse)) return V; // And distributes over Or. Try some generic simplifications based on this. @@ -2164,16 +2165,16 @@ // If the operation is with the result of a select instruction, check // whether operating on either branch of the select always yields the same // value. - if (Value *V = ThreadBinOpOverSelect(Instruction::And, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + threadBinOpOverSelect(Instruction::And, Op0, Op1, Q, MaxRecurse)) return V; } // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Instruction::And, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + threadBinOpOverPHI(Instruction::And, Op0, Op1, Q, MaxRecurse)) return V; // Assuming the effective width of Y is not larger than A, i.e. all bits @@ -2196,8 +2197,7 @@ const KnownBits YKnown = computeKnownBits(Y, Q.DL, 0, Q.AC, Q.CxtI, Q.DT); const unsigned EffWidthY = YKnown.countMaxActiveBits(); if (EffWidthY <= ShftCnt) { - const KnownBits XKnown = computeKnownBits(X, Q.DL, 0, Q.AC, Q.CxtI, - Q.DT); + const KnownBits XKnown = computeKnownBits(X, Q.DL, 0, Q.AC, Q.CxtI, Q.DT); const unsigned EffWidthX = XKnown.countMaxActiveBits(); const APInt EffBitsY = APInt::getLowBitsSet(Width, EffWidthY); const APInt EffBitsX = APInt::getLowBitsSet(Width, EffWidthX) << ShftCnt; @@ -2231,8 +2231,8 @@ return nullptr; } -Value *llvm::SimplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyAndInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyAndInst(Op0, Op1, Q, RecursionLimit); } static Value *simplifyOrLogic(Value *X, Value *Y) { @@ -2320,7 +2320,7 @@ /// Given operands for an Or, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::Or, Op0, Op1, Q)) return C; @@ -2402,8 +2402,8 @@ return Op0; // Try some generic simplifications for associative operations. - if (Value *V = SimplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + simplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, MaxRecurse)) return V; // Or distributes over And. Try some generic simplifications based on this. @@ -2422,8 +2422,8 @@ // If the operation is with the result of a select instruction, check // whether operating on either branch of the select always yields the same // value. - if (Value *V = ThreadBinOpOverSelect(Instruction::Or, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + threadBinOpOverSelect(Instruction::Or, Op0, Op1, Q, MaxRecurse)) return V; } @@ -2445,8 +2445,7 @@ return A; } // Or commutes, try both ways. - if (C1->isMask() && - match(B, m_c_Add(m_Specific(A), m_Value(N)))) { + if (C1->isMask() && match(B, m_c_Add(m_Specific(A), m_Value(N)))) { // Add commutes, try both ways. if (MaskedValueIsZero(N, *C1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT)) return B; @@ -2457,7 +2456,7 @@ // If the operation is with the result of a phi instruction, check whether // operating on all incoming values of the phi always yields the same value. if (isa(Op0) || isa(Op1)) - if (Value *V = ThreadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse)) + if (Value *V = threadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse)) return V; if (Op0->getType()->isIntOrIntVectorTy(1)) { @@ -2472,13 +2471,13 @@ return nullptr; } -Value *llvm::SimplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyOrInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyOrInst(Op0, Op1, Q, RecursionLimit); } /// Given operands for a Xor, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, +static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, unsigned MaxRecurse) { if (Constant *C = foldOrCommuteConstant(Instruction::Xor, Op0, Op1, Q)) return C; @@ -2500,8 +2499,7 @@ return Constant::getNullValue(Op0->getType()); // A ^ ~A = ~A ^ A = -1 - if (match(Op0, m_Not(m_Specific(Op1))) || - match(Op1, m_Not(m_Specific(Op0)))) + if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) return Constant::getAllOnesValue(Op0->getType()); auto foldAndOrNot = [](Value *X, Value *Y) -> Value * { @@ -2532,8 +2530,8 @@ return V; // Try some generic simplifications for associative operations. - if (Value *V = SimplifyAssociativeBinOp(Instruction::Xor, Op0, Op1, Q, - MaxRecurse)) + if (Value *V = + simplifyAssociativeBinOp(Instruction::Xor, Op0, Op1, Q, MaxRecurse)) return V; // Threading Xor over selects and phi nodes is pointless, so don't bother. @@ -2548,19 +2546,18 @@ return nullptr; } -Value *llvm::SimplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { - return ::SimplifyXorInst(Op0, Op1, Q, RecursionLimit); +Value *llvm::simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { + return ::simplifyXorInst(Op0, Op1, Q, RecursionLimit); } - -static Type *GetCompareTy(Value *Op) { +static Type *getCompareTy(Value *Op) { return CmpInst::makeCmpResultType(Op->getType()); } /// Rummage around inside V looking for something equivalent to the comparison /// "LHS Pred RHS". Return such a value if found, otherwise return null. /// Helper function for analyzing max/min idioms. -static Value *ExtractEquivalentCondition(Value *V, CmpInst::Predicate Pred, +static Value *extractEquivalentCondition(Value *V, CmpInst::Predicate Pred, Value *LHS, Value *RHS) { SelectInst *SI = dyn_cast(V); if (!SI) @@ -2579,7 +2576,7 @@ /// Return true if the underlying object (storage) must be disjoint from /// storage returned by any noalias return call. -static bool IsAllocDisjoint(const Value *V) { +static bool isAllocDisjoint(const Value *V) { // For allocas, we consider only static ones (dynamic // allocas might be transformed into calls to malloc not simultaneously // live with the compared-to allocation). For globals, we exclude symbols @@ -2590,7 +2587,7 @@ if (const GlobalValue *GV = dyn_cast(V)) return (GV->hasLocalLinkage() || GV->hasHiddenVisibility() || GV->hasProtectedVisibility() || GV->hasGlobalUnnamedAddr()) && - !GV->isThreadLocal(); + !GV->isThreadLocal(); if (const Argument *A = dyn_cast(V)) return A->hasByValAttr(); return false; @@ -2599,7 +2596,7 @@ /// Return true if V1 and V2 are each the base of some distict storage region /// [V, object_size(V)] which do not overlap. Note that zero sized regions /// *are* possible, and that zero sized regions do not overlap with any other. -static bool HaveNonOverlappingStorage(const Value *V1, const Value *V2) { +static bool haveNonOverlappingStorage(const Value *V1, const Value *V2) { // Global variables always exist, so they always exist during the lifetime // of each other and all allocas. Global variables themselves usually have // non-overlapping storage, but since their addresses are constants, the @@ -2637,8 +2634,8 @@ if (isByValArg(V2)) return isa(V1) || isa(V1) || isByValArg(V1); - return isa(V1) && - (isa(V2) || isa(V2)); + return isa(V1) && + (isa(V2) || isa(V2)); } // A significant optimization not implemented here is assuming that alloca @@ -2669,9 +2666,8 @@ // If the C and C++ standards are ever made sufficiently restrictive in this // area, it may be possible to update LLVM's semantics accordingly and reinstate // this optimization. -static Constant * -computePointerICmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, - const SimplifyQuery &Q) { +static Constant *computePointerICmp(CmpInst::Predicate Pred, Value *LHS, + Value *RHS, const SimplifyQuery &Q) { const DataLayout &DL = Q.DL; const TargetLibraryInfo *TLI = Q.TLI; const DominatorTree *DT = Q.DT; @@ -2686,8 +2682,7 @@ if (isa(RHS) && ICmpInst::isEquality(Pred) && llvm::isKnownNonZero(LHS, DL, 0, nullptr, nullptr, nullptr, IIQ.UseInstrInfo)) - return ConstantInt::get(GetCompareTy(LHS), - !CmpInst::isTrueWhenEqual(Pred)); + return ConstantInt::get(getCompareTy(LHS), !CmpInst::isTrueWhenEqual(Pred)); // We can only fold certain predicates on pointer comparisons. switch (Pred) { @@ -2727,8 +2722,8 @@ // If LHS and RHS are related via constant offsets to the same base // value, we can replace it with an icmp which just compares the offsets. if (LHS == RHS) - return ConstantInt::get( - GetCompareTy(LHS), ICmpInst::compare(LHSOffset, RHSOffset, Pred)); + return ConstantInt::get(getCompareTy(LHS), + ICmpInst::compare(LHSOffset, RHSOffset, Pred)); // Various optimizations for (in)equality comparisons. if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_NE) { @@ -2737,7 +2732,7 @@ // within the bounds of their allocations (and not one-past-the-end! // so we can't use inbounds!), and their allocations aren't the same, // the pointers are not equal. - if (HaveNonOverlappingStorage(LHS, RHS)) { + if (haveNonOverlappingStorage(LHS, RHS)) { uint64_t LHSSize, RHSSize; ObjectSizeOpts Opts; Opts.EvalMode = ObjectSizeOpts::Mode::Min; @@ -2753,7 +2748,7 @@ getObjectSize(RHS, RHSSize, DL, TLI, Opts) && !LHSOffset.isNegative() && !RHSOffset.isNegative() && LHSOffset.ult(LHSSize) && RHSOffset.ult(RHSSize)) { - return ConstantInt::get(GetCompareTy(LHS), + return ConstantInt::get(getCompareTy(LHS), !CmpInst::isTrueWhenEqual(Pred)); } } @@ -2776,13 +2771,13 @@ // noalias calls. We assume that indexing from such disjoint storage // into the heap is undefined, and thus offsets can be safely ignored. auto IsAllocDisjoint = [](ArrayRef Objects) { - return all_of(Objects, ::IsAllocDisjoint); + return all_of(Objects, ::isAllocDisjoint); }; if ((IsNAC(LHSUObjs) && IsAllocDisjoint(RHSUObjs)) || (IsNAC(RHSUObjs) && IsAllocDisjoint(LHSUObjs))) - return ConstantInt::get(GetCompareTy(LHS), - !CmpInst::isTrueWhenEqual(Pred)); + return ConstantInt::get(getCompareTy(LHS), + !CmpInst::isTrueWhenEqual(Pred)); // Fold comparisons for non-escaping pointer even if the allocation call // cannot be elided. We cannot fold malloc comparison to null. Also, the @@ -2799,7 +2794,7 @@ // FIXME: We should also fold the compare when the pointer escapes, but the // compare dominates the pointer escape if (MI && !PointerMayBeCaptured(MI, true, true)) - return ConstantInt::get(GetCompareTy(LHS), + return ConstantInt::get(getCompareTy(LHS), CmpInst::isFalseWhenEqual(Pred)); } @@ -2810,7 +2805,7 @@ /// Fold an icmp when its operands have i1 scalar type. static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const SimplifyQuery &Q) { - Type *ITy = GetCompareTy(LHS); // The return type. + Type *ITy = getCompareTy(LHS); // The return type. Type *OpTy = LHS->getType(); // The operand type. if (!OpTy->isIntOrIntVectorTy(1)) return nullptr; @@ -2848,7 +2843,8 @@ case CmpInst::ICMP_SLE: // X <=s 0 -> true return getTrue(ITy); - default: break; + default: + break; } } else if (match(RHS, m_One())) { switch (Pred) { @@ -2872,7 +2868,8 @@ case CmpInst::ICMP_SGE: // X >=s -1 -> true return getTrue(ITy); - default: break; + default: + break; } } @@ -2909,7 +2906,7 @@ if (!match(RHS, m_Zero())) return nullptr; - Type *ITy = GetCompareTy(LHS); // The return type. + Type *ITy = getCompareTy(LHS); // The return type. switch (Pred) { default: llvm_unreachable("Unknown ICmp predicate!"); @@ -2968,7 +2965,7 @@ static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const InstrInfoQuery &IIQ) { - Type *ITy = GetCompareTy(RHS); // The return type. + Type *ITy = getCompareTy(RHS); // The return type. Value *X; // Sign-bit checks can be optimized to true/false after unsigned @@ -3015,10 +3012,11 @@ return nullptr; } -static Value *simplifyICmpWithBinOpOnLHS( - CmpInst::Predicate Pred, BinaryOperator *LBO, Value *RHS, - const SimplifyQuery &Q, unsigned MaxRecurse) { - Type *ITy = GetCompareTy(RHS); // The return type. +static Value *simplifyICmpWithBinOpOnLHS(CmpInst::Predicate Pred, + BinaryOperator *LBO, Value *RHS, + const SimplifyQuery &Q, + unsigned MaxRecurse) { + Type *ITy = getCompareTy(RHS); // The return type. Value *Y = nullptr; // icmp pred (or X, Y), X @@ -3153,7 +3151,6 @@ return nullptr; } - // If only one of the icmp's operands has NSW flags, try to prove that: // // icmp slt (x + C1), (x +nsw C2) @@ -3188,7 +3185,6 @@ (C2->slt(*C1) && C1->isNonPositive()); } - /// TODO: A large part of this logic is duplicated in InstCombine's /// foldICmpBinOp(). We should be able to share that and avoid the code /// duplication. @@ -3225,7 +3221,7 @@ // icmp (X+Y), X -> icmp Y, 0 for equalities or if there is no overflow. if ((A == RHS || B == RHS) && NoLHSWrapProblem) - if (Value *V = SimplifyICmpInst(Pred, A == RHS ? B : A, + if (Value *V = simplifyICmpInst(Pred, A == RHS ? B : A, Constant::getNullValue(RHS->getType()), Q, MaxRecurse - 1)) return V; @@ -3233,7 +3229,7 @@ // icmp X, (X+Y) -> icmp 0, Y for equalities or if there is no overflow. if ((C == LHS || D == LHS) && NoRHSWrapProblem) if (Value *V = - SimplifyICmpInst(Pred, Constant::getNullValue(LHS->getType()), + simplifyICmpInst(Pred, Constant::getNullValue(LHS->getType()), C == LHS ? D : C, Q, MaxRecurse - 1)) return V; @@ -3261,7 +3257,7 @@ Y = A; Z = C; } - if (Value *V = SimplifyICmpInst(Pred, Y, Z, Q, MaxRecurse - 1)) + if (Value *V = simplifyICmpInst(Pred, Y, Z, Q, MaxRecurse - 1)) return V; } } @@ -3281,15 +3277,15 @@ if (match(RHS, m_APInt(C))) { if (C->isStrictlyPositive()) { if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_NE) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(getCompareTy(RHS)); if (Pred == ICmpInst::ICMP_SGE || Pred == ICmpInst::ICMP_EQ) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(getCompareTy(RHS)); } if (C->isNonNegative()) { if (Pred == ICmpInst::ICMP_SLE) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(getCompareTy(RHS)); if (Pred == ICmpInst::ICMP_SGT) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(getCompareTy(RHS)); } } } @@ -3312,9 +3308,9 @@ Q.IIQ.hasNoUnsignedWrap(cast(LBO)) || match(LHS, m_Shl(m_One(), m_Value())) || !C->isZero()) { if (Pred == ICmpInst::ICMP_EQ) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(getCompareTy(RHS)); if (Pred == ICmpInst::ICMP_NE) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(getCompareTy(RHS)); } } @@ -3323,9 +3319,9 @@ // (1 << X) <=u 0x8000 --> true if (match(LHS, m_Shl(m_One(), m_Value())) && match(RHS, m_SignMask())) { if (Pred == ICmpInst::ICMP_UGT) - return ConstantInt::getFalse(GetCompareTy(RHS)); + return ConstantInt::getFalse(getCompareTy(RHS)); if (Pred == ICmpInst::ICMP_ULE) - return ConstantInt::getTrue(GetCompareTy(RHS)); + return ConstantInt::getTrue(getCompareTy(RHS)); } if (MaxRecurse && LBO && RBO && LBO->getOpcode() == RBO->getOpcode() && @@ -3338,22 +3334,22 @@ if (ICmpInst::isSigned(Pred) || !Q.IIQ.isExact(LBO) || !Q.IIQ.isExact(RBO)) break; - if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0), + if (Value *V = simplifyICmpInst(Pred, LBO->getOperand(0), RBO->getOperand(0), Q, MaxRecurse - 1)) - return V; + return V; break; case Instruction::SDiv: if (!ICmpInst::isEquality(Pred) || !Q.IIQ.isExact(LBO) || !Q.IIQ.isExact(RBO)) break; - if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0), + if (Value *V = simplifyICmpInst(Pred, LBO->getOperand(0), RBO->getOperand(0), Q, MaxRecurse - 1)) return V; break; case Instruction::AShr: if (!Q.IIQ.isExact(LBO) || !Q.IIQ.isExact(RBO)) break; - if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0), + if (Value *V = simplifyICmpInst(Pred, LBO->getOperand(0), RBO->getOperand(0), Q, MaxRecurse - 1)) return V; break; @@ -3364,7 +3360,7 @@ break; if (!NSW && ICmpInst::isSigned(Pred)) break; - if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0), + if (Value *V = simplifyICmpInst(Pred, LBO->getOperand(0), RBO->getOperand(0), Q, MaxRecurse - 1)) return V; break; @@ -3374,12 +3370,12 @@ return nullptr; } -/// Simplify integer comparisons where at least one operand of the compare +/// simplify integer comparisons where at least one operand of the compare /// matches an integer min/max idiom. static Value *simplifyICmpWithMinMax(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { - Type *ITy = GetCompareTy(LHS); // The return type. + Type *ITy = getCompareTy(LHS); // The return type. Value *A, *B; CmpInst::Predicate P = CmpInst::BAD_ICMP_PREDICATE; CmpInst::Predicate EqP; // Chosen so that "A == max/min(A,B)" iff "A EqP B". @@ -3424,13 +3420,13 @@ case CmpInst::ICMP_SLE: // Equivalent to "A EqP B". This may be the same as the condition tested // in the max/min; if so, we can just return that. - if (Value *V = ExtractEquivalentCondition(LHS, EqP, A, B)) + if (Value *V = extractEquivalentCondition(LHS, EqP, A, B)) return V; - if (Value *V = ExtractEquivalentCondition(RHS, EqP, A, B)) + if (Value *V = extractEquivalentCondition(RHS, EqP, A, B)) return V; // Otherwise, see if "A EqP B" simplifies. if (MaxRecurse) - if (Value *V = SimplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1)) + if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1)) return V; break; case CmpInst::ICMP_NE: @@ -3438,13 +3434,13 @@ CmpInst::Predicate InvEqP = CmpInst::getInversePredicate(EqP); // Equivalent to "A InvEqP B". This may be the same as the condition // tested in the max/min; if so, we can just return that. - if (Value *V = ExtractEquivalentCondition(LHS, InvEqP, A, B)) + if (Value *V = extractEquivalentCondition(LHS, InvEqP, A, B)) return V; - if (Value *V = ExtractEquivalentCondition(RHS, InvEqP, A, B)) + if (Value *V = extractEquivalentCondition(RHS, InvEqP, A, B)) return V; // Otherwise, see if "A InvEqP B" simplifies. if (MaxRecurse) - if (Value *V = SimplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1)) + if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1)) return V; break; } @@ -3498,13 +3494,13 @@ case CmpInst::ICMP_ULE: // Equivalent to "A EqP B". This may be the same as the condition tested // in the max/min; if so, we can just return that. - if (Value *V = ExtractEquivalentCondition(LHS, EqP, A, B)) + if (Value *V = extractEquivalentCondition(LHS, EqP, A, B)) return V; - if (Value *V = ExtractEquivalentCondition(RHS, EqP, A, B)) + if (Value *V = extractEquivalentCondition(RHS, EqP, A, B)) return V; // Otherwise, see if "A EqP B" simplifies. if (MaxRecurse) - if (Value *V = SimplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1)) + if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1)) return V; break; case CmpInst::ICMP_NE: @@ -3512,13 +3508,13 @@ CmpInst::Predicate InvEqP = CmpInst::getInversePredicate(EqP); // Equivalent to "A InvEqP B". This may be the same as the condition // tested in the max/min; if so, we can just return that. - if (Value *V = ExtractEquivalentCondition(LHS, InvEqP, A, B)) + if (Value *V = extractEquivalentCondition(LHS, InvEqP, A, B)) return V; - if (Value *V = ExtractEquivalentCondition(RHS, InvEqP, A, B)) + if (Value *V = extractEquivalentCondition(RHS, InvEqP, A, B)) return V; // Otherwise, see if "A InvEqP B" simplifies. if (MaxRecurse) - if (Value *V = SimplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1)) + if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1)) return V; break; } @@ -3574,11 +3570,10 @@ continue; CallInst *Assume = cast(AssumeVH); - if (Optional Imp = - isImpliedCondition(Assume->getArgOperand(0), Predicate, LHS, RHS, - Q.DL)) + if (Optional Imp = isImpliedCondition(Assume->getArgOperand(0), + Predicate, LHS, RHS, Q.DL)) if (isValidAssumeForContext(Assume, Q.CxtI, Q.DT)) - return ConstantInt::get(GetCompareTy(LHS), *Imp); + return ConstantInt::get(getCompareTy(LHS), *Imp); } } @@ -3587,7 +3582,7 @@ /// Given operands for an ICmpInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, +static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; assert(CmpInst::isIntPredicate(Pred) && "Not an integer compare!"); @@ -3602,7 +3597,7 @@ } assert(!isa(LHS) && "Unexpected icmp undef,%X"); - Type *ITy = GetCompareTy(LHS); // The return type. + Type *ITy = getCompareTy(LHS); // The return type. // icmp poison, X -> poison if (isa(RHS)) @@ -3664,15 +3659,15 @@ Q.DL.getTypeSizeInBits(SrcTy) == DstTy->getPrimitiveSizeInBits()) { if (Constant *RHSC = dyn_cast(RHS)) { // Transfer the cast to the constant. - if (Value *V = SimplifyICmpInst(Pred, SrcOp, + if (Value *V = simplifyICmpInst(Pred, SrcOp, ConstantExpr::getIntToPtr(RHSC, SrcTy), - Q, MaxRecurse-1)) + Q, MaxRecurse - 1)) return V; } else if (PtrToIntInst *RI = dyn_cast(RHS)) { if (RI->getOperand(0)->getType() == SrcTy) // Compare without the cast. - if (Value *V = SimplifyICmpInst(Pred, SrcOp, RI->getOperand(0), - Q, MaxRecurse-1)) + if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q, + MaxRecurse - 1)) return V; } } @@ -3683,9 +3678,9 @@ if (ZExtInst *RI = dyn_cast(RHS)) { if (MaxRecurse && SrcTy == RI->getOperand(0)->getType()) // Compare X and Y. Note that signed predicates become unsigned. - if (Value *V = SimplifyICmpInst(ICmpInst::getUnsignedPredicate(Pred), - SrcOp, RI->getOperand(0), Q, - MaxRecurse-1)) + if (Value *V = + simplifyICmpInst(ICmpInst::getUnsignedPredicate(Pred), SrcOp, + RI->getOperand(0), Q, MaxRecurse - 1)) return V; } // Fold (zext X) ule (sext X), (zext X) sge (sext X) to true. @@ -3708,15 +3703,16 @@ // If the re-extended constant didn't change then this is effectively // also a case of comparing two zero-extended values. if (RExt == CI && MaxRecurse) - if (Value *V = SimplifyICmpInst(ICmpInst::getUnsignedPredicate(Pred), - SrcOp, Trunc, Q, MaxRecurse-1)) + if (Value *V = simplifyICmpInst(ICmpInst::getUnsignedPredicate(Pred), + SrcOp, Trunc, Q, MaxRecurse - 1)) return V; // Otherwise the upper bits of LHS are zero while RHS has a non-zero bit // there. Use this to work out the result of the comparison. if (RExt != CI) { switch (Pred) { - default: llvm_unreachable("Unknown ICmp predicate!"); + default: + llvm_unreachable("Unknown ICmp predicate!"); // LHS getValue().isNegative() ? - ConstantInt::getTrue(CI->getContext()) : - ConstantInt::getFalse(CI->getContext()); + return CI->getValue().isNegative() + ? ConstantInt::getTrue(CI->getContext()) + : ConstantInt::getFalse(CI->getContext()); case ICmpInst::ICMP_SLT: case ICmpInst::ICMP_SLE: - return CI->getValue().isNegative() ? - ConstantInt::getFalse(CI->getContext()) : - ConstantInt::getTrue(CI->getContext()); + return CI->getValue().isNegative() + ? ConstantInt::getFalse(CI->getContext()) + : ConstantInt::getTrue(CI->getContext()); } } } @@ -3752,8 +3748,8 @@ if (SExtInst *RI = dyn_cast(RHS)) { if (MaxRecurse && SrcTy == RI->getOperand(0)->getType()) // Compare X and Y. Note that the predicate does not change. - if (Value *V = SimplifyICmpInst(Pred, SrcOp, RI->getOperand(0), - Q, MaxRecurse-1)) + if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q, + MaxRecurse - 1)) return V; } // Fold (sext X) uge (zext X), (sext X) sle (zext X) to true. @@ -3776,14 +3772,16 @@ // If the re-extended constant didn't change then this is effectively // also a case of comparing two sign-extended values. if (RExt == CI && MaxRecurse) - if (Value *V = SimplifyICmpInst(Pred, SrcOp, Trunc, Q, MaxRecurse-1)) + if (Value *V = + simplifyICmpInst(Pred, SrcOp, Trunc, Q, MaxRecurse - 1)) return V; // Otherwise the upper bits of LHS are all equal, while RHS has varying // bits there. Use this to work out the result of the comparison. if (RExt != CI) { switch (Pred) { - default: llvm_unreachable("Unknown ICmp predicate!"); + default: + llvm_unreachable("Unknown ICmp predicate!"); case ICmpInst::ICMP_EQ: return ConstantInt::getFalse(CI->getContext()); case ICmpInst::ICMP_NE: @@ -3793,14 +3791,14 @@ // LHS >s RHS. case ICmpInst::ICMP_SGT: case ICmpInst::ICMP_SGE: - return CI->getValue().isNegative() ? - ConstantInt::getTrue(CI->getContext()) : - ConstantInt::getFalse(CI->getContext()); + return CI->getValue().isNegative() + ? ConstantInt::getTrue(CI->getContext()) + : ConstantInt::getFalse(CI->getContext()); case ICmpInst::ICMP_SLT: case ICmpInst::ICMP_SLE: - return CI->getValue().isNegative() ? - ConstantInt::getFalse(CI->getContext()) : - ConstantInt::getTrue(CI->getContext()); + return CI->getValue().isNegative() + ? ConstantInt::getFalse(CI->getContext()) + : ConstantInt::getTrue(CI->getContext()); // If LHS is non-negative then LHS u RHS. @@ -3808,18 +3806,18 @@ case ICmpInst::ICMP_UGE: // Comparison is true iff the LHS =s 0. if (MaxRecurse) - if (Value *V = SimplifyICmpInst(ICmpInst::ICMP_SGE, SrcOp, - Constant::getNullValue(SrcTy), - Q, MaxRecurse-1)) + if (Value *V = simplifyICmpInst(ICmpInst::ICMP_SGE, SrcOp, + Constant::getNullValue(SrcTy), Q, + MaxRecurse - 1)) return V; break; } @@ -3863,26 +3861,26 @@ // If the comparison is with the result of a select instruction, check whether // comparing with either branch of the select always yields the same value. if (isa(LHS) || isa(RHS)) - if (Value *V = ThreadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse)) return V; // If the comparison is with the result of a phi instruction, check whether // doing the compare with each incoming phi value yields a common result. if (isa(LHS) || isa(RHS)) - if (Value *V = ThreadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) return V; return nullptr; } -Value *llvm::SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *llvm::simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q) { - return ::SimplifyICmpInst(Predicate, LHS, RHS, Q, RecursionLimit); + return ::simplifyICmpInst(Predicate, LHS, RHS, Q, RecursionLimit); } /// Given operands for an FCmpInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q, unsigned MaxRecurse) { CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate; @@ -3898,7 +3896,7 @@ } // Fold trivial predicates. - Type *RetTy = GetCompareTy(LHS); + Type *RetTy = getCompareTy(LHS); if (Pred == FCmpInst::FCMP_FALSE) return getFalse(RetTy); if (Pred == FCmpInst::FCMP_TRUE) @@ -4018,23 +4016,29 @@ // The ordered relationship and minnum/maxnum guarantee that we do not // have NaN constants, so ordered/unordered preds are handled the same. switch (Pred) { - case FCmpInst::FCMP_OEQ: case FCmpInst::FCMP_UEQ: + case FCmpInst::FCMP_OEQ: + case FCmpInst::FCMP_UEQ: // minnum(X, LesserC) == C --> false // maxnum(X, GreaterC) == C --> false return getFalse(RetTy); - case FCmpInst::FCMP_ONE: case FCmpInst::FCMP_UNE: + case FCmpInst::FCMP_ONE: + case FCmpInst::FCMP_UNE: // minnum(X, LesserC) != C --> true // maxnum(X, GreaterC) != C --> true return getTrue(RetTy); - case FCmpInst::FCMP_OGE: case FCmpInst::FCMP_UGE: - case FCmpInst::FCMP_OGT: case FCmpInst::FCMP_UGT: + case FCmpInst::FCMP_OGE: + case FCmpInst::FCMP_UGE: + case FCmpInst::FCMP_OGT: + case FCmpInst::FCMP_UGT: // minnum(X, LesserC) >= C --> false // minnum(X, LesserC) > C --> false // maxnum(X, GreaterC) >= C --> true // maxnum(X, GreaterC) > C --> true return ConstantInt::get(RetTy, IsMaxNum); - case FCmpInst::FCMP_OLE: case FCmpInst::FCMP_ULE: - case FCmpInst::FCMP_OLT: case FCmpInst::FCMP_ULT: + case FCmpInst::FCMP_OLE: + case FCmpInst::FCMP_ULE: + case FCmpInst::FCMP_OLT: + case FCmpInst::FCMP_ULT: // minnum(X, LesserC) <= C --> true // minnum(X, LesserC) < C --> true // maxnum(X, GreaterC) <= C --> false @@ -4072,21 +4076,21 @@ // If the comparison is with the result of a select instruction, check whether // comparing with either branch of the select always yields the same value. if (isa(LHS) || isa(RHS)) - if (Value *V = ThreadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse)) return V; // If the comparison is with the result of a phi instruction, check whether // doing the compare with each incoming phi value yields a common result. if (isa(LHS) || isa(RHS)) - if (Value *V = ThreadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) + if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse)) return V; return nullptr; } -Value *llvm::SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *llvm::simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q) { - return ::SimplifyFCmpInst(Predicate, LHS, RHS, FMF, Q, RecursionLimit); + return ::simplifyFCmpInst(Predicate, LHS, RHS, FMF, Q, RecursionLimit); } static Value *simplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp, @@ -4153,22 +4157,21 @@ }; if (auto *B = dyn_cast(I)) - return PreventSelfSimplify(SimplifyBinOp(B->getOpcode(), NewOps[0], + return PreventSelfSimplify(simplifyBinOp(B->getOpcode(), NewOps[0], NewOps[1], Q, MaxRecurse - 1)); if (CmpInst *C = dyn_cast(I)) - return PreventSelfSimplify(SimplifyCmpInst(C->getPredicate(), NewOps[0], + return PreventSelfSimplify(simplifyCmpInst(C->getPredicate(), NewOps[0], NewOps[1], Q, MaxRecurse - 1)); if (auto *GEP = dyn_cast(I)) - return PreventSelfSimplify(SimplifyGEPInst( + return PreventSelfSimplify(simplifyGEPInst( GEP->getSourceElementType(), NewOps[0], makeArrayRef(NewOps).slice(1), GEP->isInBounds(), Q, MaxRecurse - 1)); if (isa(I)) - return PreventSelfSimplify( - SimplifySelectInst(NewOps[0], NewOps[1], NewOps[2], Q, - MaxRecurse - 1)); + return PreventSelfSimplify(simplifySelectInst( + NewOps[0], NewOps[1], NewOps[2], Q, MaxRecurse - 1)); // TODO: We could hand off more cases to instsimplify here. } @@ -4264,7 +4267,8 @@ /// Try to simplify a select instruction when its condition operand is an /// integer comparison. static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal, - Value *FalseVal, const SimplifyQuery &Q, + Value *FalseVal, + const SimplifyQuery &Q, unsigned MaxRecurse) { ICmpInst::Predicate Pred; Value *CmpLHS, *CmpRHS; @@ -4284,7 +4288,8 @@ Value *X, *Y; SelectPatternFlavor SPF = matchDecomposedSelectPattern(cast(CondVal), TrueVal, FalseVal, - X, Y).Flavor; + X, Y) + .Flavor; if (SelectPatternResult::isMinOrMax(SPF) && Pred == getMinMaxPred(SPF)) { APInt LimitC = getMinMaxLimit(getInverseMinMaxFlavor(SPF), X->getType()->getScalarSizeInBits()); @@ -4336,8 +4341,8 @@ } // Check for other compares that behave like bit test. - if (Value *V = simplifySelectWithFakeICmpEq(CmpLHS, CmpRHS, Pred, - TrueVal, FalseVal)) + if (Value *V = + simplifySelectWithFakeICmpEq(CmpLHS, CmpRHS, Pred, TrueVal, FalseVal)) return V; // If we have a scalar equality comparison, then we know the value in one of @@ -4347,18 +4352,18 @@ // because each element of a vector select is chosen independently. if (Pred == ICmpInst::ICMP_EQ && !CondVal->getType()->isVectorTy()) { if (simplifyWithOpReplaced(FalseVal, CmpLHS, CmpRHS, Q, - /* AllowRefinement */ false, MaxRecurse) == - TrueVal || + /* AllowRefinement */ false, + MaxRecurse) == TrueVal || simplifyWithOpReplaced(FalseVal, CmpRHS, CmpLHS, Q, - /* AllowRefinement */ false, MaxRecurse) == - TrueVal) + /* AllowRefinement */ false, + MaxRecurse) == TrueVal) return FalseVal; if (simplifyWithOpReplaced(TrueVal, CmpLHS, CmpRHS, Q, - /* AllowRefinement */ true, MaxRecurse) == - FalseVal || + /* AllowRefinement */ true, + MaxRecurse) == FalseVal || simplifyWithOpReplaced(TrueVal, CmpRHS, CmpLHS, Q, - /* AllowRefinement */ true, MaxRecurse) == - FalseVal) + /* AllowRefinement */ true, + MaxRecurse) == FalseVal) return FalseVal; } @@ -4377,11 +4382,11 @@ // This transform is safe if we do not have (do not care about) -0.0 or if // at least one operand is known to not be -0.0. Otherwise, the select can // change the sign of a zero operand. - bool HasNoSignedZeros = Q.CxtI && isa(Q.CxtI) && - Q.CxtI->hasNoSignedZeros(); + bool HasNoSignedZeros = + Q.CxtI && isa(Q.CxtI) && Q.CxtI->hasNoSignedZeros(); const APFloat *C; if (HasNoSignedZeros || (match(T, m_APFloat(C)) && C->isNonZero()) || - (match(F, m_APFloat(C)) && C->isNonZero())) { + (match(F, m_APFloat(C)) && C->isNonZero())) { // (T == F) ? T : F --> F // (F == T) ? T : F --> F if (Pred == FCmpInst::FCMP_OEQ) @@ -4398,7 +4403,7 @@ /// Given operands for a SelectInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, +static Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q, unsigned MaxRecurse) { if (auto *CondC = dyn_cast(Cond)) { if (auto *TrueC = dyn_cast(TrueVal)) @@ -4514,14 +4519,14 @@ return nullptr; } -Value *llvm::SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, +Value *llvm::simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const SimplifyQuery &Q) { - return ::SimplifySelectInst(Cond, TrueVal, FalseVal, Q, RecursionLimit); + return ::simplifySelectInst(Cond, TrueVal, FalseVal, Q, RecursionLimit); } /// Given operands for an GetElementPtrInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyGEPInst(Type *SrcTy, Value *Ptr, +static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef Indices, bool InBounds, const SimplifyQuery &Q, unsigned) { // The type of the GEP pointer operand. @@ -4659,16 +4664,16 @@ return ConstantFoldConstant(CE, Q.DL); } -Value *llvm::SimplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef Indices, +Value *llvm::simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef Indices, bool InBounds, const SimplifyQuery &Q) { - return ::SimplifyGEPInst(SrcTy, Ptr, Indices, InBounds, Q, RecursionLimit); + return ::simplifyGEPInst(SrcTy, Ptr, Indices, InBounds, Q, RecursionLimit); } /// Given operands for an InsertValueInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyInsertValueInst(Value *Agg, Value *Val, - ArrayRef Idxs, const SimplifyQuery &Q, - unsigned) { +static Value *simplifyInsertValueInst(Value *Agg, Value *Val, + ArrayRef Idxs, + const SimplifyQuery &Q, unsigned) { if (Constant *CAgg = dyn_cast(Agg)) if (Constant *CVal = dyn_cast(Val)) return ConstantFoldInsertValueInstruction(CAgg, CVal, Idxs); @@ -4693,13 +4698,13 @@ return nullptr; } -Value *llvm::SimplifyInsertValueInst(Value *Agg, Value *Val, +Value *llvm::simplifyInsertValueInst(Value *Agg, Value *Val, ArrayRef Idxs, const SimplifyQuery &Q) { - return ::SimplifyInsertValueInst(Agg, Val, Idxs, Q, RecursionLimit); + return ::simplifyInsertValueInst(Agg, Val, Idxs, Q, RecursionLimit); } -Value *llvm::SimplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx, +Value *llvm::simplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx, const SimplifyQuery &Q) { // Try to constant fold. auto *VecC = dyn_cast(Vec); @@ -4736,7 +4741,7 @@ /// Given operands for an ExtractValueInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyExtractValueInst(Value *Agg, ArrayRef Idxs, +static Value *simplifyExtractValueInst(Value *Agg, ArrayRef Idxs, const SimplifyQuery &, unsigned) { if (auto *CAgg = dyn_cast(Agg)) return ConstantFoldExtractValueInstruction(CAgg, Idxs); @@ -4759,14 +4764,14 @@ return nullptr; } -Value *llvm::SimplifyExtractValueInst(Value *Agg, ArrayRef Idxs, +Value *llvm::simplifyExtractValueInst(Value *Agg, ArrayRef Idxs, const SimplifyQuery &Q) { - return ::SimplifyExtractValueInst(Agg, Idxs, Q, RecursionLimit); + return ::simplifyExtractValueInst(Agg, Idxs, Q, RecursionLimit); } /// Given operands for an ExtractElementInst, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyExtractElementInst(Value *Vec, Value *Idx, +static Value *simplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQuery &Q, unsigned) { auto *VecVTy = cast(Vec->getType()); if (auto *CVec = dyn_cast(Vec)) { @@ -4803,13 +4808,13 @@ return nullptr; } -Value *llvm::SimplifyExtractElementInst(Value *Vec, Value *Idx, +Value *llvm::simplifyExtractElementInst(Value *Vec, Value *Idx, const SimplifyQuery &Q) { - return ::SimplifyExtractElementInst(Vec, Idx, Q, RecursionLimit); + return ::simplifyExtractElementInst(Vec, Idx, Q, RecursionLimit); } /// See if we can fold the given phi. If not, returns null. -static Value *SimplifyPHINode(PHINode *PN, ArrayRef IncomingValues, +static Value *simplifyPHINode(PHINode *PN, ArrayRef IncomingValues, const SimplifyQuery &Q) { // WARNING: no matter how worthwhile it may seem, we can not perform PHI CSE // here, because the PHI we may succeed simplifying to was not @@ -4821,14 +4826,15 @@ bool HasUndefInput = false; for (Value *Incoming : IncomingValues) { // If the incoming value is the phi node itself, it can safely be skipped. - if (Incoming == PN) continue; + if (Incoming == PN) + continue; if (Q.isUndefValue(Incoming)) { // Remember that we saw an undef value, but otherwise ignore them. HasUndefInput = true; continue; } if (CommonValue && Incoming != CommonValue) - return nullptr; // Not the same, bail out. + return nullptr; // Not the same, bail out. CommonValue = Incoming; } @@ -4853,8 +4859,8 @@ return CommonValue; } -static Value *SimplifyCastInst(unsigned CastOpc, Value *Op, - Type *Ty, const SimplifyQuery &Q, unsigned MaxRecurse) { +static Value *simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, + const SimplifyQuery &Q, unsigned MaxRecurse) { if (auto *C = dyn_cast(Op)) return ConstantFoldCastOperand(CastOpc, C, Ty, Q.DL); @@ -4887,9 +4893,9 @@ return nullptr; } -Value *llvm::SimplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, +Value *llvm::simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q) { - return ::SimplifyCastInst(CastOpc, Op, Ty, Q, RecursionLimit); + return ::simplifyCastInst(CastOpc, Op, Ty, Q, RecursionLimit); } /// For the given destination element of a shuffle, peek through shuffles to @@ -4943,7 +4949,7 @@ return RootVec; } -static Value *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, +static Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef Mask, Type *RetTy, const SimplifyQuery &Q, unsigned MaxRecurse) { @@ -5059,14 +5065,14 @@ } /// Given operands for a ShuffleVectorInst, fold the result or return null. -Value *llvm::SimplifyShuffleVectorInst(Value *Op0, Value *Op1, +Value *llvm::simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef Mask, Type *RetTy, const SimplifyQuery &Q) { - return ::SimplifyShuffleVectorInst(Op0, Op1, Mask, RetTy, Q, RecursionLimit); + return ::simplifyShuffleVectorInst(Op0, Op1, Mask, RetTy, Q, RecursionLimit); } -static Constant *foldConstant(Instruction::UnaryOps Opcode, - Value *&Op, const SimplifyQuery &Q) { +static Constant *foldConstant(Instruction::UnaryOps Opcode, Value *&Op, + const SimplifyQuery &Q) { if (auto *C = dyn_cast(Op)) return ConstantFoldUnaryOpOperand(Opcode, C, Q.DL); return nullptr; @@ -5087,7 +5093,7 @@ return nullptr; } -Value *llvm::SimplifyFNegInst(Value *Op, FastMathFlags FMF, +Value *llvm::simplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q) { return ::simplifyFNegInst(Op, FMF, Q, RecursionLimit); } @@ -5141,7 +5147,7 @@ /// Given operands for an FAdd, see if we can fold the result. If not, this /// returns null. static Value * -SimplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, +simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned MaxRecurse, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven) { @@ -5203,7 +5209,7 @@ /// Given operands for an FSub, see if we can fold the result. If not, this /// returns null. static Value * -SimplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, +simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned MaxRecurse, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven) { @@ -5231,8 +5237,7 @@ // fsub -0.0, (fneg X) ==> X Value *X; if (canIgnoreSNaN(ExBehavior, FMF)) - if (match(Op0, m_NegZeroFP()) && - match(Op1, m_FNeg(m_Value(X)))) + if (match(Op0, m_NegZeroFP()) && match(Op1, m_FNeg(m_Value(X)))) return X; if (!isDefaultFPEnvironment(ExBehavior, Rounding)) @@ -5259,7 +5264,7 @@ return nullptr; } -static Value *SimplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, +static Value *simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned MaxRecurse, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { @@ -5299,7 +5304,7 @@ /// Given the operands for an FMul, see if we can fold the result static Value * -SimplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, +simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned MaxRecurse, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven) { @@ -5308,43 +5313,43 @@ return C; // Now apply simplifications that do not require rounding. - return SimplifyFMAFMul(Op0, Op1, FMF, Q, MaxRecurse, ExBehavior, Rounding); + return simplifyFMAFMul(Op0, Op1, FMF, Q, MaxRecurse, ExBehavior, Rounding); } -Value *llvm::SimplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFAddInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFAddInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } -Value *llvm::SimplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFSubInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFSubInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } -Value *llvm::SimplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFMulInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFMulInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } -Value *llvm::SimplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFMAFMul(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFMAFMul(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } static Value * -SimplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, +simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven) { @@ -5390,16 +5395,16 @@ return nullptr; } -Value *llvm::SimplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFDivInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFDivInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } static Value * -SimplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, +simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, unsigned, fp::ExceptionBehavior ExBehavior = fp::ebIgnore, RoundingMode Rounding = RoundingMode::NearestTiesToEven) { @@ -5428,11 +5433,11 @@ return nullptr; } -Value *llvm::SimplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, +Value *llvm::simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, const SimplifyQuery &Q, fp::ExceptionBehavior ExBehavior, RoundingMode Rounding) { - return ::SimplifyFRemInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, + return ::simplifyFRemInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, Rounding); } @@ -5454,8 +5459,8 @@ /// If not, this returns null. /// Try to use FastMathFlags when folding the result. static Value *simplifyFPUnOp(unsigned Opcode, Value *Op, - const FastMathFlags &FMF, - const SimplifyQuery &Q, unsigned MaxRecurse) { + const FastMathFlags &FMF, const SimplifyQuery &Q, + unsigned MaxRecurse) { switch (Opcode) { case Instruction::FNeg: return simplifyFNegInst(Op, FMF, Q, MaxRecurse); @@ -5464,56 +5469,56 @@ } } -Value *llvm::SimplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q) { +Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q) { return ::simplifyUnOp(Opcode, Op, Q, RecursionLimit); } -Value *llvm::SimplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF, +Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, FastMathFlags FMF, const SimplifyQuery &Q) { return ::simplifyFPUnOp(Opcode, Op, FMF, Q, RecursionLimit); } /// Given operands for a BinaryOperator, see if we can fold the result. /// If not, this returns null. -static Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, +static Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { switch (Opcode) { case Instruction::Add: - return SimplifyAddInst(LHS, RHS, false, false, Q, MaxRecurse); + return simplifyAddInst(LHS, RHS, false, false, Q, MaxRecurse); case Instruction::Sub: - return SimplifySubInst(LHS, RHS, false, false, Q, MaxRecurse); + return simplifySubInst(LHS, RHS, false, false, Q, MaxRecurse); case Instruction::Mul: - return SimplifyMulInst(LHS, RHS, Q, MaxRecurse); + return simplifyMulInst(LHS, RHS, Q, MaxRecurse); case Instruction::SDiv: - return SimplifySDivInst(LHS, RHS, Q, MaxRecurse); + return simplifySDivInst(LHS, RHS, Q, MaxRecurse); case Instruction::UDiv: - return SimplifyUDivInst(LHS, RHS, Q, MaxRecurse); + return simplifyUDivInst(LHS, RHS, Q, MaxRecurse); case Instruction::SRem: - return SimplifySRemInst(LHS, RHS, Q, MaxRecurse); + return simplifySRemInst(LHS, RHS, Q, MaxRecurse); case Instruction::URem: - return SimplifyURemInst(LHS, RHS, Q, MaxRecurse); + return simplifyURemInst(LHS, RHS, Q, MaxRecurse); case Instruction::Shl: - return SimplifyShlInst(LHS, RHS, false, false, Q, MaxRecurse); + return simplifyShlInst(LHS, RHS, false, false, Q, MaxRecurse); case Instruction::LShr: - return SimplifyLShrInst(LHS, RHS, false, Q, MaxRecurse); + return simplifyLShrInst(LHS, RHS, false, Q, MaxRecurse); case Instruction::AShr: - return SimplifyAShrInst(LHS, RHS, false, Q, MaxRecurse); + return simplifyAShrInst(LHS, RHS, false, Q, MaxRecurse); case Instruction::And: - return SimplifyAndInst(LHS, RHS, Q, MaxRecurse); + return simplifyAndInst(LHS, RHS, Q, MaxRecurse); case Instruction::Or: - return SimplifyOrInst(LHS, RHS, Q, MaxRecurse); + return simplifyOrInst(LHS, RHS, Q, MaxRecurse); case Instruction::Xor: - return SimplifyXorInst(LHS, RHS, Q, MaxRecurse); + return simplifyXorInst(LHS, RHS, Q, MaxRecurse); case Instruction::FAdd: - return SimplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); case Instruction::FSub: - return SimplifyFSubInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyFSubInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); case Instruction::FMul: - return SimplifyFMulInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyFMulInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); case Instruction::FDiv: - return SimplifyFDivInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyFDivInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); case Instruction::FRem: - return SimplifyFRemInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyFRemInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse); default: llvm_unreachable("Unexpected opcode"); } @@ -5522,49 +5527,50 @@ /// Given operands for a BinaryOperator, see if we can fold the result. /// If not, this returns null. /// Try to use FastMathFlags when folding the result. -static Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, +static Value *simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const FastMathFlags &FMF, const SimplifyQuery &Q, unsigned MaxRecurse) { switch (Opcode) { case Instruction::FAdd: - return SimplifyFAddInst(LHS, RHS, FMF, Q, MaxRecurse); + return simplifyFAddInst(LHS, RHS, FMF, Q, MaxRecurse); case Instruction::FSub: - return SimplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse); + return simplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse); case Instruction::FMul: - return SimplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse); + return simplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse); case Instruction::FDiv: - return SimplifyFDivInst(LHS, RHS, FMF, Q, MaxRecurse); + return simplifyFDivInst(LHS, RHS, FMF, Q, MaxRecurse); default: - return SimplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse); + return simplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse); } } -Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, +Value *llvm::simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, const SimplifyQuery &Q) { - return ::SimplifyBinOp(Opcode, LHS, RHS, Q, RecursionLimit); + return ::simplifyBinOp(Opcode, LHS, RHS, Q, RecursionLimit); } -Value *llvm::SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, +Value *llvm::simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q) { - return ::SimplifyBinOp(Opcode, LHS, RHS, FMF, Q, RecursionLimit); + return ::simplifyBinOp(Opcode, LHS, RHS, FMF, Q, RecursionLimit); } /// Given operands for a CmpInst, see if we can fold the result. -static Value *SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +static Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q, unsigned MaxRecurse) { if (CmpInst::isIntPredicate((CmpInst::Predicate)Predicate)) - return SimplifyICmpInst(Predicate, LHS, RHS, Q, MaxRecurse); - return SimplifyFCmpInst(Predicate, LHS, RHS, FastMathFlags(), Q, MaxRecurse); + return simplifyICmpInst(Predicate, LHS, RHS, Q, MaxRecurse); + return simplifyFCmpInst(Predicate, LHS, RHS, FastMathFlags(), Q, MaxRecurse); } -Value *llvm::SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, +Value *llvm::simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, const SimplifyQuery &Q) { - return ::SimplifyCmpInst(Predicate, LHS, RHS, Q, RecursionLimit); + return ::simplifyCmpInst(Predicate, LHS, RHS, Q, RecursionLimit); } -static bool IsIdempotent(Intrinsic::ID ID) { +static bool isIdempotent(Intrinsic::ID ID) { switch (ID) { - default: return false; + default: + return false; // Unary idempotent: f(f(x)) = f(x) case Intrinsic::fabs: @@ -5580,7 +5586,7 @@ } } -static Value *SimplifyRelativeLoad(Constant *Ptr, Constant *Offset, +static Value *simplifyRelativeLoad(Constant *Ptr, Constant *Offset, const DataLayout &DL) { GlobalValue *PtrSym; APInt PtrOffset; @@ -5640,7 +5646,7 @@ const SimplifyQuery &Q) { // Idempotent functions return the same result when called repeatedly. Intrinsic::ID IID = F->getIntrinsicID(); - if (IsIdempotent(IID)) + if (isIdempotent(IID)) if (auto *II = dyn_cast(Op0)) if (II->getIntrinsicID() == IID) return II; @@ -5648,15 +5654,18 @@ Value *X; switch (IID) { case Intrinsic::fabs: - if (SignBitMustBeZero(Op0, Q.TLI)) return Op0; + if (SignBitMustBeZero(Op0, Q.TLI)) + return Op0; break; case Intrinsic::bswap: // bswap(bswap(x)) -> x - if (match(Op0, m_BSwap(m_Value(X)))) return X; + if (match(Op0, m_BSwap(m_Value(X)))) + return X; break; case Intrinsic::bitreverse: // bitreverse(bitreverse(x)) -> x - if (match(Op0, m_BitReverse(m_Value(X)))) return X; + if (match(Op0, m_BitReverse(m_Value(X)))) + return X; break; case Intrinsic::ctpop: { // If everything but the lowest bit is zero, that bit is the pop-count. Ex: @@ -5670,30 +5679,34 @@ case Intrinsic::exp: // exp(log(x)) -> x if (Q.CxtI->hasAllowReassoc() && - match(Op0, m_Intrinsic(m_Value(X)))) return X; + match(Op0, m_Intrinsic(m_Value(X)))) + return X; break; case Intrinsic::exp2: // exp2(log2(x)) -> x if (Q.CxtI->hasAllowReassoc() && - match(Op0, m_Intrinsic(m_Value(X)))) return X; + match(Op0, m_Intrinsic(m_Value(X)))) + return X; break; case Intrinsic::log: // log(exp(x)) -> x if (Q.CxtI->hasAllowReassoc() && - match(Op0, m_Intrinsic(m_Value(X)))) return X; + match(Op0, m_Intrinsic(m_Value(X)))) + return X; break; case Intrinsic::log2: // log2(exp2(x)) -> x if (Q.CxtI->hasAllowReassoc() && (match(Op0, m_Intrinsic(m_Value(X))) || - match(Op0, m_Intrinsic(m_SpecificFP(2.0), - m_Value(X))))) return X; + match(Op0, + m_Intrinsic(m_SpecificFP(2.0), m_Value(X))))) + return X; break; case Intrinsic::log10: // log10(pow(10.0, x)) -> x if (Q.CxtI->hasAllowReassoc() && - match(Op0, m_Intrinsic(m_SpecificFP(10.0), - m_Value(X)))) return X; + match(Op0, m_Intrinsic(m_SpecificFP(10.0), m_Value(X)))) + return X; break; case Intrinsic::floor: case Intrinsic::trunc: @@ -5915,7 +5928,7 @@ case Intrinsic::load_relative: if (auto *C0 = dyn_cast(Op0)) if (auto *C1 = dyn_cast(Op1)) - return SimplifyRelativeLoad(C0, C1, Q.DL); + return simplifyRelativeLoad(C0, C1, Q.DL); break; case Intrinsic::powi: if (auto *Power = dyn_cast(Op1)) { @@ -5942,7 +5955,8 @@ case Intrinsic::maximum: case Intrinsic::minimum: { // If the arguments are the same, this is a no-op. - if (Op0 == Op1) return Op0; + if (Op0 == Op1) + return Op0; // Canonicalize constant operand as Op1. if (isa(Op0)) @@ -6163,35 +6177,35 @@ } case Intrinsic::experimental_constrained_fadd: { auto *FPI = cast(Call); - return SimplifyFAddInst(FPI->getArgOperand(0), FPI->getArgOperand(1), + return simplifyFAddInst(FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), Q, FPI->getExceptionBehavior().getValue(), FPI->getRoundingMode().getValue()); } case Intrinsic::experimental_constrained_fsub: { auto *FPI = cast(Call); - return SimplifyFSubInst(FPI->getArgOperand(0), FPI->getArgOperand(1), + return simplifyFSubInst(FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), Q, FPI->getExceptionBehavior().getValue(), FPI->getRoundingMode().getValue()); } case Intrinsic::experimental_constrained_fmul: { auto *FPI = cast(Call); - return SimplifyFMulInst(FPI->getArgOperand(0), FPI->getArgOperand(1), + return simplifyFMulInst(FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), Q, FPI->getExceptionBehavior().getValue(), FPI->getRoundingMode().getValue()); } case Intrinsic::experimental_constrained_fdiv: { auto *FPI = cast(Call); - return SimplifyFDivInst(FPI->getArgOperand(0), FPI->getArgOperand(1), + return simplifyFDivInst(FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), Q, FPI->getExceptionBehavior().getValue(), FPI->getRoundingMode().getValue()); } case Intrinsic::experimental_constrained_frem: { auto *FPI = cast(Call); - return SimplifyFRemInst(FPI->getArgOperand(0), FPI->getArgOperand(1), + return simplifyFRemInst(FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), Q, FPI->getExceptionBehavior().getValue(), FPI->getRoundingMode().getValue()); @@ -6222,7 +6236,7 @@ return ConstantFoldCall(Call, F, ConstantArgs, Q.TLI); } -Value *llvm::SimplifyCall(CallBase *Call, const SimplifyQuery &Q) { +Value *llvm::simplifyCall(CallBase *Call, const SimplifyQuery &Q) { // musttail calls can only be simplified if they are also DCEd. // As we can't guarantee this here, don't simplify them. if (Call->isMustTailCall()) @@ -6245,7 +6259,7 @@ return nullptr; } -Value *llvm::SimplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q) { +Value *llvm::simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q) { assert(isa(Call)); if (Value *V = tryConstantFoldCall(Call, Q)) return V; @@ -6255,7 +6269,7 @@ } /// Given operands for a Freeze, see if we can fold the result. -static Value *SimplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { +static Value *simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { // Use a utility function defined in ValueTracking. if (llvm::isGuaranteedNotToBeUndefOrPoison(Op0, Q.AC, Q.CxtI, Q.DT)) return Op0; @@ -6263,11 +6277,11 @@ return nullptr; } -Value *llvm::SimplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { - return ::SimplifyFreezeInst(Op0, Q); +Value *llvm::simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) { + return ::simplifyFreezeInst(Op0, Q); } -static Value *SimplifyLoadInst(LoadInst *LI, Value *PtrOp, +static Value *simplifyLoadInst(LoadInst *LI, Value *PtrOp, const SimplifyQuery &Q) { if (LI->isVolatile()) return nullptr; @@ -6311,134 +6325,134 @@ } break; case Instruction::FNeg: - Result = SimplifyFNegInst(NewOps[0], I->getFastMathFlags(), Q); + Result = simplifyFNegInst(NewOps[0], I->getFastMathFlags(), Q); break; case Instruction::FAdd: - Result = SimplifyFAddInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); + Result = simplifyFAddInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::Add: - Result = SimplifyAddInst( + Result = simplifyAddInst( NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast(I)), Q.IIQ.hasNoUnsignedWrap(cast(I)), Q); break; case Instruction::FSub: - Result = SimplifyFSubInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); + Result = simplifyFSubInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::Sub: - Result = SimplifySubInst( + Result = simplifySubInst( NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast(I)), Q.IIQ.hasNoUnsignedWrap(cast(I)), Q); break; case Instruction::FMul: - Result = SimplifyFMulInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); + Result = simplifyFMulInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::Mul: - Result = SimplifyMulInst(NewOps[0], NewOps[1], Q); + Result = simplifyMulInst(NewOps[0], NewOps[1], Q); break; case Instruction::SDiv: - Result = SimplifySDivInst(NewOps[0], NewOps[1], Q); + Result = simplifySDivInst(NewOps[0], NewOps[1], Q); break; case Instruction::UDiv: - Result = SimplifyUDivInst(NewOps[0], NewOps[1], Q); + Result = simplifyUDivInst(NewOps[0], NewOps[1], Q); break; case Instruction::FDiv: - Result = SimplifyFDivInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); + Result = simplifyFDivInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::SRem: - Result = SimplifySRemInst(NewOps[0], NewOps[1], Q); + Result = simplifySRemInst(NewOps[0], NewOps[1], Q); break; case Instruction::URem: - Result = SimplifyURemInst(NewOps[0], NewOps[1], Q); + Result = simplifyURemInst(NewOps[0], NewOps[1], Q); break; case Instruction::FRem: - Result = SimplifyFRemInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); + Result = simplifyFRemInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::Shl: - Result = SimplifyShlInst( + Result = simplifyShlInst( NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast(I)), Q.IIQ.hasNoUnsignedWrap(cast(I)), Q); break; case Instruction::LShr: - Result = SimplifyLShrInst(NewOps[0], NewOps[1], + Result = simplifyLShrInst(NewOps[0], NewOps[1], Q.IIQ.isExact(cast(I)), Q); break; case Instruction::AShr: - Result = SimplifyAShrInst(NewOps[0], NewOps[1], + Result = simplifyAShrInst(NewOps[0], NewOps[1], Q.IIQ.isExact(cast(I)), Q); break; case Instruction::And: - Result = SimplifyAndInst(NewOps[0], NewOps[1], Q); + Result = simplifyAndInst(NewOps[0], NewOps[1], Q); break; case Instruction::Or: - Result = SimplifyOrInst(NewOps[0], NewOps[1], Q); + Result = simplifyOrInst(NewOps[0], NewOps[1], Q); break; case Instruction::Xor: - Result = SimplifyXorInst(NewOps[0], NewOps[1], Q); + Result = simplifyXorInst(NewOps[0], NewOps[1], Q); break; case Instruction::ICmp: - Result = SimplifyICmpInst(cast(I)->getPredicate(), NewOps[0], + Result = simplifyICmpInst(cast(I)->getPredicate(), NewOps[0], NewOps[1], Q); break; case Instruction::FCmp: - Result = SimplifyFCmpInst(cast(I)->getPredicate(), NewOps[0], + Result = simplifyFCmpInst(cast(I)->getPredicate(), NewOps[0], NewOps[1], I->getFastMathFlags(), Q); break; case Instruction::Select: - Result = SimplifySelectInst(NewOps[0], NewOps[1], NewOps[2], Q); + Result = simplifySelectInst(NewOps[0], NewOps[1], NewOps[2], Q); break; case Instruction::GetElementPtr: { auto *GEPI = cast(I); Result = - SimplifyGEPInst(GEPI->getSourceElementType(), NewOps[0], + simplifyGEPInst(GEPI->getSourceElementType(), NewOps[0], makeArrayRef(NewOps).slice(1), GEPI->isInBounds(), Q); break; } case Instruction::InsertValue: { InsertValueInst *IV = cast(I); - Result = SimplifyInsertValueInst(NewOps[0], NewOps[1], IV->getIndices(), Q); + Result = simplifyInsertValueInst(NewOps[0], NewOps[1], IV->getIndices(), Q); break; } case Instruction::InsertElement: { - Result = SimplifyInsertElementInst(NewOps[0], NewOps[1], NewOps[2], Q); + Result = simplifyInsertElementInst(NewOps[0], NewOps[1], NewOps[2], Q); break; } case Instruction::ExtractValue: { auto *EVI = cast(I); - Result = SimplifyExtractValueInst(NewOps[0], EVI->getIndices(), Q); + Result = simplifyExtractValueInst(NewOps[0], EVI->getIndices(), Q); break; } case Instruction::ExtractElement: { - Result = SimplifyExtractElementInst(NewOps[0], NewOps[1], Q); + Result = simplifyExtractElementInst(NewOps[0], NewOps[1], Q); break; } case Instruction::ShuffleVector: { auto *SVI = cast(I); - Result = SimplifyShuffleVectorInst( + Result = simplifyShuffleVectorInst( NewOps[0], NewOps[1], SVI->getShuffleMask(), SVI->getType(), Q); break; } case Instruction::PHI: - Result = SimplifyPHINode(cast(I), NewOps, Q); + Result = simplifyPHINode(cast(I), NewOps, Q); break; case Instruction::Call: { // TODO: Use NewOps - Result = SimplifyCall(cast(I), Q); + Result = simplifyCall(cast(I), Q); break; } case Instruction::Freeze: - Result = llvm::SimplifyFreezeInst(NewOps[0], Q); + Result = llvm::simplifyFreezeInst(NewOps[0], Q); break; #define HANDLE_CAST_INST(num, opc, clas) case Instruction::opc: #include "llvm/IR/Instruction.def" #undef HANDLE_CAST_INST - Result = SimplifyCastInst(I->getOpcode(), NewOps[0], I->getType(), Q); + Result = simplifyCastInst(I->getOpcode(), NewOps[0], I->getType(), Q); break; case Instruction::Alloca: // No simplifications for Alloca and it can't be constant folded. Result = nullptr; break; case Instruction::Load: - Result = SimplifyLoadInst(cast(I), NewOps[0], Q); + Result = simplifyLoadInst(cast(I), NewOps[0], Q); break; } @@ -6448,7 +6462,7 @@ return Result == I ? UndefValue::get(I->getType()) : Result; } -Value *llvm::SimplifyInstructionWithOperands(Instruction *I, +Value *llvm::simplifyInstructionWithOperands(Instruction *I, ArrayRef NewOps, const SimplifyQuery &SQ, OptimizationRemarkEmitter *ORE) { @@ -6457,7 +6471,7 @@ return ::simplifyInstructionWithOperands(I, NewOps, SQ, ORE); } -Value *llvm::SimplifyInstruction(Instruction *I, const SimplifyQuery &SQ, +Value *llvm::simplifyInstruction(Instruction *I, const SimplifyQuery &SQ, OptimizationRemarkEmitter *ORE) { SmallVector Ops(I->operands()); return ::simplifyInstructionWithOperands(I, Ops, SQ, ORE); @@ -6508,7 +6522,7 @@ I = Worklist[Idx]; // See if this instruction simplifies. - SimpleV = SimplifyInstruction(I, {DL, TLI, DT, AC}); + SimpleV = simplifyInstruction(I, {DL, TLI, DT, AC}); if (!SimpleV) { if (UnsimplifiedUsers) UnsimplifiedUsers->insert(I); @@ -6571,6 +6585,6 @@ } template const SimplifyQuery getBestSimplifyQuery(AnalysisManager &, Function &); -} +} // namespace llvm void InstSimplifyFolder::anchor() {} diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1012,7 +1012,7 @@ // Handle extractvalue of insertvalue to allow further simplification // based on replaced with.overflow intrinsics. - if (Value *V = SimplifyExtractValueInst( + if (Value *V = simplifyExtractValueInst( EVI->getAggregateOperand(), EVI->getIndices(), EVI->getModule()->getDataLayout())) return getBlockValue(V, BB, EVI); @@ -1270,7 +1270,7 @@ if (auto *CI = dyn_cast(Usr)) { assert(CI->getOperand(0) == Op && "Operand 0 isn't Op"); if (auto *C = dyn_cast_or_null( - SimplifyCastInst(CI->getOpcode(), OpConst, + simplifyCastInst(CI->getOpcode(), OpConst, CI->getDestTy(), DL))) { return ValueLatticeElement::getRange(ConstantRange(C->getValue())); } @@ -1282,7 +1282,7 @@ Value *LHS = Op0Match ? OpConst : BO->getOperand(0); Value *RHS = Op1Match ? OpConst : BO->getOperand(1); if (auto *C = dyn_cast_or_null( - SimplifyBinOp(BO->getOpcode(), LHS, RHS, DL))) { + simplifyBinOp(BO->getOpcode(), LHS, RHS, DL))) { return ValueLatticeElement::getRange(ConstantRange(C->getValue())); } } else if (isa(Usr)) { diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -690,7 +690,7 @@ // As a last resort, try SimplifyInstruction or constant folding. if (Instruction *Inst = dyn_cast(V)) { - if (Value *W = SimplifyInstruction(Inst, {*DL, TLI, DT, AC})) + if (Value *W = simplifyInstruction(Inst, {*DL, TLI, DT, AC})) return findValueImpl(W, OffsetOk, Visited); } else if (auto *C = dyn_cast(V)) { Value *W = ConstantFoldConstant(C, *DL, TLI); diff --git a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp --- a/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp +++ b/llvm/lib/Analysis/LoopUnrollAnalyzer.cpp @@ -87,9 +87,9 @@ const DataLayout &DL = I.getModule()->getDataLayout(); if (auto FI = dyn_cast(&I)) SimpleV = - SimplifyBinOp(I.getOpcode(), LHS, RHS, FI->getFastMathFlags(), DL); + simplifyBinOp(I.getOpcode(), LHS, RHS, FI->getFastMathFlags(), DL); else - SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL); + SimpleV = simplifyBinOp(I.getOpcode(), LHS, RHS, DL); if (SimpleV) { SimplifiedValues[&I] = SimpleV; @@ -158,7 +158,7 @@ // i32 0). if (CastInst::castIsValid(I.getOpcode(), Op, I.getType())) { const DataLayout &DL = I.getModule()->getDataLayout(); - if (Value *V = SimplifyCastInst(I.getOpcode(), Op, I.getType(), DL)) { + if (Value *V = simplifyCastInst(I.getOpcode(), Op, I.getType(), DL)) { SimplifiedValues[&I] = V; return true; } @@ -195,7 +195,7 @@ } const DataLayout &DL = I.getModule()->getDataLayout(); - if (Value *V = SimplifyCmpInst(I.getPredicate(), LHS, RHS, DL)) { + if (Value *V = simplifyCmpInst(I.getPredicate(), LHS, RHS, DL)) { SimplifiedValues[&I] = V; return true; } diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -140,7 +140,7 @@ return false; auto DL = ExitBlock->getModule()->getDataLayout(); auto *IVStart = LHS->getIncomingValueForBlock(CurLoop->getLoopPreheader()); - auto *SimpleValOrNull = SimplifyCmpInst(Cond->getPredicate(), + auto *SimpleValOrNull = simplifyCmpInst(Cond->getPredicate(), IVStart, RHS, {DL, /*TLI*/ nullptr, DT, /*AC*/ nullptr, BI}); diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -222,7 +222,7 @@ return GEP; // Simplify the GEP to handle 'gep x, 0' -> x etc. - if (Value *V = SimplifyGEPInst(GEP->getSourceElementType(), GEPOps[0], + if (Value *V = simplifyGEPInst(GEP->getSourceElementType(), GEPOps[0], ArrayRef(GEPOps).slice(1), GEP->isInBounds(), {DL, TLI, DT, AC})) { for (unsigned i = 0, e = GEPOps.size(); i != e; ++i) @@ -274,7 +274,7 @@ } // See if the add simplifies away. - if (Value *Res = SimplifyAddInst(LHS, RHS, isNSW, isNUW, {DL, TLI, DT, AC})) { + if (Value *Res = simplifyAddInst(LHS, RHS, isNSW, isNUW, {DL, TLI, DT, AC})) { // If we simplified the operands, the LHS is no longer an input, but Res // is. RemoveInstInputs(LHS, InstInputs); diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -5931,7 +5931,7 @@ // PHI's incoming blocks are in a different loop, in which case doing so // risks breaking LCSSA form. Instcombine would normally zap these, but // it doesn't have DominatorTree information, so it may miss cases. - if (Value *V = SimplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC})) + if (Value *V = simplifyInstruction(PN, {getDataLayout(), &TLI, &DT, &AC})) if (LI.replacementPreservesLCSSAForm(PN, V)) return getSCEV(V); diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -3394,7 +3394,7 @@ if (!Visited.insert(P).second) continue; if (auto *PI = dyn_cast(P)) - if (Value *V = SimplifyInstruction(cast(PI), SQ)) { + if (Value *V = simplifyInstruction(cast(PI), SQ)) { for (auto *U : PI->users()) WorkList.push_back(cast(U)); Put(PI, V); @@ -7877,7 +7877,7 @@ // It is possible for very late stage optimizations (such as SimplifyCFG) // to introduce PHI nodes too late to be cleaned up. If we detect such a // trivial PHI, go ahead and zap it here. - if (Value *V = SimplifyInstruction(P, {*DL, TLInfo})) { + if (Value *V = simplifyInstruction(P, {*DL, TLInfo})) { LargeOffsetGEPMap.erase(P); P->replaceAllUsesWith(V); P->eraseFromParent(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp @@ -67,7 +67,7 @@ Value *simplify(Instruction *I, const TargetLibraryInfo *TLI, const DominatorTree *DT) { - return SimplifyInstruction(I, {*TD, TLI, DT}); + return simplifyInstruction(I, {*TD, TLI, DT}); } const DataLayout *TD; diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp --- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -1487,7 +1487,7 @@ void PolynomialMultiplyRecognize::cleanupLoopBody(BasicBlock *LoopB) { for (auto &I : *LoopB) - if (Value *SV = SimplifyInstruction(&I, {DL, &TLI, &DT})) + if (Value *SV = simplifyInstruction(&I, {DL, &TLI, &DT})) I.replaceAllUsesWith(SV); for (Instruction &I : llvm::make_early_inc_range(*LoopB)) @@ -2169,7 +2169,7 @@ SCEV::FlagNUW); Value *NumBytes = Expander.expandCodeFor(NumBytesS, IntPtrTy, ExpPt); if (Instruction *In = dyn_cast(NumBytes)) - if (Value *Simp = SimplifyInstruction(In, {*DL, TLI, DT})) + if (Value *Simp = simplifyInstruction(In, {*DL, TLI, DT})) NumBytes = Simp; CallInst *NewCall; @@ -2279,7 +2279,7 @@ Value *NumWords = Expander.expandCodeFor(NumWordsS, Int32Ty, MemmoveB->getTerminator()); if (Instruction *In = dyn_cast(NumWords)) - if (Value *Simp = SimplifyInstruction(In, {*DL, TLI, DT})) + if (Value *Simp = simplifyInstruction(In, {*DL, TLI, DT})) NumWords = Simp; Value *Op0 = (StoreBasePtr->getType() == Int32PtrTy) diff --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp --- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp @@ -1310,7 +1310,7 @@ auto Simplify = [&](Value *V) { if (auto *I = dyn_cast(V)) { SimplifyQuery Q(DL, &TLI, &DT, &AC, I); - if (Value *S = SimplifyInstruction(I, Q)) + if (Value *S = simplifyInstruction(I, Q)) return S; } return V; diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -5851,7 +5851,7 @@ const DataLayout &DL = I.getModule()->getDataLayout(); SimplifyQuery Q(DL, TLI, DT, AC, &I); if (Value *SimplifiedI = - SimplifyInstructionWithOperands(&I, NewOps, Q, ORE)) { + simplifyInstructionWithOperands(&I, NewOps, Q, ORE)) { SimplifiedAssociatedValue = AA::combineOptionalValuesInAAValueLatice( SimplifiedAssociatedValue, SimplifiedI, I.getType()); return SimplifiedAssociatedValue != Optional(nullptr); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1271,7 +1271,7 @@ } Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) { - if (Value *V = SimplifyAddInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyAddInst(I.getOperand(0), I.getOperand(1), I.hasNoSignedWrap(), I.hasNoUnsignedWrap(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1529,7 +1529,7 @@ } Instruction *InstCombinerImpl::visitFAdd(BinaryOperator &I) { - if (Value *V = SimplifyFAddInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyFAddInst(I.getOperand(0), I.getOperand(1), I.getFastMathFlags(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1751,7 +1751,7 @@ } Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) { - if (Value *V = SimplifySubInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifySubInst(I.getOperand(0), I.getOperand(1), I.hasNoSignedWrap(), I.hasNoUnsignedWrap(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -2278,7 +2278,7 @@ Instruction *InstCombinerImpl::visitFNeg(UnaryOperator &I) { Value *Op = I.getOperand(0); - if (Value *V = SimplifyFNegInst(Op, I.getFastMathFlags(), + if (Value *V = simplifyFNegInst(Op, I.getFastMathFlags(), getSimplifyQuery().getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -2329,7 +2329,7 @@ } Instruction *InstCombinerImpl::visitFSub(BinaryOperator &I) { - if (Value *V = SimplifyFSubInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyFSubInst(I.getOperand(0), I.getOperand(1), I.getFastMathFlags(), getSimplifyQuery().getWithInstruction(&I))) return replaceInstUsesWith(I, V); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1122,7 +1122,7 @@ // (X != C) || (Y Pred1 X) --> (X != C) || (Y Pred1 C) // Can think of the 'or' substitution with the 'and' bool equivalent: // A || B --> A || (!A && B) - Value *SubstituteCmp = SimplifyICmpInst(Pred1, Y, C, Q); + Value *SubstituteCmp = simplifyICmpInst(Pred1, Y, C, Q); if (!SubstituteCmp) { // If we need to create a new instruction, require that the old compare can // be removed. @@ -1728,7 +1728,7 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) { Type *Ty = I.getType(); - if (Value *V = SimplifyAndInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyAndInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -2570,7 +2570,7 @@ // here. We should standardize that construct where it is needed or choose some // other way to ensure that commutated variants of patterns are not missed. Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) { - if (Value *V = SimplifyOrInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyOrInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -3101,10 +3101,10 @@ // // This is based on a truth table definition of xor: // X ^ Y --> (X | Y) & !(X & Y) - if (Value *OrICmp = SimplifyBinOp(Instruction::Or, LHS, RHS, SQ)) { + if (Value *OrICmp = simplifyBinOp(Instruction::Or, LHS, RHS, SQ)) { // TODO: If OrICmp is true, then the definition of xor simplifies to !(X&Y). // TODO: If OrICmp is false, the whole thing is false (InstSimplify?). - if (Value *AndICmp = SimplifyBinOp(Instruction::And, LHS, RHS, SQ)) { + if (Value *AndICmp = simplifyBinOp(Instruction::And, LHS, RHS, SQ)) { // TODO: Independently handle cases where the 'and' side is a constant. ICmpInst *X = nullptr, *Y = nullptr; if (OrICmp == LHS && AndICmp == RHS) { @@ -3471,7 +3471,7 @@ // here. We should standardize that construct where it is needed or choose some // other way to ensure that commutated variants of patterns are not missed. Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) { - if (Value *V = SimplifyXorInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyXorInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1137,7 +1137,7 @@ // Don't try to simplify calls without uses. It will not do anything useful, // but will result in the following folds being skipped. if (!CI.use_empty()) - if (Value *V = SimplifyCall(&CI, SQ.getWithInstruction(&CI))) + if (Value *V = simplifyCall(&CI, SQ.getWithInstruction(&CI))) return replaceInstUsesWith(CI, V); if (isFreeCall(&CI, &TLI)) @@ -1242,7 +1242,7 @@ // actually absent. To detect this case, call SimplifyConstrainedFPCall. If it // returns a replacement, the call may be removed. if (CI.use_empty() && isa(CI)) { - if (SimplifyConstrainedFPCall(&CI, SQ.getWithInstruction(&CI))) + if (simplifyConstrainedFPCall(&CI, SQ.getWithInstruction(&CI))) return eraseInstFromFunction(CI); } @@ -1840,7 +1840,7 @@ } // Try to simplify the underlying FMul. - if (Value *V = SimplifyFMulInst(II->getArgOperand(0), II->getArgOperand(1), + if (Value *V = simplifyFMulInst(II->getArgOperand(0), II->getArgOperand(1), II->getFastMathFlags(), SQ.getWithInstruction(II))) { auto *FAdd = BinaryOperator::CreateFAdd(V, II->getArgOperand(2)); @@ -1871,7 +1871,7 @@ // Try to simplify the underlying FMul. We can only apply simplifications // that do not require rounding. - if (Value *V = SimplifyFMAFMul(II->getArgOperand(0), II->getArgOperand(1), + if (Value *V = simplifyFMAFMul(II->getArgOperand(0), II->getArgOperand(1), II->getFastMathFlags(), SQ.getWithInstruction(II))) { auto *FAdd = BinaryOperator::CreateFAdd(V, II->getArgOperand(2)); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3496,7 +3496,7 @@ // Try to fold the comparison into the select arms, which will cause the // select to be converted into a logical and/or. auto SimplifyOp = [&](Value *Op, bool SelectCondIsTrue) -> Value * { - if (Value *Res = SimplifyICmpInst(Pred, Op, RHS, SQ)) + if (Value *Res = simplifyICmpInst(Pred, Op, RHS, SQ)) return Res; if (Optional Impl = isImpliedCondition(SI->getCondition(), Pred, Op, RHS, DL, SelectCondIsTrue)) @@ -3812,7 +3812,7 @@ // Can we fold (XShAmt+YShAmt) ? auto *NewShAmt = dyn_cast_or_null( - SimplifyAddInst(XShAmt, YShAmt, /*isNSW=*/false, + simplifyAddInst(XShAmt, YShAmt, /*isNSW=*/false, /*isNUW=*/false, SQ.getWithInstruction(&I))); if (!NewShAmt) return nullptr; @@ -4836,7 +4836,7 @@ // or could not be determined to be equal (in the case of a constant // expression), so the constant cannot be represented in the shorter type. // All the cases that fold to true or false will have already been handled - // by SimplifyICmpInst, so only deal with the tricky case. + // by simplifyICmpInst, so only deal with the tricky case. if (IsSignedCmp || !IsSignedExt || !isa(C)) return nullptr; @@ -6064,7 +6064,7 @@ Changed = true; } - if (Value *V = SimplifyICmpInst(I.getPredicate(), Op0, Op1, Q)) + if (Value *V = simplifyICmpInst(I.getPredicate(), Op0, Op1, Q)) return replaceInstUsesWith(I, V); // Comparing -val or val with non-zero is the same as just comparing val @@ -6687,7 +6687,7 @@ const CmpInst::Predicate Pred = I.getPredicate(); Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (Value *V = SimplifyFCmpInst(Pred, Op0, Op1, I.getFastMathFlags(), + if (Value *V = simplifyFCmpInst(Pred, Op0, Op1, I.getFastMathFlags(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -140,7 +140,7 @@ } Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) { - if (Value *V = SimplifyMulInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyMulInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -460,7 +460,7 @@ } Instruction *InstCombinerImpl::visitFMul(BinaryOperator &I) { - if (Value *V = SimplifyFMulInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyFMulInst(I.getOperand(0), I.getOperand(1), I.getFastMathFlags(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1020,7 +1020,7 @@ } Instruction *InstCombinerImpl::visitUDiv(BinaryOperator &I) { - if (Value *V = SimplifyUDivInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyUDivInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1090,7 +1090,7 @@ } Instruction *InstCombinerImpl::visitSDiv(BinaryOperator &I) { - if (Value *V = SimplifySDivInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifySDivInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1321,7 +1321,7 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) { Module *M = I.getModule(); - if (Value *V = SimplifyFDivInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyFDivInst(I.getOperand(0), I.getOperand(1), I.getFastMathFlags(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1484,7 +1484,7 @@ } Instruction *InstCombinerImpl::visitURem(BinaryOperator &I) { - if (Value *V = SimplifyURemInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyURemInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1537,7 +1537,7 @@ } Instruction *InstCombinerImpl::visitSRem(BinaryOperator &I) { - if (Value *V = SimplifySRemInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifySRemInst(I.getOperand(0), I.getOperand(1), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1609,7 +1609,7 @@ } Instruction *InstCombinerImpl::visitFRem(BinaryOperator &I) { - if (Value *V = SimplifyFRemInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyFRemInst(I.getOperand(0), I.getOperand(1), I.getFastMathFlags(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp @@ -1363,7 +1363,7 @@ // PHINode simplification // Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) { - if (Value *V = SimplifyInstruction(&PN, SQ.getWithInstruction(&PN))) + if (Value *V = simplifyInstruction(&PN, SQ.getWithInstruction(&PN))) return replaceInstUsesWith(PN, V); if (Instruction *Result = foldPHIArgZextsIntoPHI(PN)) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -2644,7 +2644,7 @@ Value *FalseVal = SI.getFalseValue(); Type *SelType = SI.getType(); - if (Value *V = SimplifySelectInst(CondVal, TrueVal, FalseVal, + if (Value *V = simplifySelectInst(CondVal, TrueVal, FalseVal, SQ.getWithInstruction(&SI))) return replaceInstUsesWith(SI, V); @@ -3190,7 +3190,7 @@ // between the load and select masks. // (i.e (load_mask & select_mask) == 0 == no overlap) bool CanMergeSelectIntoLoad = false; - if (Value *V = SimplifyAndInst(CondVal, Mask, SQ.getWithInstruction(&SI))) + if (Value *V = simplifyAndInst(CondVal, Mask, SQ.getWithInstruction(&SI))) CanMergeSelectIntoLoad = match(V, m_Zero()); if (CanMergeSelectIntoLoad) { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -107,7 +107,7 @@ // Can we fold (ShAmt0+ShAmt1) ? auto *NewShAmt = dyn_cast_or_null( - SimplifyAddInst(ShAmt0, ShAmt1, /*isNSW=*/false, /*isNUW=*/false, + simplifyAddInst(ShAmt0, ShAmt1, /*isNSW=*/false, /*isNUW=*/false, SQ.getWithInstruction(Sh0))); if (!NewShAmt) return nullptr; // Did not simplify. @@ -231,7 +231,7 @@ return nullptr; // Can we simplify (MaskShAmt+ShiftShAmt) ? - auto *SumOfShAmts = dyn_cast_or_null(SimplifyAddInst( + auto *SumOfShAmts = dyn_cast_or_null(simplifyAddInst( MaskShAmt, ShiftShAmt, /*IsNSW=*/false, /*IsNUW=*/false, Q)); if (!SumOfShAmts) return nullptr; // Did not simplify. @@ -263,7 +263,7 @@ return nullptr; // Can we simplify (ShiftShAmt-MaskShAmt) ? - auto *ShAmtsDiff = dyn_cast_or_null(SimplifySubInst( + auto *ShAmtsDiff = dyn_cast_or_null(simplifySubInst( ShiftShAmt, MaskShAmt, /*IsNSW=*/false, /*IsNUW=*/false, Q)); if (!ShAmtsDiff) return nullptr; // Did not simplify. @@ -811,7 +811,7 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) { const SimplifyQuery Q = SQ.getWithInstruction(&I); - if (Value *V = SimplifyShlInst(I.getOperand(0), I.getOperand(1), + if (Value *V = simplifyShlInst(I.getOperand(0), I.getOperand(1), I.hasNoSignedWrap(), I.hasNoUnsignedWrap(), Q)) return replaceInstUsesWith(I, V); @@ -1038,7 +1038,7 @@ } Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) { - if (Value *V = SimplifyLShrInst(I.getOperand(0), I.getOperand(1), I.isExact(), + if (Value *V = simplifyLShrInst(I.getOperand(0), I.getOperand(1), I.isExact(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); @@ -1347,7 +1347,7 @@ } Instruction *InstCombinerImpl::visitAShr(BinaryOperator &I) { - if (Value *V = SimplifyAShrInst(I.getOperand(0), I.getOperand(1), I.isExact(), + if (Value *V = simplifyAShrInst(I.getOperand(0), I.getOperand(1), I.isExact(), SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -377,7 +377,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) { Value *SrcVec = EI.getVectorOperand(); Value *Index = EI.getIndexOperand(); - if (Value *V = SimplifyExtractElementInst(SrcVec, Index, + if (Value *V = simplifyExtractElementInst(SrcVec, Index, SQ.getWithInstruction(&EI))) return replaceInstUsesWith(EI, V); @@ -1488,7 +1488,7 @@ Value *ScalarOp = IE.getOperand(1); Value *IdxOp = IE.getOperand(2); - if (auto *V = SimplifyInsertElementInst( + if (auto *V = simplifyInsertElementInst( VecOp, ScalarOp, IdxOp, SQ.getWithInstruction(&IE))) return replaceInstUsesWith(IE, V); @@ -2533,7 +2533,7 @@ Value *LHS = SVI.getOperand(0); Value *RHS = SVI.getOperand(1); SimplifyQuery ShufQuery = SQ.getWithInstruction(&SVI); - if (auto *V = SimplifyShuffleVectorInst(LHS, RHS, SVI.getShuffleMask(), + if (auto *V = simplifyShuffleVectorInst(LHS, RHS, SVI.getShuffleMask(), SVI.getType(), ShufQuery)) return replaceInstUsesWith(SVI, V); @@ -2588,7 +2588,7 @@ if (!ScaledMask.empty()) { // If the shuffled source vector simplifies, cast that value to this // shuffle's type. - if (auto *V = SimplifyShuffleVectorInst(X, UndefValue::get(XType), + if (auto *V = simplifyShuffleVectorInst(X, UndefValue::get(XType), ScaledMask, XType, ShufQuery)) return BitCastInst::Create(Instruction::BitCast, V, SVI.getType()); } diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -426,7 +426,7 @@ Value *C = I.getOperand(1); // Does "B op C" simplify? - if (Value *V = SimplifyBinOp(Opcode, B, C, SQ.getWithInstruction(&I))) { + if (Value *V = simplifyBinOp(Opcode, B, C, SQ.getWithInstruction(&I))) { // It simplifies to V. Form "A op V". replaceOperand(I, 0, A); replaceOperand(I, 1, V); @@ -459,7 +459,7 @@ Value *C = Op1->getOperand(1); // Does "A op B" simplify? - if (Value *V = SimplifyBinOp(Opcode, A, B, SQ.getWithInstruction(&I))) { + if (Value *V = simplifyBinOp(Opcode, A, B, SQ.getWithInstruction(&I))) { // It simplifies to V. Form "V op C". replaceOperand(I, 0, V); replaceOperand(I, 1, C); @@ -487,7 +487,7 @@ Value *C = I.getOperand(1); // Does "C op A" simplify? - if (Value *V = SimplifyBinOp(Opcode, C, A, SQ.getWithInstruction(&I))) { + if (Value *V = simplifyBinOp(Opcode, C, A, SQ.getWithInstruction(&I))) { // It simplifies to V. Form "V op B". replaceOperand(I, 0, V); replaceOperand(I, 1, B); @@ -507,7 +507,7 @@ Value *C = Op1->getOperand(1); // Does "C op A" simplify? - if (Value *V = SimplifyBinOp(Opcode, C, A, SQ.getWithInstruction(&I))) { + if (Value *V = simplifyBinOp(Opcode, C, A, SQ.getWithInstruction(&I))) { // It simplifies to V. Form "B op V". replaceOperand(I, 0, B); replaceOperand(I, 1, V); @@ -654,7 +654,7 @@ std::swap(C, D); // Consider forming "A op' (B op D)". // If "B op D" simplifies then it can be formed with no cost. - V = SimplifyBinOp(TopLevelOpcode, B, D, SQ.getWithInstruction(&I)); + V = simplifyBinOp(TopLevelOpcode, B, D, SQ.getWithInstruction(&I)); // If "B op D" doesn't simplify then only go on if both of the existing // operations "A op' B" and "C op' D" will be zapped as no longer used. if (!V && LHS->hasOneUse() && RHS->hasOneUse()) @@ -673,7 +673,7 @@ std::swap(C, D); // Consider forming "(A op C) op' B". // If "A op C" simplifies then it can be formed with no cost. - V = SimplifyBinOp(TopLevelOpcode, A, C, SQ.getWithInstruction(&I)); + V = simplifyBinOp(TopLevelOpcode, A, C, SQ.getWithInstruction(&I)); // If "A op C" doesn't simplify then only go on if both of the existing // operations "A op' B" and "C op' D" will be zapped as no longer used. @@ -782,8 +782,8 @@ // Disable the use of undef because it's not safe to distribute undef. auto SQDistributive = SQ.getWithInstruction(&I).getWithoutUndef(); - Value *L = SimplifyBinOp(TopLevelOpcode, A, C, SQDistributive); - Value *R = SimplifyBinOp(TopLevelOpcode, B, C, SQDistributive); + Value *L = simplifyBinOp(TopLevelOpcode, A, C, SQDistributive); + Value *R = simplifyBinOp(TopLevelOpcode, B, C, SQDistributive); // Do "A op C" and "B op C" both simplify? if (L && R) { @@ -821,8 +821,8 @@ // Disable the use of undef because it's not safe to distribute undef. auto SQDistributive = SQ.getWithInstruction(&I).getWithoutUndef(); - Value *L = SimplifyBinOp(TopLevelOpcode, A, B, SQDistributive); - Value *R = SimplifyBinOp(TopLevelOpcode, A, C, SQDistributive); + Value *L = simplifyBinOp(TopLevelOpcode, A, B, SQDistributive); + Value *R = simplifyBinOp(TopLevelOpcode, A, C, SQDistributive); // Do "A op B" and "A op C" both simplify? if (L && R) { @@ -878,8 +878,8 @@ if (LHSIsSelect && RHSIsSelect && A == D) { // (A ? B : C) op (A ? E : F) -> A ? (B op E) : (C op F) Cond = A; - True = SimplifyBinOp(Opcode, B, E, FMF, Q); - False = SimplifyBinOp(Opcode, C, F, FMF, Q); + True = simplifyBinOp(Opcode, B, E, FMF, Q); + False = simplifyBinOp(Opcode, C, F, FMF, Q); if (LHS->hasOneUse() && RHS->hasOneUse()) { if (False && !True) @@ -890,13 +890,13 @@ } else if (LHSIsSelect && LHS->hasOneUse()) { // (A ? B : C) op Y -> A ? (B op Y) : (C op Y) Cond = A; - True = SimplifyBinOp(Opcode, B, RHS, FMF, Q); - False = SimplifyBinOp(Opcode, C, RHS, FMF, Q); + True = simplifyBinOp(Opcode, B, RHS, FMF, Q); + False = simplifyBinOp(Opcode, C, RHS, FMF, Q); } else if (RHSIsSelect && RHS->hasOneUse()) { // X op (D ? E : F) -> D ? (X op E) : (X op F) Cond = D; - True = SimplifyBinOp(Opcode, LHS, E, FMF, Q); - False = SimplifyBinOp(Opcode, LHS, F, FMF, Q); + True = simplifyBinOp(Opcode, LHS, E, FMF, Q); + False = simplifyBinOp(Opcode, LHS, F, FMF, Q); } if (!True || !False) @@ -2088,7 +2088,7 @@ return nullptr; Value *Sum = - SimplifyAddInst(GO1, SO1, false, false, SQ.getWithInstruction(&GEP)); + simplifyAddInst(GO1, SO1, false, false, SQ.getWithInstruction(&GEP)); // Only do the combine when we are sure the cost after the // merge is never more than that before the merge. if (Sum == nullptr) @@ -2235,7 +2235,7 @@ Type *GEPType = GEP.getType(); Type *GEPEltType = GEP.getSourceElementType(); bool IsGEPSrcEleScalable = isa(GEPEltType); - if (Value *V = SimplifyGEPInst(GEPEltType, PtrOp, Indices, GEP.isInBounds(), + if (Value *V = simplifyGEPInst(GEPEltType, PtrOp, Indices, GEP.isInBounds(), SQ.getWithInstruction(&GEP))) return replaceInstUsesWith(GEP, V); @@ -3224,7 +3224,7 @@ if (!EV.hasIndices()) return replaceInstUsesWith(EV, Agg); - if (Value *V = SimplifyExtractValueInst(Agg, EV.getIndices(), + if (Value *V = simplifyExtractValueInst(Agg, EV.getIndices(), SQ.getWithInstruction(&EV))) return replaceInstUsesWith(EV, V); @@ -3818,7 +3818,7 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) { Value *Op0 = I.getOperand(0); - if (Value *V = SimplifyFreezeInst(Op0, SQ.getWithInstruction(&I))) + if (Value *V = simplifyFreezeInst(Op0, SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); // freeze (phi const, x) --> phi const, (freeze x) diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -276,7 +276,7 @@ } } - if (Value *V = SimplifyInstruction(P, SQ)) { + if (Value *V = simplifyInstruction(P, SQ)) { P->replaceAllUsesWith(V); P->eraseFromParent(); Changed = true; diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -1347,7 +1347,7 @@ // If the instruction can be simplified (e.g. X+0 = X) then replace it with // its simpler value. - if (Value *V = SimplifyInstruction(&Inst, SQ)) { + if (Value *V = simplifyInstruction(&Inst, SQ)) { LLVM_DEBUG(dbgs() << "EarlyCSE Simplify: " << Inst << " to: " << *V << '\n'); if (!DebugCounter::shouldExecute(CSECounter)) { diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -2455,7 +2455,7 @@ // example if it determines that %y is equal to %x then the instruction // "%z = and i32 %x, %y" becomes "%z = and i32 %x, %x" which we now simplify. const DataLayout &DL = I->getModule()->getDataLayout(); - if (Value *V = SimplifyInstruction(I, {DL, TLI, DT, AC})) { + if (Value *V = simplifyInstruction(I, {DL, TLI, DT, AC})) { bool Changed = false; if (!I->use_empty()) { // Simplification can cause a special instruction to become not special. diff --git a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp --- a/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp +++ b/llvm/lib/Transforms/Scalar/InstSimplifyPass.cpp @@ -51,7 +51,7 @@ DeadInstsInBB.push_back(&I); Changed = true; } else if (!I.use_empty()) { - if (Value *V = SimplifyInstruction(&I, SQ, ORE)) { + if (Value *V = simplifyInstruction(&I, SQ, ORE)) { // Mark all uses for resimplification next time round the loop. for (User *U : I.users()) Next->insert(cast(U)); diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -831,7 +831,7 @@ LHS = CmpLHS->DoPHITranslation(BB, PredBB); RHS = PN->getIncomingValue(i); } - Value *Res = SimplifyCmpInst(Pred, LHS, RHS, {DL}); + Value *Res = simplifyCmpInst(Pred, LHS, RHS, {DL}); if (!Res) { if (!isa(RHS)) continue; @@ -2662,7 +2662,7 @@ // If this instruction can be simplified after the operands are updated, // just use the simplified value instead. This frequently happens due to // phi translation. - if (Value *IV = SimplifyInstruction( + if (Value *IV = simplifyInstruction( New, {BB->getModule()->getDataLayout(), TLI, nullptr, nullptr, New})) { ValueMapping[&*BI] = IV; diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp --- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp @@ -192,13 +192,13 @@ getValueOnFirstIteration(BO->getOperand(0), FirstIterValue, SQ); Value *RHS = getValueOnFirstIteration(BO->getOperand(1), FirstIterValue, SQ); - FirstIterV = SimplifyBinOp(BO->getOpcode(), LHS, RHS, SQ); + FirstIterV = simplifyBinOp(BO->getOpcode(), LHS, RHS, SQ); } else if (auto *Cmp = dyn_cast(V)) { Value *LHS = getValueOnFirstIteration(Cmp->getOperand(0), FirstIterValue, SQ); Value *RHS = getValueOnFirstIteration(Cmp->getOperand(1), FirstIterValue, SQ); - FirstIterV = SimplifyICmpInst(Cmp->getPredicate(), LHS, RHS, SQ); + FirstIterV = simplifyICmpInst(Cmp->getPredicate(), LHS, RHS, SQ); } else if (auto *Select = dyn_cast(V)) { Value *Cond = getValueOnFirstIteration(Select->getCondition(), FirstIterValue, SQ); diff --git a/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp b/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp --- a/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp @@ -96,7 +96,7 @@ if (!IsFirstIteration && !ToSimplify->count(&I)) continue; - Value *V = SimplifyInstruction(&I, SQ.getWithInstruction(&I)); + Value *V = simplifyInstruction(&I, SQ.getWithInstruction(&I)); if (!V || !LI.replacementPreservesLCSSAForm(&I, V)) continue; diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -1089,7 +1089,7 @@ E->op_push_back(lookupOperandLeader(Arg1)); E->op_push_back(lookupOperandLeader(Arg2)); - Value *V = SimplifyBinOp(Opcode, E->getOperand(0), E->getOperand(1), SQ); + Value *V = simplifyBinOp(Opcode, E->getOperand(0), E->getOperand(1), SQ); if (auto Simplified = checkExprResults(E, I, V)) { addAdditionalUsers(Simplified, I); return Simplified.Expr; @@ -1167,13 +1167,13 @@ Predicate = CmpInst::getSwappedPredicate(Predicate); } E->setOpcode((CI->getOpcode() << 8) | Predicate); - // TODO: 25% of our time is spent in SimplifyCmpInst with pointer operands + // TODO: 25% of our time is spent in simplifyCmpInst with pointer operands assert(I->getOperand(0)->getType() == I->getOperand(1)->getType() && "Wrong types on cmp instruction"); assert((E->getOperand(0)->getType() == I->getOperand(0)->getType() && E->getOperand(1)->getType() == I->getOperand(1)->getType())); Value *V = - SimplifyCmpInst(Predicate, E->getOperand(0), E->getOperand(1), SQ); + simplifyCmpInst(Predicate, E->getOperand(0), E->getOperand(1), SQ); if (auto Simplified = checkExprResults(E, I, V)) return Simplified; } else if (isa(I)) { @@ -1181,24 +1181,24 @@ E->getOperand(1) == E->getOperand(2)) { assert(E->getOperand(1)->getType() == I->getOperand(1)->getType() && E->getOperand(2)->getType() == I->getOperand(2)->getType()); - Value *V = SimplifySelectInst(E->getOperand(0), E->getOperand(1), + Value *V = simplifySelectInst(E->getOperand(0), E->getOperand(1), E->getOperand(2), SQ); if (auto Simplified = checkExprResults(E, I, V)) return Simplified; } } else if (I->isBinaryOp()) { Value *V = - SimplifyBinOp(E->getOpcode(), E->getOperand(0), E->getOperand(1), SQ); + simplifyBinOp(E->getOpcode(), E->getOperand(0), E->getOperand(1), SQ); if (auto Simplified = checkExprResults(E, I, V)) return Simplified; } else if (auto *CI = dyn_cast(I)) { Value *V = - SimplifyCastInst(CI->getOpcode(), E->getOperand(0), CI->getType(), SQ); + simplifyCastInst(CI->getOpcode(), E->getOperand(0), CI->getType(), SQ); if (auto Simplified = checkExprResults(E, I, V)) return Simplified; } else if (auto *GEPI = dyn_cast(I)) { Value *V = - SimplifyGEPInst(GEPI->getSourceElementType(), *E->op_begin(), + simplifyGEPInst(GEPI->getSourceElementType(), *E->op_begin(), makeArrayRef(std::next(E->op_begin()), E->op_end()), GEPI->isInBounds(), SQ); if (auto Simplified = checkExprResults(E, I, V)) diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -1012,7 +1012,7 @@ I.getParent()->getFirstInsertionPt() == I.getParent()->end()) return PI.setAborted(&I); - // TODO: We could use SimplifyInstruction here to fold PHINodes and + // TODO: We could use simplifyInstruction here to fold PHINodes and // SelectInsts. However, doing so requires to change the current // dead-operand-tracking mechanism. For instance, suppose neither loading // from %U nor %other traps. Then "load (select undef, %U, %other)" does not diff --git a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp --- a/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp +++ b/llvm/lib/Transforms/Scalar/StructurizeCFG.cpp @@ -681,7 +681,7 @@ Q.DT = DT; for (WeakVH VH : AffectedPhis) { if (auto Phi = dyn_cast_or_null(VH)) { - if (auto NewValue = SimplifyInstruction(Phi, Q)) { + if (auto NewValue = simplifyInstruction(Phi, Q)) { Phi->replaceAllUsesWith(NewValue); Phi->eraseFromParent(); Changed = true; diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -729,7 +729,7 @@ // call. for (PHINode *PN : ArgumentPHIs) { // If the PHI Node is a dynamic constant, replace it with the value it is. - if (Value *PNV = SimplifyInstruction(PN, F.getParent()->getDataLayout())) { + if (Value *PNV = simplifyInstruction(PN, F.getParent()->getDataLayout())) { PN->replaceAllUsesWith(PNV); PN->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -485,7 +485,7 @@ // a mapping to that value rather than inserting a new instruction into // the basic block. if (Value *V = - SimplifyInstruction(NewInst, BB->getModule()->getDataLayout())) { + simplifyInstruction(NewInst, BB->getModule()->getDataLayout())) { // On the off-chance that this simplifies to an instruction in the old // function, map it back into the new function. if (NewFunc != OldFunc) @@ -768,7 +768,7 @@ continue; // See if this instruction simplifies. - Value *SimpleV = SimplifyInstruction(I, DL); + Value *SimpleV = simplifyInstruction(I, DL); if (!SimpleV) continue; diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -2650,7 +2650,7 @@ AssumptionCache *AC = IFI.GetAssumptionCache ? &IFI.GetAssumptionCache(*Caller) : nullptr; auto &DL = Caller->getParent()->getDataLayout(); - if (Value *V = SimplifyInstruction(PHI, {DL, nullptr, nullptr, AC})) { + if (Value *V = simplifyInstruction(PHI, {DL, nullptr, nullptr, AC})) { PHI->replaceAllUsesWith(V); PHI->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -675,7 +675,7 @@ return true; } - if (Value *SimpleV = SimplifyInstruction(I, DL)) { + if (Value *SimpleV = simplifyInstruction(I, DL)) { // Add the users to the worklist. CAREFUL: an instruction can use itself, // in the case of a phi node. for (User *U : I->users()) { diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -439,7 +439,7 @@ // With the operands remapped, see if the instruction constant folds or is // otherwise simplifyable. This commonly occurs because the entry from PHI // nodes allows icmps and other instructions to fold. - Value *V = SimplifyInstruction(C, SQ); + Value *V = simplifyInstruction(C, SQ); if (V && LI->replacementPreservesLCSSAForm(C, V)) { // If so, then delete the temporary instruction and stick the folded value // in the map. diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -176,7 +176,7 @@ for (BasicBlock::iterator I = L->getHeader()->begin(); isa(I); ) { PHINode *PN = cast(I); ++I; - if (Value *V = SimplifyInstruction(PN, {DL, nullptr, DT, AC})) { + if (Value *V = simplifyInstruction(PN, {DL, nullptr, DT, AC})) { // This is a degenerate PHI already, don't modify it! PN->replaceAllUsesWith(V); PN->eraseFromParent(); @@ -597,7 +597,7 @@ PHINode *PN; for (BasicBlock::iterator I = L->getHeader()->begin(); (PN = dyn_cast(I++)); ) - if (Value *V = SimplifyInstruction(PN, {DL, nullptr, DT, AC})) { + if (Value *V = simplifyInstruction(PN, {DL, nullptr, DT, AC})) { if (SE) SE->forgetValue(PN); if (!PreserveLCSSA || LI->replacementPreservesLCSSAForm(PN, V)) { PN->replaceAllUsesWith(V); diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -236,7 +236,7 @@ SmallVector DeadInsts; for (BasicBlock *BB : L->getBlocks()) { for (Instruction &Inst : llvm::make_early_inc_range(*BB)) { - if (Value *V = SimplifyInstruction(&Inst, {DL, nullptr, DT, AC})) + if (Value *V = simplifyInstruction(&Inst, {DL, nullptr, DT, AC})) if (LI->replacementPreservesLCSSAForm(&Inst, V)) Inst.replaceAllUsesWith(V); if (isInstructionTriviallyDead(&Inst)) diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -957,7 +957,7 @@ SmallVector DeadInsts; for (BasicBlock *BB : RemainderBlocks) { for (Instruction &Inst : llvm::make_early_inc_range(*BB)) { - if (Value *V = SimplifyInstruction(&Inst, {DL, nullptr, DT, AC})) + if (Value *V = simplifyInstruction(&Inst, {DL, nullptr, DT, AC})) if (LI->replacementPreservesLCSSAForm(&Inst, V)) Inst.replaceAllUsesWith(V); if (isInstructionTriviallyDead(&Inst)) diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -702,7 +702,7 @@ PHINode *PN = I->second; // If this PHI node merges one value and/or undefs, get the value. - if (Value *V = SimplifyInstruction(PN, SQ)) { + if (Value *V = simplifyInstruction(PN, SQ)) { PN->replaceAllUsesWith(V); PN->eraseFromParent(); NewPhiNodes.erase(I++); diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp --- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -996,7 +996,7 @@ if ((V1State.isConstant() || V2State.isConstant())) { Value *V1 = isConstant(V1State) ? getConstant(V1State) : I.getOperand(0); Value *V2 = isConstant(V2State) ? getConstant(V2State) : I.getOperand(1); - Value *R = SimplifyBinOp(I.getOpcode(), V1, V2, SimplifyQuery(DL)); + Value *R = simplifyBinOp(I.getOpcode(), V1, V2, SimplifyQuery(DL)); auto *C = dyn_cast_or_null(R); if (C) { // X op Y -> undef. diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp --- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp +++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp @@ -165,7 +165,7 @@ // See if the PHI node can be merged to a single value. This can happen in // loop cases when we get a PHI of itself and one other value. if (Value *V = - SimplifyInstruction(InsertedPHI, BB->getModule()->getDataLayout())) { + simplifyInstruction(InsertedPHI, BB->getModule()->getDataLayout())) { InsertedPHI->eraseFromParent(); return V; } diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1932,7 +1932,7 @@ // so narrow phis can reuse them. for (PHINode *Phi : Phis) { auto SimplifyPHINode = [&](PHINode *PN) -> Value * { - if (Value *V = SimplifyInstruction(PN, {DL, &SE.TLI, &SE.DT, &SE.AC})) + if (Value *V = simplifyInstruction(PN, {DL, &SE.TLI, &SE.DT, &SE.AC})) return V; if (!SE.isSCEVable(PN->getType())) return nullptr; diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3103,7 +3103,7 @@ } // Check for trivial simplification. - if (Value *V = SimplifyInstruction(N, {DL, nullptr, nullptr, AC})) { + if (Value *V = simplifyInstruction(N, {DL, nullptr, nullptr, AC})) { if (!BBI->use_empty()) TranslateMap[&*BBI] = V; if (!N->mayHaveSideEffects()) { @@ -3244,7 +3244,7 @@ bool Changed = false; for (BasicBlock::iterator II = BB->begin(); isa(II);) { PHINode *PN = cast(II++); - if (Value *V = SimplifyInstruction(PN, {DL, PN})) { + if (Value *V = simplifyInstruction(PN, {DL, PN})) { PN->replaceAllUsesWith(V); PN->eraseFromParent(); Changed = true; @@ -4489,7 +4489,7 @@ assert(VVal && "Should have a unique destination value"); ICI->setOperand(0, VVal); - if (Value *V = SimplifyInstruction(ICI, {DL, ICI})) { + if (Value *V = simplifyInstruction(ICI, {DL, ICI})) { ICI->replaceAllUsesWith(V); ICI->eraseFromParent(); } diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp --- a/llvm/unittests/Transforms/Utils/LocalTest.cpp +++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -596,9 +596,9 @@ Function *VScale = Intrinsic::getDeclaration(&M, Intrinsic::vscale, {Ty}); auto *CI = CallInst::Create(VScale, {}, "vscale"); - // Test that SimplifyCall won't try to query it's parent function for + // Test that simplifyCall won't try to query it's parent function for // vscale_range attributes in order to simplify llvm.vscale -> constant. - EXPECT_EQ(SimplifyCall(CI, SimplifyQuery(M.getDataLayout())), nullptr); + EXPECT_EQ(simplifyCall(CI, SimplifyQuery(M.getDataLayout())), nullptr); delete CI; }