diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -18,7 +18,10 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/ConstraintSystem.h" #include "llvm/Analysis/GlobalsModRef.h" +#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/OptimizationRemarkEmitter.h" +#include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Dominators.h" @@ -90,6 +93,8 @@ Value *Op0; Value *Op1; + ConditionTy() + : Pred(CmpInst::BAD_ICMP_PREDICATE), Op0(nullptr), Op1(nullptr) {} ConditionTy(CmpInst::Predicate Pred, Value *Op0, Value *Op1) : Pred(Pred), Op0(Op0), Op1(Op1) {} }; @@ -115,6 +120,10 @@ ConditionTy Cond; }; + /// A pre-condition that must hold for the current fact to be added to the + /// system. + ConditionTy DoesHold; + unsigned NumIn; unsigned NumOut; EntryTy Ty; @@ -124,27 +133,25 @@ Ty(Ty) {} FactOrCheck(DomTreeNode *DTN, Use *U) - : U(U), NumIn(DTN->getDFSNumIn()), NumOut(DTN->getDFSNumOut()), + : U(U), DoesHold(CmpInst::BAD_ICMP_PREDICATE, nullptr, nullptr), + NumIn(DTN->getDFSNumIn()), NumOut(DTN->getDFSNumOut()), Ty(EntryTy::UseCheck) {} - FactOrCheck(DomTreeNode *DTN, CmpInst::Predicate Pred, Value *Op0, Value *Op1) - : Cond(Pred, Op0, Op1), NumIn(DTN->getDFSNumIn()), + FactOrCheck(DomTreeNode *DTN, CmpInst::Predicate Pred, Value *Op0, Value *Op1, + ConditionTy Precond = ConditionTy()) + : Cond(Pred, Op0, Op1), DoesHold(Precond), NumIn(DTN->getDFSNumIn()), NumOut(DTN->getDFSNumOut()), Ty(EntryTy::ConditionFact) {} static FactOrCheck getConditionFact(DomTreeNode *DTN, CmpInst::Predicate Pred, - Value *Op0, Value *Op1) { - return FactOrCheck(DTN, Pred, Op0, Op1); + Value *Op0, Value *Op1, + ConditionTy Precond = ConditionTy()) { + return FactOrCheck(DTN, Pred, Op0, Op1, Precond); } static FactOrCheck getInstFact(DomTreeNode *DTN, Instruction *Inst) { return FactOrCheck(EntryTy::InstFact, DTN, Inst); } - static FactOrCheck getFact(DomTreeNode *DTN, CmpInst::Predicate Pred, - Value *Op0, Value *Op1) { - return FactOrCheck(DTN, Pred, Op0, Op1); - } - static FactOrCheck getCheck(DomTreeNode *DTN, Use *U) { return FactOrCheck(DTN, U); } @@ -177,13 +184,20 @@ /// Keep state required to build worklist. struct State { DominatorTree &DT; + LoopInfo &LI; + ScalarEvolution &SE; SmallVector WorkList; - State(DominatorTree &DT) : DT(DT) {} + State(DominatorTree &DT, LoopInfo &LI, ScalarEvolution &SE) + : DT(DT), LI(LI), SE(SE) {} /// Process block \p BB and add known facts to work-list. void addInfoFor(BasicBlock &BB); + /// Try to add facts for loop inductions (AddRecs) in EQ/NE compares + /// controlling the loop header. + void addInfoForInductions(BasicBlock &BB); + /// Returns true if we can add a known condition from BB to its successor /// block Succ. bool canAddSuccessor(BasicBlock &BB, BasicBlock *Succ) const { @@ -799,7 +813,110 @@ } #endif +void State::addInfoForInductions(BasicBlock &BB) { + auto *L = LI.getLoopFor(&BB); + if (!L || L->getHeader() != &BB) + return; + + Value *A; + Value *B; + CmpInst::Predicate Pred; + + if (!match(BB.getTerminator(), + m_Br(m_ICmp(Pred, m_Value(A), m_Value(B)), m_Value(), m_Value()))) + return; + PHINode *PN = dyn_cast(A); + if (!PN) { + Pred = CmpInst::getSwappedPredicate(Pred); + std::swap(A, B); + PN = dyn_cast(A); + } + + if (!PN || PN->getParent() != &BB || PN->getNumIncomingValues() != 2 || + !SE.isSCEVable(PN->getType())) + return; + + BasicBlock *InLoopSucc = nullptr; + if (Pred == CmpInst::ICMP_NE) + InLoopSucc = cast(BB.getTerminator())->getSuccessor(0); + else if (Pred == CmpInst::ICMP_EQ) + InLoopSucc = cast(BB.getTerminator())->getSuccessor(1); + else + return; + + if (!L->contains(InLoopSucc) || !L->isLoopExiting(&BB) || InLoopSucc == &BB) + return; + + auto *AR = dyn_cast_or_null(SE.getSCEV(PN)); + if (!AR) + return; + + const SCEV *StartSCEV = AR->getStart(); + Value *StartValue = nullptr; + if (auto *C = dyn_cast(StartSCEV)) + StartValue = C->getValue(); + else if (auto *U = dyn_cast(StartSCEV)) + StartValue = U->getValue(); + + if (!StartValue) + return; + + auto *DTN = DT.getNode(InLoopSucc); + auto Inc = SE.getMonotonicPredicateType(AR, CmpInst::ICMP_UGT); + if (Inc && *Inc == ScalarEvolution::MonotonicallyIncreasing) { + // SCEV guarantees that AR does not wrap, so PN >= StartValue can be added + // unconditionally. + WorkList.push_back( + FactOrCheck::getConditionFact(DTN, CmpInst::ICMP_UGE, PN, StartValue)); + } + + APInt StepOffset; + if (auto *C = dyn_cast(AR->getStepRecurrence(SE))) + StepOffset = C->getAPInt(); + else + return; + + // Make sure AR either steps by 1 or that the value we compare against is a + // GEP based on the same start value and all offsets are a multiple of the + // step size, to guarantee that the induction will reach the value. + if (StepOffset.isZero() || StepOffset.isNegative()) + return; + + if (!StepOffset.isOne()) { + auto *UpperGEP = dyn_cast(B); + if (!UpperGEP || UpperGEP->getPointerOperand() != StartValue || + !UpperGEP->isInBounds()) + return; + + MapVector UpperVariableOffsets; + APInt UpperConstantOffset(StepOffset.getBitWidth(), 0); + const DataLayout &DL = BB.getModule()->getDataLayout(); + if (!UpperGEP->collectOffset(DL, StepOffset.getBitWidth(), + UpperVariableOffsets, UpperConstantOffset)) + return; + // All variable offsets and the constant offset have to be a multiple of the + // step. + if (!UpperConstantOffset.urem(StepOffset).isZero() || + any_of(UpperVariableOffsets, [&StepOffset](const auto &P) { + return !P.second.urem(StepOffset).isZero(); + })) + return; + } + + // AR may wrap. Add PN >= StartValue conditional on StartValue <= B which + // guarantees that the loop exits before wrapping in combination with the + // restrictions on B and the step above. + WorkList.push_back(FactOrCheck::getConditionFact( + DTN, CmpInst::ICMP_UGE, PN, StartValue, + ConditionTy(CmpInst::ICMP_ULE, StartValue, B))); + WorkList.push_back(FactOrCheck::getConditionFact( + DTN, CmpInst::ICMP_ULT, PN, B, + ConditionTy(CmpInst::ICMP_ULE, StartValue, B))); +} + void State::addInfoFor(BasicBlock &BB) { + addInfoForInductions(BB); + // True as long as long as the current instruction is guaranteed to execute. bool GuaranteedToExecute = true; // Queue conditions and assumes. @@ -1179,6 +1296,7 @@ FactOrCheck &CB, ConstraintInfo &Info, Module *ReproducerModule, SmallVectorImpl &ReproducerCondStack, SmallVectorImpl &DFSInStack) { + CmpInst::Predicate Pred; Value *A, *B; Instruction *And = CB.getContextInst(); @@ -1322,7 +1440,8 @@ return Changed; } -static bool eliminateConstraints(Function &F, DominatorTree &DT, +static bool eliminateConstraints(Function &F, DominatorTree &DT, LoopInfo &LI, + ScalarEvolution &SE, OptimizationRemarkEmitter &ORE) { bool Changed = false; DT.updateDFSNumbers(); @@ -1330,7 +1449,7 @@ for (Value &Arg : F.args()) FunctionArgs.push_back(&Arg); ConstraintInfo Info(F.getParent()->getDataLayout(), FunctionArgs); - State S(DT); + State S(DT, LI, SE); std::unique_ptr ReproducerModule( DumpReproducers ? new Module(F.getName(), F.getContext()) : nullptr); @@ -1428,6 +1547,10 @@ } auto AddFact = [&](CmpInst::Predicate Pred, Value *A, Value *B) { + LLVM_DEBUG(dbgs() << "fact to add to the system: " + << CmpInst::getPredicateName(Pred) << " "; + A->printAsOperand(dbgs()); dbgs() << ", "; + B->printAsOperand(dbgs()); dbgs() << "\n"); if (Info.getCS(CmpInst::isSigned(Pred)).size() > MaxRows) { LLVM_DEBUG( dbgs() @@ -1475,6 +1598,9 @@ Pred = CB.Cond.Pred; A = CB.Cond.Op0; B = CB.Cond.Op1; + if (CB.DoesHold.Pred != CmpInst::BAD_ICMP_PREDICATE && + !Info.doesHold(CB.DoesHold.Pred, CB.DoesHold.Op0, CB.DoesHold.Op1)) + continue; } else { bool Matched = match(CB.Inst, m_Intrinsic( m_ICmp(Pred, m_Value(A), m_Value(B)))); @@ -1511,12 +1637,16 @@ PreservedAnalyses ConstraintEliminationPass::run(Function &F, FunctionAnalysisManager &AM) { auto &DT = AM.getResult(F); + auto &LI = AM.getResult(F); + auto &SE = AM.getResult(F); auto &ORE = AM.getResult(F); - if (!eliminateConstraints(F, DT, ORE)) + if (!eliminateConstraints(F, DT, LI, SE, ORE)) return PreservedAnalyses::all(); PreservedAnalyses PA; PA.preserve(); + PA.preserve(); + PA.preserve(); PA.preserveSet(); return PA; } diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll --- a/llvm/test/Other/new-pm-defaults.ll +++ b/llvm/test/Other/new-pm-defaults.ll @@ -162,10 +162,12 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass -; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O1-NEXT: Running analysis: LoopAnalysis ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-lto-defaults.ll b/llvm/test/Other/new-pm-lto-defaults.ll --- a/llvm/test/Other/new-pm-lto-defaults.ll +++ b/llvm/test/Other/new-pm-lto-defaults.ll @@ -81,6 +81,8 @@ ; CHECK-O23SZ-NEXT: Running pass: InstCombinePass ; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis on foo +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis on foo ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass ; CHECK-O23SZ-NEXT: Running analysis: LazyValueAnalysis ; CHECK-O23SZ-NEXT: Running pass: SROAPass on foo @@ -93,11 +95,9 @@ ; CHECK-O23SZ-NEXT: Invalidating analysis: AAManager on foo ; CHECK-O23SZ-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) ; CHECK-O23SZ-NEXT: Running pass: LoopSimplifyPass on foo -; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis on foo ; CHECK-O23SZ-NEXT: Running pass: LCSSAPass on foo ; CHECK-O23SZ-NEXT: Running analysis: MemorySSAAnalysis on foo ; CHECK-O23SZ-NEXT: Running analysis: AAManager on foo -; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis on foo ; CHECK-O23SZ-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O23SZ-NEXT: Running pass: LICMPass on loop ; CHECK-O23SZ-NEXT: Running pass: GVNPass on foo diff --git a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-postlink-defaults.ll @@ -99,10 +99,12 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass -; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O1-NEXT: Running analysis: LoopAnalysis ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll @@ -88,9 +88,10 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll @@ -95,9 +95,10 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-prelink-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-defaults.ll @@ -131,10 +131,12 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass -; CHECK-O-NEXT: Running analysis: LoopAnalysis +; CHECK-O1-NEXT: Running analysis: LoopAnalysis ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll @@ -134,9 +134,10 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll @@ -100,9 +100,10 @@ ; CHECK-O-NEXT: Running pass: SimplifyCFGPass ; CHECK-O-NEXT: Running pass: ReassociatePass ; CHECK-O23SZ-NEXT: Running pass: ConstraintEliminationPass +; CHECK-O23SZ-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running pass: LoopSimplifyPass ; CHECK-O-NEXT: Running pass: LCSSAPass -; CHECK-O-NEXT: Running analysis: ScalarEvolutionAnalysis +; CHECK-O1-NEXT: Running analysis: ScalarEvolutionAnalysis ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy ; CHECK-O-NEXT: Running pass: LoopInstSimplifyPass ; CHECK-O-NEXT: Running pass: LoopSimplifyCFGPass diff --git a/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll b/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll --- a/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll +++ b/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll @@ -12,6 +12,9 @@ ; CHECK-NEXT: Running analysis: TargetIRAnalysis on ssub_no_overflow_due_to_or_conds ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on ssub_no_overflow_due_to_or_conds ; CHECK-NEXT: Running pass: ConstraintEliminationPass on ssub_no_overflow_due_to_or_conds +; CHECK-NEXT: Running analysis: LoopAnalysis on ssub_no_overflow_due_to_or_conds +; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on ssub_no_overflow_due_to_or_conds +; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on ssub_no_overflow_due_to_or_conds ; CHECK-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on ssub_no_overflow_due_to_or_conds ; CHECK-NEXT: Invalidating analysis: DemandedBitsAnalysis on ssub_no_overflow_due_to_or_conds ; CHECK-NEXT: Running pass: RequireAnalysisPass @@ -23,6 +26,9 @@ ; CHECK-NEXT: Running analysis: TargetIRAnalysis on uge_zext ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on uge_zext ; CHECK-NEXT: Running pass: ConstraintEliminationPass on uge_zext +; CHECK-NEXT: Running analysis: LoopAnalysis on uge_zext +; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on uge_zext +; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on uge_zext ; CHECK-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on uge_zext ; CHECK-NEXT: Invalidating analysis: DemandedBitsAnalysis on uge_zext ; CHECK-NEXT: Running pass: RequireAnalysisPass diff --git a/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll b/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll --- a/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll +++ b/llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll @@ -407,16 +407,14 @@ ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body: ; CHECK-NEXT: [[GEP_IV:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[IV]] -; CHECK-NEXT: [[CMP_IV_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV]] ; CHECK-NEXT: [[CMP_IV_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV]] -; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP_IV_LOWER]], [[CMP_IV_UPPER]] +; CHECK-NEXT: [[OR:%.*]] = or i1 false, [[CMP_IV_UPPER]] ; CHECK-NEXT: br i1 [[OR]], label [[TRAP]], label [[FOR_BODY_1:%.*]] ; CHECK: for.body.1: ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i16 [[IV]], 1 ; CHECK-NEXT: [[GEP_IV_1:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[ADD]] -; CHECK-NEXT: [[CMP_IV_1_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV_1]] ; CHECK-NEXT: [[CMP_IV_1_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV_1]] -; CHECK-NEXT: [[OR_1:%.*]] = or i1 [[CMP_IV_1_LOWER]], [[CMP_IV_1_UPPER]] +; CHECK-NEXT: [[OR_1:%.*]] = or i1 false, [[CMP_IV_1_UPPER]] ; CHECK-NEXT: br i1 [[OR_1]], label [[TRAP]], label [[FOR_LATCH]] ; CHECK: for.latch: ; CHECK-NEXT: store i8 0, ptr [[GEP_IV]], align 4 @@ -491,16 +489,12 @@ ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body: ; CHECK-NEXT: [[GEP_IV:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[IV]] -; CHECK-NEXT: [[CMP_IV_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV]] -; CHECK-NEXT: [[CMP_IV_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV]] -; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP_IV_LOWER]], [[CMP_IV_UPPER]] +; CHECK-NEXT: [[OR:%.*]] = or i1 false, false ; CHECK-NEXT: br i1 [[OR]], label [[TRAP]], label [[FOR_BODY_1:%.*]] ; CHECK: for.body.1: ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i16 [[IV]], 1 ; CHECK-NEXT: [[GEP_IV_1:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[ADD]] -; CHECK-NEXT: [[CMP_IV_1_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV_1]] -; CHECK-NEXT: [[CMP_IV_1_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV_1]] -; CHECK-NEXT: [[OR_1:%.*]] = or i1 [[CMP_IV_1_LOWER]], [[CMP_IV_1_UPPER]] +; CHECK-NEXT: [[OR_1:%.*]] = or i1 false, false ; CHECK-NEXT: br i1 [[OR_1]], label [[TRAP]], label [[FOR_LATCH]] ; CHECK: for.latch: ; CHECK-NEXT: store i8 0, ptr [[GEP_IV]], align 4 @@ -577,16 +571,14 @@ ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] ; CHECK: for.body: ; CHECK-NEXT: [[GEP_IV:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[IV]] -; CHECK-NEXT: [[CMP_IV_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV]] ; CHECK-NEXT: [[CMP_IV_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV]] -; CHECK-NEXT: [[OR:%.*]] = or i1 [[CMP_IV_LOWER]], [[CMP_IV_UPPER]] +; CHECK-NEXT: [[OR:%.*]] = or i1 false, [[CMP_IV_UPPER]] ; CHECK-NEXT: br i1 [[OR]], label [[TRAP]], label [[FOR_BODY_1:%.*]] ; CHECK: for.body.1: ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i16 [[IV]], 1 ; CHECK-NEXT: [[GEP_IV_1:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i16 [[ADD]] -; CHECK-NEXT: [[CMP_IV_1_LOWER:%.*]] = icmp ugt ptr [[LOWER]], [[GEP_IV_1]] ; CHECK-NEXT: [[CMP_IV_1_UPPER:%.*]] = icmp ule ptr [[UPPER]], [[GEP_IV_1]] -; CHECK-NEXT: [[OR_1:%.*]] = or i1 [[CMP_IV_1_LOWER]], [[CMP_IV_1_UPPER]] +; CHECK-NEXT: [[OR_1:%.*]] = or i1 false, [[CMP_IV_1_UPPER]] ; CHECK-NEXT: br i1 [[OR_1]], label [[TRAP]], label [[FOR_LATCH]] ; CHECK: for.latch: ; CHECK-NEXT: store i8 0, ptr [[GEP_IV]], align 4 diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis-wrapping.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis-wrapping.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis-wrapping.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis-wrapping.ll @@ -55,8 +55,7 @@ ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_2]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge i8 [[IV]], -1 -; CHECK-NEXT: call void @use.i1(i1 [[T_1]]) +; CHECK-NEXT: call void @use.i1(i1 true) ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i8 [[IV]], 1 ; CHECK-NEXT: br label [[LOOP_HEADER]] ; CHECK: exit: @@ -97,8 +96,7 @@ ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_2]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge i8 [[IV]], -1 -; CHECK-NEXT: call void @use.i1(i1 [[T_1]]) +; CHECK-NEXT: call void @use.i1(i1 true) ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i8 [[IV]], 1 ; CHECK-NEXT: br label [[LOOP_HEADER]] ; CHECK: exit: @@ -139,8 +137,7 @@ ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_2]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: -; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[IV]], 1 -; CHECK-NEXT: call void @use.i1(i1 [[T_1]]) +; CHECK-NEXT: call void @use.i1(i1 false) ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i8 [[IV]], 1 ; CHECK-NEXT: br label [[LOOP_HEADER]] ; CHECK: exit: @@ -222,8 +219,7 @@ ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_2]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: -; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[IV]], [[A]] -; CHECK-NEXT: call void @use.i1(i1 [[T_1]]) +; CHECK-NEXT: call void @use.i1(i1 false) ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i8 [[IV]], 1 ; CHECK-NEXT: br label [[LOOP_HEADER]] ; CHECK: exit: @@ -263,8 +259,7 @@ ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_2]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: -; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[IV]], [[A]] -; CHECK-NEXT: call void @use.i1(i1 [[T_1]]) +; CHECK-NEXT: call void @use.i1(i1 false) ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i8 [[IV]], 2 ; CHECK-NEXT: br label [[LOOP_HEADER]] ; CHECK: exit: diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-int-phis.ll @@ -20,9 +20,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq i16 [[IV]], [[LEN]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge i16 [[IV]], 0 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i16 [[IV]], [[A]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(i16 [[IV]]) @@ -112,9 +111,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq i16 [[IV]], [[LEN]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge i16 [[IV]], 0 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i16 [[IV]], [[A]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(i16 [[IV]]) diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-constant-upper-offset.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-constant-upper-offset.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-constant-upper-offset.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-constant-upper-offset.ll @@ -17,9 +17,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -62,9 +60,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -107,9 +103,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -152,9 +146,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -197,9 +190,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -245,9 +237,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -297,9 +287,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -349,9 +337,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -401,9 +387,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -453,9 +438,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -505,9 +489,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-custom-datalayout.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-custom-datalayout.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-custom-datalayout.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-custom-datalayout.ll @@ -21,9 +21,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -73,9 +72,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -125,9 +122,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -177,9 +172,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -232,9 +225,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -291,9 +283,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -350,9 +340,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -409,9 +397,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-early-exits.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-early-exits.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-early-exits.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-early-exits.ll @@ -25,9 +25,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -84,9 +82,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -142,9 +139,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[END]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -199,9 +194,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[END]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -259,9 +253,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -566,9 +559,8 @@ ; CHECK-NEXT: [[C_0:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_0]], label [[EXIT]], label [[THEN:%.*]] ; CHECK: then: -; CHECK-NEXT: [[C_2:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[C_3:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_2]], [[C_3]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[C_3]] ; CHECK-NEXT: call void @use.i1(i1 [[AND]]) ; CHECK-NEXT: br label [[LOOP_LATCH]] ; CHECK: loop.latch: @@ -932,9 +924,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -991,9 +981,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-struct-types.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-struct-types.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-struct-types.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis-struct-types.ll @@ -22,9 +22,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -74,9 +72,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -126,9 +122,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -181,9 +176,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -240,9 +233,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -299,9 +290,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -358,9 +348,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -417,9 +405,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -476,9 +462,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -535,9 +520,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -594,9 +577,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -653,9 +635,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -712,9 +692,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -771,9 +749,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -830,9 +806,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -889,9 +863,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -948,9 +920,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -1007,9 +977,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -1125,9 +1094,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -1184,9 +1152,7 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -1243,9 +1209,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond() ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_NEXT:%.*]], label [[EXIT]] ; CHECK: loop.next: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) diff --git a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis.ll b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis.ll --- a/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis.ll +++ b/llvm/test/Transforms/ConstraintElimination/monotonic-pointer-phis.ll @@ -22,9 +22,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -74,9 +72,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -124,9 +120,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -173,9 +167,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -225,9 +217,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -276,9 +267,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[END]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[END]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -326,9 +315,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[END]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[END]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -374,9 +362,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT:%.*]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[C_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[C_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[C_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -580,9 +567,7 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[C_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] -; CHECK-NEXT: [[C_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, true ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -900,9 +885,8 @@ ; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: br i1 [[AND]], label [[LOOP_LATCH]], label [[EXIT]] ; CHECK: loop.latch: ; CHECK-NEXT: call void @use(ptr [[PTR_IV]]) @@ -952,9 +936,8 @@ ; CHECK-NEXT: [[C_1:%.*]] = icmp eq ptr [[PTR_IV]], [[UPPER]] ; CHECK-NEXT: br i1 [[C_1]], label [[EXIT]], label [[FOR_BODY:%.*]] ; CHECK: for.body: -; CHECK-NEXT: [[T_1:%.*]] = icmp uge ptr [[PTR_IV]], [[START]] ; CHECK-NEXT: [[T_2:%.*]] = icmp ult ptr [[PTR_IV]], [[UPPER]] -; CHECK-NEXT: [[AND:%.*]] = and i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[AND:%.*]] = and i1 true, [[T_2]] ; CHECK-NEXT: call void @use.i1(i1 [[AND]]) ; CHECK-NEXT: br label [[LOOP_LATCH]] ; CHECK: loop.latch: diff --git a/llvm/test/Transforms/PhaseOrdering/loop-access-checks.ll b/llvm/test/Transforms/PhaseOrdering/loop-access-checks.ll --- a/llvm/test/Transforms/PhaseOrdering/loop-access-checks.ll +++ b/llvm/test/Transforms/PhaseOrdering/loop-access-checks.ll @@ -26,8 +26,8 @@ ; CHECK-NEXT: [[ELEMS_COERCE_FCA_1_EXTRACT:%.*]] = extractvalue [2 x i64] [[ELEMS_COERCE]], 1 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 [[ELEMS_COERCE_FCA_1_EXTRACT]] ; CHECK-NEXT: [[CMP_NOT_I_I_I_I:%.*]] = icmp slt i64 [[ELEMS_COERCE_FCA_1_EXTRACT]], 0 -; CHECK-NEXT: br i1 [[CMP_NOT_I_I_I_I]], label [[ERROR:%.*]], label [[FOR_COND_PREHEADER:%.*]] -; CHECK: for.cond.preheader: +; CHECK-NEXT: br i1 [[CMP_NOT_I_I_I_I]], label [[ERROR:%.*]], label [[FOR_COND_PREHEADER_SPLIT:%.*]] +; CHECK: for.cond.preheader.split: ; CHECK-NEXT: [[CMP_I_NOT2:%.*]] = icmp eq i64 [[ELEMS_COERCE_FCA_1_EXTRACT]], 0 ; CHECK-NEXT: br i1 [[CMP_I_NOT2]], label [[COMMON_RET:%.*]], label [[FOR_BODY:%.*]] ; CHECK: common.ret: @@ -36,10 +36,7 @@ ; CHECK-NEXT: tail call void @error() ; CHECK-NEXT: br label [[COMMON_RET]] ; CHECK: for.body: -; CHECK-NEXT: [[__BEGIN1_SROA_0_03:%.*]] = phi ptr [ [[INCDEC_PTR_I:%.*]], [[FOR_LATCH:%.*]] ], [ [[TMP0]], [[FOR_COND_PREHEADER]] ] -; CHECK-NEXT: [[CMP2_I_I:%.*]] = icmp ult ptr [[__BEGIN1_SROA_0_03]], [[ADD_PTR_I]] -; CHECK-NEXT: br i1 [[CMP2_I_I]], label [[FOR_LATCH]], label [[ERROR]] -; CHECK: for.latch: +; CHECK-NEXT: [[__BEGIN1_SROA_0_03:%.*]] = phi ptr [ [[INCDEC_PTR_I:%.*]], [[FOR_BODY]] ], [ [[TMP0]], [[FOR_COND_PREHEADER_SPLIT]] ] ; CHECK-NEXT: tail call void @use(ptr noundef nonnull align 4 dereferenceable(4) [[__BEGIN1_SROA_0_03]]) ; CHECK-NEXT: [[INCDEC_PTR_I]] = getelementptr inbounds i32, ptr [[__BEGIN1_SROA_0_03]], i64 1 ; CHECK-NEXT: [[CMP_I_NOT:%.*]] = icmp eq ptr [[INCDEC_PTR_I]], [[ADD_PTR_I]]