diff options
63 files changed, 530 insertions, 780 deletions
diff --git a/polly/include/polly/CodeGen/IslAst.h b/polly/include/polly/CodeGen/IslAst.h index 1310e222fe7..0ee9dffa20e 100644 --- a/polly/include/polly/CodeGen/IslAst.h +++ b/polly/include/polly/CodeGen/IslAst.h @@ -53,15 +53,22 @@ public: __isl_give isl_ast_node *getAst(); - /// @brief Build the run-time condition for the current scop. + /// @brief Get the run-time conditions for the Scop. + __isl_give isl_ast_expr *getRunCondition(); + + /// @brief Build run-time condition for scop. + /// + /// @param S The scop to build the condition for. + /// @param Build The isl_build object to use to build the condition. /// /// @returns An ast expression that describes the necessary run-time check. - __isl_give isl_ast_expr *buildRunCondition(); + static isl_ast_expr *buildRunCondition(Scop *S, + __isl_keep isl_ast_build *Build); private: Scop *S; isl_ast_node *Root; - isl_ast_build *Build; + isl_ast_expr *RunCondition; std::shared_ptr<isl_ctx> Ctx; IslAst(Scop *Scop); diff --git a/polly/include/polly/CodeGen/IslExprBuilder.h b/polly/include/polly/CodeGen/IslExprBuilder.h index bd9806d08cc..3e112829e50 100644 --- a/polly/include/polly/CodeGen/IslExprBuilder.h +++ b/polly/include/polly/CodeGen/IslExprBuilder.h @@ -69,17 +69,24 @@ namespace polly { /// When lowering to LLVM-IR we need to chose both the size of the data type and /// the sign of the operations we use. /// -/// We use the minimal necessary bit width for the generated code and always -/// interpret values as signed. If operations might overflow (add/sub/mul) we -/// will try to adjust the types in order to ensure a non-wrapping computation. -/// If the type adjustment is not possible (e.g., the necessary type is bigger -/// than the type value of --polly-max-expr-bit-width) we will use assumptions -/// to verify the computation will not wrap. However, for run-time checks we -/// cannot build assumptions but instead utilize overflow tracking intrinsics. +/// At the moment, we hardcode i64 bit signed computations. Our experience has +/// shown that 64 bit are generally large enough for the loop bounds that appear +/// in the wild. Signed computations are needed, as loop bounds may become +/// negative. /// /// It is possible to track overflows that occured in the generated IR. See the /// description of @see OverflowState for more information. /// +/// FIXME: Hardcoding sizes can cause issues: +/// +/// - On embedded systems and especially for high-level-synthesis 64 bit +/// computations are very costly. +/// +/// The right approach is to compute the minimal necessary bitwidth and +/// signedness for each subexpression during in the isl AST generation and +/// to use this information in our IslAstGenerator. Preliminary patches are +/// available, but have not been committed yet. +/// class IslExprBuilder { public: /// @brief A map from isl_ids to llvm::Values. @@ -107,39 +114,13 @@ public: /// @return The llvm::Value* containing the result of the computation. llvm::Value *create(__isl_take isl_ast_expr *Expr); - /// @brief Unify the types of @p V0 and @p V1 in-place. - /// - /// The values @p V0 and @p V1 will be updated in place such that - /// type(V0) == type(V1) == MaxType - /// where MaxType is the larger type of the initial @p V0 and @p V1. - void unifyTypes(llvm::Value *&V0, llvm::Value *&V1) { - unifyTypes(V0, V1, V1); - } - - /// @brief Unify the types of @p V0, @p V1 and @p V2 in-place. - /// - /// The same as unifyTypes above but for three values instead of two. - void unifyTypes(llvm::Value *&V0, llvm::Value *&V1, llvm::Value *&V2); - - /// @brief Adjust the types of @p V0 and @p V1 in-place. + /// @brief Return the largest of two types. /// - /// @param V0 One operand of an operation. - /// @param V1 Another operand of an operation. - /// @param RequiredBitWidth The bit with required for a safe operation. + /// @param T1 The first type. + /// @param T2 The second type. /// - /// @return True if the new type has at least @p RequiredBitWidth bits. - bool adjustTypesForSafeComputation(llvm::Value *&V0, llvm::Value *&V1, - unsigned RequiredBitWidth); - - /// @brief Unify the types of @p LHS and @p RHS in-place for an add/sub op. - /// - /// @return False if an additive operation of @p LHS and @p RHS can overflow. - bool adjustTypesForSafeAddition(llvm::Value *&LHS, llvm::Value *&RHS); - - /// @brief Unify the types of @p LHS and @p RHS in-place for a mul op. - /// - /// @return False if a multiplication of @p LHS and @p RHS can overflow. - bool adjustTypesForSafeMultiplication(llvm::Value *&LHS, llvm::Value *&RHS); + /// @return The largest of the two types. + llvm::Type *getWidestType(llvm::Type *T1, llvm::Type *T2); /// @brief Return the type with which this expression should be computed. /// @@ -204,9 +185,6 @@ private: llvm::Value *createOpAddressOf(__isl_take isl_ast_expr *Expr); llvm::Value *createAccessAddress(__isl_take isl_ast_expr *Expr); - /// @brief Supported kinds of division. - enum DivisionMode { DM_SIGNED, DM_UNSIGNED, DM_FLOORED }; - /// @brief Create a binary operation @p Opc and track overflows if requested. /// /// @param OpC The binary operation that should be performed [Add/Sub/Mul]. @@ -219,15 +197,6 @@ private: llvm::Value *LHS, llvm::Value *RHS, const llvm::Twine &Name); - /// @brief Create a division and adjust the result type if possible. - /// - /// @param LHS The left operand. - /// @param RHS The right operand. - /// @param DM The requested division mode. - /// - /// @return A value that represents the result of the division. - llvm::Value *createDiv(llvm::Value *LHS, llvm::Value *RHS, DivisionMode DM); - /// @brief Create an addition and track overflows if requested. /// /// @param LHS The left operand. diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp index b434144a686..ce1098fa444 100644 --- a/polly/lib/CodeGen/CodeGeneration.cpp +++ b/polly/lib/CodeGen/CodeGeneration.cpp @@ -191,12 +191,7 @@ public: } else { NodeBuilder.addParameters(S.getContext()); - SplitBlock = Builder.GetInsertBlock(); - Builder.SetInsertPoint(&StartBlock->front()); - NodeBuilder.create(AstRoot); - - Builder.SetInsertPoint(SplitBlock->getTerminator()); ExprBuilder.setTrackOverflow(true); Value *RTC = buildRTC(Builder, ExprBuilder); Value *OverflowHappened = Builder.CreateNot( @@ -204,7 +199,10 @@ public: RTC = Builder.CreateAnd(RTC, OverflowHappened, "polly.rtc.result"); ExprBuilder.setTrackOverflow(false); - SplitBlock->getTerminator()->setOperand(0, RTC); + Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC); + Builder.SetInsertPoint(&StartBlock->front()); + + NodeBuilder.create(AstRoot); NodeBuilder.finalizeSCoP(S); fixRegionInfo(EnteringBB->getParent(), R->getParent()); diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp index f5249548097..5bcd784dacd 100644 --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -331,7 +331,8 @@ buildCondition(__isl_keep isl_ast_build *Build, const Scop::MinMaxAccessTy *It0, return NonAliasGroup; } -__isl_give isl_ast_expr *IslAst::buildRunCondition() { +__isl_give isl_ast_expr * +IslAst::buildRunCondition(Scop *S, __isl_keep isl_ast_build *Build) { isl_ast_expr *RunCondition; // The conditions that need to be checked at run-time for this scop are @@ -392,7 +393,8 @@ static bool benefitsFromPolly(Scop *Scop, bool PerformParallelTest) { } IslAst::IslAst(Scop *Scop) - : S(Scop), Root(nullptr), Build(nullptr), Ctx(Scop->getSharedIslCtx()) {} + : S(Scop), Root(nullptr), RunCondition(nullptr), + Ctx(Scop->getSharedIslCtx()) {} void IslAst::init(const Dependences &D) { bool PerformParallelTest = PollyParallel || DetectParallel || @@ -405,6 +407,7 @@ void IslAst::init(const Dependences &D) { isl_ctx *Ctx = S->getIslCtx(); isl_options_set_ast_build_atomic_upper_bound(Ctx, true); isl_options_set_ast_build_detect_min_max(Ctx, true); + isl_ast_build *Build; AstBuildUserInfo BuildInfo; if (UseContext) @@ -430,7 +433,11 @@ void IslAst::init(const Dependences &D) { &BuildInfo); } + RunCondition = buildRunCondition(S, Build); + Root = isl_ast_build_node_from_schedule(Build, S->getScheduleTree()); + + isl_ast_build_free(Build); } IslAst *IslAst::create(Scop *Scop, const Dependences &D) { @@ -441,10 +448,13 @@ IslAst *IslAst::create(Scop *Scop, const Dependences &D) { IslAst::~IslAst() { isl_ast_node_free(Root); - isl_ast_build_free(Build); + isl_ast_expr_free(RunCondition); } __isl_give isl_ast_node *IslAst::getAst() { return isl_ast_node_copy(Root); } +__isl_give isl_ast_expr *IslAst::getRunCondition() { + return isl_ast_expr_copy(RunCondition); +} void IslAstInfo::releaseMemory() { if (Ast) { @@ -470,7 +480,7 @@ bool IslAstInfo::runOnScop(Scop &Scop) { __isl_give isl_ast_node *IslAstInfo::getAst() const { return Ast->getAst(); } __isl_give isl_ast_expr *IslAstInfo::getRunCondition() const { - return Ast->buildRunCondition(); + return Ast->getRunCondition(); } IslAstUserPayload *IslAstInfo::getNodePayload(__isl_keep isl_ast_node *Node) { diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp index 069e23df7b5..62c166f7b66 100644 --- a/polly/lib/CodeGen/IslExprBuilder.cpp +++ b/polly/lib/CodeGen/IslExprBuilder.cpp @@ -39,12 +39,6 @@ static cl::opt<OverflowTrackingChoice> OTMode( clEnumValEnd), cl::Hidden, cl::init(OT_REQUEST), cl::ZeroOrMore, cl::cat(PollyCategory)); -// @TODO This should actually be derived from the DataLayout. -static cl::opt<unsigned> PollyMaxAllowedBitWidth( - "polly-max-expr-bit-width", - cl::desc("The maximal bit with for generated expressions."), cl::Hidden, - cl::ZeroOrMore, cl::init(64), cl::cat(PollyCategory)); - IslExprBuilder::IslExprBuilder(Scop &S, PollyIRBuilder &Builder, IDToValueTy &IDToValue, ValueMapT &GlobalMap, const DataLayout &DL, ScalarEvolution &SE, @@ -80,23 +74,8 @@ Value *IslExprBuilder::getOverflowState() const { Value *IslExprBuilder::createBinOp(BinaryOperator::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name) { - // Flag that is true if the computation cannot overflow. - bool IsSafeToCompute = false; - switch (Opc) { - case Instruction::Add: - case Instruction::Sub: - IsSafeToCompute = adjustTypesForSafeAddition(LHS, RHS); - break; - case Instruction::Mul: - IsSafeToCompute = adjustTypesForSafeMultiplication(LHS, RHS); - break; - default: - llvm_unreachable("Unknown binary operator!"); - } - - // Handle the plain operation (without overflow tracking or a safe - // computation) first. - if (!OverflowState || (IsSafeToCompute && (OTMode != OT_ALWAYS))) { + // Handle the plain operation (without overflow tracking) first. + if (!OverflowState) { switch (Opc) { case Instruction::Add: return Builder.CreateNSWAdd(LHS, RHS, Name); @@ -158,7 +137,7 @@ Value *IslExprBuilder::createMul(Value *LHS, Value *RHS, const Twine &Name) { return createBinOp(Instruction::Mul, LHS, RHS, Name); } -static Type *getWidestType(Type *T1, Type *T2) { +Type *IslExprBuilder::getWidestType(Type *T1, Type *T2) { assert(isa<IntegerType>(T1) && isa<IntegerType>(T2)); if (T1->getPrimitiveSizeInBits() < T2->getPrimitiveSizeInBits()) @@ -167,63 +146,23 @@ static Type *getWidestType(Type *T1, Type *T2) { return T1; } -void IslExprBuilder::unifyTypes(Value *&V0, Value *&V1, Value *&V2) { - auto *T0 = V0->getType(); - auto *T1 = V1->getType(); - auto *T2 = V2->getType(); - if (T0 == T1 && T1 == T2) - return; - auto *MaxT = getWidestType(T0, T1); - MaxT = getWidestType(MaxT, T2); - V0 = Builder.CreateSExt(V0, MaxT); - V1 = Builder.CreateSExt(V1, MaxT); - V2 = Builder.CreateSExt(V2, MaxT); -} - -bool IslExprBuilder::adjustTypesForSafeComputation(Value *&LHS, Value *&RHS, - unsigned RequiredBitWidth) { - unsigned LBitWidth = LHS->getType()->getPrimitiveSizeInBits(); - unsigned RBitWidth = RHS->getType()->getPrimitiveSizeInBits(); - unsigned MaxUsedBitWidth = std::max(LBitWidth, RBitWidth); - - // @TODO For now use the maximal bit width if the required one is to large but - // note that this is not sound. - unsigned MaxAllowedBitWidth = PollyMaxAllowedBitWidth; - unsigned NewBitWidth = - std::max(MaxUsedBitWidth, std::min(MaxAllowedBitWidth, RequiredBitWidth)); - - Type *Ty = Builder.getIntNTy(NewBitWidth); - LHS = Builder.CreateSExt(LHS, Ty); - RHS = Builder.CreateSExt(RHS, Ty); - - // If the new bit width is not large enough the computation is not sound. - return NewBitWidth == RequiredBitWidth; -} - -bool IslExprBuilder::adjustTypesForSafeAddition(Value *&LHS, Value *&RHS) { - unsigned LBitWidth = LHS->getType()->getPrimitiveSizeInBits(); - unsigned RBitWidth = RHS->getType()->getPrimitiveSizeInBits(); - return adjustTypesForSafeComputation(LHS, RHS, - std::max(LBitWidth, RBitWidth) + 1); -} - -bool IslExprBuilder::adjustTypesForSafeMultiplication(Value *&LHS, - Value *&RHS) { - unsigned LBitWidth = LHS->getType()->getPrimitiveSizeInBits(); - unsigned RBitWidth = RHS->getType()->getPrimitiveSizeInBits(); - return adjustTypesForSafeComputation(LHS, RHS, LBitWidth + RBitWidth); -} - Value *IslExprBuilder::createOpUnary(__isl_take isl_ast_expr *Expr) { assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_minus && "Unsupported unary operation"); - auto *V = create(isl_ast_expr_get_op_arg(Expr, 0)); - assert(V->getType()->isIntegerTy() && + Value *V; + Type *MaxType = getType(Expr); + assert(MaxType->isIntegerTy() && "Unary expressions can only be created for integer types"); + V = create(isl_ast_expr_get_op_arg(Expr, 0)); + MaxType = getWidestType(MaxType, V->getType()); + + if (MaxType != V->getType()) + V = Builder.CreateSExt(V, MaxType); + isl_ast_expr_free(Expr); - return createSub(ConstantInt::getNullValue(V->getType()), V); + return createSub(ConstantInt::getNullValue(MaxType), V); } Value *IslExprBuilder::createOpNAry(__isl_take isl_ast_expr *Expr) { @@ -231,20 +170,44 @@ Value *IslExprBuilder::createOpNAry(__isl_take isl_ast_expr *Expr) { "isl ast expression not of type isl_ast_op"); assert(isl_ast_expr_get_op_n_arg(Expr) >= 2 && "We need at least two operands in an n-ary operation"); - assert((isl_ast_expr_get_op_type(Expr) == isl_ast_op_max || - isl_ast_expr_get_op_type(Expr) == isl_ast_op_min) && - "This is no n-ary isl ast expression"); - - bool IsMax = isl_ast_expr_get_op_type(Expr) == isl_ast_op_max; - auto Pred = IsMax ? CmpInst::ICMP_SGT : CmpInst::ICMP_SLT; - auto *V = create(isl_ast_expr_get_op_arg(Expr, 0)); - - for (int i = 1; i < isl_ast_expr_get_op_n_arg(Expr); ++i) { - auto *OpV = create(isl_ast_expr_get_op_arg(Expr, i)); - unifyTypes(V, OpV); - V = Builder.CreateSelect(Builder.CreateICmp(Pred, V, OpV), V, OpV); + + Value *V; + + V = create(isl_ast_expr_get_op_arg(Expr, 0)); + + for (int i = 0; i < isl_ast_expr_get_op_n_arg(Expr); ++i) { + Value *OpV; + OpV = create(isl_ast_expr_get_op_arg(Expr, i)); + + Type *Ty = getWidestType(V->getType(), OpV->getType()); + + if (Ty != OpV->getType()) + OpV = Builder.CreateSExt(OpV, Ty); + + if (Ty != V->getType()) + V = Builder.CreateSExt(V, Ty); + + switch (isl_ast_expr_get_op_type(Expr)) { + default: + llvm_unreachable("This is no n-ary isl ast expression"); + + case isl_ast_op_max: { + Value *Cmp = Builder.CreateICmpSGT(V, OpV); + V = Builder.CreateSelect(Cmp, V, OpV); + continue; + } + case isl_ast_op_min: { + Value *Cmp = Builder.CreateICmpSLT(V, OpV); + V = Builder.CreateSelect(Cmp, V, OpV); + continue; + } + } } + // TODO: We can truncate the result, if it fits into a smaller type. This can + // help in cases where we have larger operands (e.g. i67) but the result is + // known to fit into i64. Without the truncation, the larger i67 type may + // force all subsequent operations to be performed on a non-native type. isl_ast_expr_free(Expr); return V; } @@ -287,8 +250,18 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { assert(NextIndex->getType()->isIntegerTy() && "Access index should be an integer"); - IndexOp = !IndexOp ? NextIndex : createAdd(IndexOp, NextIndex, - "polly.access.add." + BaseName); + if (!IndexOp) { + IndexOp = NextIndex; + } else { + Type *Ty = getWidestType(NextIndex->getType(), IndexOp->getType()); + + if (Ty != NextIndex->getType()) + NextIndex = Builder.CreateIntCast(NextIndex, Ty, true); + if (Ty != IndexOp->getType()) + IndexOp = Builder.CreateIntCast(IndexOp, Ty, true); + + IndexOp = createAdd(IndexOp, NextIndex, "polly.access.add." + BaseName); + } // For every but the last dimension multiply the size, for the last // dimension we can exit the loop. @@ -303,6 +276,14 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { expandCodeFor(S, SE, DL, "polly", DimSCEV, DimSCEV->getType(), &*Builder.GetInsertPoint()); + Type *Ty = getWidestType(DimSize->getType(), IndexOp->getType()); + + if (Ty != IndexOp->getType()) + IndexOp = Builder.CreateSExtOrTrunc(IndexOp, Ty, + "polly.access.sext." + BaseName); + if (Ty != DimSize->getType()) + DimSize = Builder.CreateSExtOrTrunc(DimSize, Ty, + "polly.access.sext." + BaseName); IndexOp = createMul(IndexOp, DimSize, "polly.access.mul." + BaseName); } @@ -318,50 +299,9 @@ Value *IslExprBuilder::createOpAccess(isl_ast_expr *Expr) { return Builder.CreateLoad(Addr, Addr->getName() + ".load"); } -Value *IslExprBuilder::createDiv(Value *LHS, Value *RHS, DivisionMode DM) { - auto *ConstRHS = dyn_cast<ConstantInt>(RHS); - unsigned UnusedBits = 0; - Value *Res = nullptr; - - if (ConstRHS) - UnusedBits = ConstRHS->getValue().logBase2(); - - if (ConstRHS && ConstRHS->getValue().isPowerOf2() && - ConstRHS->getValue().isNonNegative()) - Res = Builder.CreateAShr(LHS, UnusedBits, "polly.div.shr"); - else if (DM == DM_SIGNED) - Res = Builder.CreateSDiv(LHS, RHS, "pexp.div", true); - else if (DM == DM_UNSIGNED) - Res = Builder.CreateUDiv(LHS, RHS, "pexp.p_div_q"); - else { - assert(DM == DM_FLOORED); - // TODO: Review code and check that this calculation does not yield - // incorrect overflow in some bordercases. - // - // floord(n,d) ((n < 0) ? (n - d + 1) : n) / d - Value *Sum1 = createSub(LHS, RHS, "pexp.fdiv_q.0"); - Value *One = ConstantInt::get(Sum1->getType(), 1); - Value *Sum2 = createAdd(Sum1, One, "pexp.fdiv_q.1"); - Value *Zero = ConstantInt::get(LHS->getType(), 0); - Value *isNegative = Builder.CreateICmpSLT(LHS, Zero, "pexp.fdiv_q.2"); - unifyTypes(LHS, Sum2); - Value *Dividend = - Builder.CreateSelect(isNegative, Sum2, LHS, "pexp.fdiv_q.3"); - unifyTypes(Dividend, RHS); - Res = Builder.CreateSDiv(Dividend, RHS, "pexp.fdiv_q.4"); - } - - if (UnusedBits) { - auto RequiredBits = Res->getType()->getPrimitiveSizeInBits() - UnusedBits; - Res = Builder.CreateTrunc(Res, Builder.getIntNTy(RequiredBits), - "polly.div.trunc"); - } - - return Res; -} - Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) { Value *LHS, *RHS, *Res; + Type *MaxType; isl_ast_op_type OpType; assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_op && @@ -374,25 +314,41 @@ Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) { LHS = create(isl_ast_expr_get_op_arg(Expr, 0)); RHS = create(isl_ast_expr_get_op_arg(Expr, 1)); - // For possibly overflowing operations we will later adjust types but - // for others we do it now as we will directly create the operations. + Type *LHSType = LHS->getType(); + Type *RHSType = RHS->getType(); + + MaxType = getWidestType(LHSType, RHSType); + + // Take the result into account when calculating the widest type. + // + // For operations such as '+' the result may require a type larger than + // the type of the individual operands. For other operations such as '/', the + // result type cannot be larger than the type of the individual operand. isl + // does not calculate correct types for these operations and we consequently + // exclude those operations here. switch (OpType) { case isl_ast_op_pdiv_q: case isl_ast_op_pdiv_r: case isl_ast_op_div: case isl_ast_op_fdiv_q: case isl_ast_op_zdiv_r: - unifyTypes(LHS, RHS); + // Do nothing break; case isl_ast_op_add: case isl_ast_op_sub: case isl_ast_op_mul: - // Do nothing + MaxType = getWidestType(MaxType, getType(Expr)); break; default: llvm_unreachable("This is no binary isl ast expression"); } + if (MaxType != RHS->getType()) + RHS = Builder.CreateSExt(RHS, MaxType); + + if (MaxType != LHS->getType()) + LHS = Builder.CreateSExt(LHS, MaxType); + switch (OpType) { default: llvm_unreachable("This is no binary isl ast expression"); @@ -406,22 +362,46 @@ Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) { Res = createMul(LHS, RHS); break; case isl_ast_op_div: - Res = createDiv(LHS, RHS, DM_SIGNED); + Res = Builder.CreateSDiv(LHS, RHS, "pexp.div", true); break; case isl_ast_op_pdiv_q: // Dividend is non-negative - Res = createDiv(LHS, RHS, DM_UNSIGNED); + Res = Builder.CreateUDiv(LHS, RHS, "pexp.p_div_q"); break; - case isl_ast_op_fdiv_q: // Round towards -infty - Res = createDiv(LHS, RHS, DM_FLOORED); + case isl_ast_op_fdiv_q: { // Round towards -infty + if (auto *Const = dyn_cast<ConstantInt>(RHS)) { + auto &Val = Const->getValue(); + if (Val.isPowerOf2() && Val.isNonNegative()) { + Res = Builder.CreateAShr(LHS, Val.ceilLogBase2(), "polly.fdiv_q.shr"); + break; + } + } + // TODO: Review code and check that this calculation does not yield + // incorrect overflow in some bordercases. + // + // floord(n,d) ((n < 0) ? (n - d + 1) : n) / d + Value *One = ConstantInt::get(MaxType, 1); + Value *Zero = ConstantInt::get(MaxType, 0); + Value *Sum1 = createSub(LHS, RHS, "pexp.fdiv_q.0"); + Value *Sum2 = createAdd(Sum1, One, "pexp.fdiv_q.1"); + Value *isNegative = Builder.CreateICmpSLT(LHS, Zero, "pexp.fdiv_q.2"); + Value *Dividend = + Builder.CreateSelect(isNegative, Sum2, LHS, "pexp.fdiv_q.3"); + Res = Builder.CreateSDiv(Dividend, RHS, "pexp.fdiv_q.4"); break; + } case isl_ast_op_pdiv_r: // Dividend is non-negative Res = Builder.CreateURem(LHS, RHS, "pexp.pdiv_r"); break; + case isl_ast_op_zdiv_r: // Result only compared against zero Res = Builder.CreateSRem(LHS, RHS, "pexp.zdiv_r"); break; } + // TODO: We can truncate the result, if it fits into a smaller type. This can + // help in cases where we have larger operands (e.g. i67) but the result is + // known to fit into i64. Without the truncation, the larger i67 type may + // force all subsequent operations to be performed on a non-native type. isl_ast_expr_free(Expr); return Res; } @@ -430,6 +410,7 @@ Value *IslExprBuilder::createOpSelect(__isl_take isl_ast_expr *Expr) { assert(isl_ast_expr_get_op_type(Expr) == isl_ast_op_select && "Unsupported unary isl ast expression"); Value *LHS, *RHS, *Cond; + Type *MaxType = getType(Expr); Cond = create(isl_ast_expr_get_op_arg(Expr, 0)); if (!Cond->getType()->isIntegerTy(1)) @@ -437,8 +418,17 @@ Value *IslExprBuilder::createOpSelect(__isl_take isl_ast_expr *Expr) { LHS = create(isl_ast_expr_get_op_arg(Expr, 1)); RHS = create(isl_ast_expr_get_op_arg(Expr, 2)); - unifyTypes(LHS, RHS); + MaxType = getWidestType(MaxType, LHS->getType()); + MaxType = getWidestType(MaxType, RHS->getType()); + + if (MaxType != RHS->getType()) + RHS = Builder.CreateSExt(RHS, MaxType); + + if (MaxType != LHS->getType()) + LHS = Builder.CreateSExt(LHS, MaxType); + + // TODO: Do we want to truncate the result? isl_ast_expr_free(Expr); return Builder.CreateSelect(Cond, LHS, RHS); } @@ -471,7 +461,16 @@ Value *IslExprBuilder::createOpICmp(__isl_take isl_ast_expr *Expr) { if (RHSTy->isPointerTy()) RHS = Builder.CreatePtrToInt(RHS, PtrAsIntTy); - unifyTypes(LHS, RHS); + if (LHS->getType() != RHS->getType()) { + Type *MaxType = LHS->getType(); + MaxType = getWidestType(MaxType, RHS->getType()); + + if (MaxType != RHS->getType()) + RHS = Builder.CreateSExt(RHS, MaxType); + + if (MaxType != LHS->getType()) + LHS = Builder.CreateSExt(LHS, MaxType); + } isl_ast_op_type OpType = isl_ast_expr_get_op_type(Expr); assert(OpType >= isl_ast_op_eq && OpType <= isl_ast_op_gt && @@ -677,7 +676,7 @@ Value *IslExprBuilder::createId(__isl_take isl_ast_expr *Expr) { V = IDToValue[Id]; if (!V) - V = UndefValue::get(Builder.getInt1Ty()); + V = UndefValue::get(getType(Expr)); if (V->getType()->isPointerTy()) V = Builder.CreatePtrToInt(V, Builder.getIntNTy(DL.getPointerSizeInBits())); @@ -690,12 +689,33 @@ Value *IslExprBuilder::createId(__isl_take isl_ast_expr *Expr) { return V; } +IntegerType *IslExprBuilder::getType(__isl_keep isl_ast_expr *Expr) { + // XXX: We assume i64 is large enough. This is often true, but in general + // incorrect. Also, on 32bit architectures, it would be beneficial to + // use a smaller type. We can and should directly derive this information + // during code generation. + return IntegerType::get(Builder.getContext(), 64); +} + Value *IslExprBuilder::createInt(__isl_take isl_ast_expr *Expr) { assert(isl_ast_expr_get_type(Expr) == isl_ast_expr_int && "Expression not of type isl_ast_expr_int"); + isl_val *Val; + Value *V; + APInt APValue; + IntegerType *T; + + Val = isl_ast_expr_get_val(Expr); + APValue = APIntFromVal(Val); + + auto BitWidth = APValue.getBitWidth(); + if (BitWidth <= 64) + T = getType(Expr); + else + T = Builder.getIntNTy(BitWidth); - auto *Val = isl_ast_expr_get_val(Expr); - auto *V = ConstantInt::get(Builder.getContext(), APIntFromVal(Val)); + APValue = APValue.sextOrSelf(T->getBitWidth()); + V = ConstantInt::get(T, APValue); isl_ast_expr_free(Expr); return V; diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index b73ed3f53a0..8ef6476b344 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -390,11 +390,14 @@ void IslNodeBuilder::createForVector(__isl_take isl_ast_node *For, Value *ValueLB = ExprBuilder.create(Init); Value *ValueInc = ExprBuilder.create(Inc); - CmpInst::Predicate Predicate; - auto *UB = getUpperBound(For, Predicate); - auto *ValueUB = ExprBuilder.create(UB); + Type *MaxType = ExprBuilder.getType(Iterator); + MaxType = ExprBuilder.getWidestType(MaxType, ValueLB->getType()); + MaxType = ExprBuilder.getWidestType(MaxType, ValueInc->getType()); - ExprBuilder.unifyTypes(ValueLB, ValueUB, ValueInc); + if (MaxType != ValueLB->getType()) + ValueLB = Builder.CreateSExt(ValueLB, MaxType); + if (MaxType != ValueInc->getType()) + ValueInc = Builder.CreateSExt(ValueInc, MaxType); std::vector<Value *> IVS(VectorWidth); IVS[0] = ValueLB; @@ -442,6 +445,7 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For, isl_ast_expr *Init, *Inc, *Iterator, *UB; isl_id *IteratorID; Value *ValueLB, *ValueUB, *ValueInc; + Type *MaxType; BasicBlock *ExitBlock; Value *IV; CmpInst::Predicate Predicate; @@ -468,7 +472,17 @@ void IslNodeBuilder::createForSequential(__isl_take isl_ast_node *For, ValueUB = ExprBuilder.create(UB); ValueInc = ExprBuilder.create(Inc); - ExprBuilder.unifyTypes(ValueLB, ValueUB, ValueInc); + MaxType = ExprBuilder.getType(Iterator); + MaxType = ExprBuilder.getWidestType(MaxType, ValueLB->getType()); + MaxType = ExprBuilder.getWidestType(MaxType, ValueUB->getType()); + MaxType = ExprBuilder.getWidestType(MaxType, ValueInc->getType()); + + if (MaxType != ValueLB->getType()) + ValueLB = Builder.CreateSExt(ValueLB, MaxType); + if (MaxType != ValueUB->getType()) + ValueUB = Builder.CreateSExt(ValueUB, MaxType); + if (MaxType != ValueInc->getType()) + ValueInc = Builder.CreateSExt(ValueInc, MaxType); // If we can show that LB <Predicate> UB holds at least once, we can // omit the GuardBB in front of the loop. @@ -540,6 +554,7 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) { isl_ast_expr *Init, *Inc, *Iterator, *UB; isl_id *IteratorID; Value *ValueLB, *ValueUB, *ValueInc; + Type *MaxType; Value *IV; CmpInst::Predicate Predicate; @@ -568,7 +583,17 @@ void IslNodeBuilder::createForParallel(__isl_take isl_ast_node *For) { ValueUB = Builder.CreateAdd( ValueUB, Builder.CreateSExt(Builder.getTrue(), ValueUB->getType())); - ExprBuilder.unifyTypes(ValueLB, ValueUB, ValueInc); + MaxType = ExprBuilder.getType(Iterator); + MaxType = ExprBuilder.getWidestType(MaxType, ValueLB->getType()); + MaxType = ExprBuilder.getWidestType(MaxType, ValueUB->getType()); + MaxType = ExprBuilder.getWidestType(MaxType, ValueInc->getType()); + + if (MaxType != ValueLB->getType()) + ValueLB = Builder.CreateSExt(ValueLB, MaxType); + if (MaxType != ValueUB->getType()) + ValueUB = Builder.CreateSExt(ValueUB, MaxType); + if (MaxType != ValueInc->getType()) + ValueInc = Builder.CreateSExt(ValueInc, MaxType); BasicBlock::iterator LoopBody; diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp index 960e0cca903..566e460b326 100644 --- a/polly/lib/CodeGen/LoopGenerators.cpp +++ b/polly/lib/CodeGen/LoopGenerators.cpp @@ -61,8 +61,6 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, assert(LB->getType() == UB->getType() && "Types of loop bounds do not match"); IntegerType *LoopIVType = dyn_cast<IntegerType>(UB->getType()); assert(LoopIVType && "UB is not integer?"); - assert((LoopIVType == LB->getType() && LoopIVType == Stride->getType()) && - "LB, UB and Stride should have equal types."); BasicBlock *BeforeBB = Builder.GetInsertBlock(); BasicBlock *GuardBB = @@ -123,6 +121,7 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, Builder.SetInsertPoint(HeaderBB); PHINode *IV = Builder.CreatePHI(LoopIVType, 2, "polly.indvar"); IV->addIncoming(LB, PreHeaderBB); + Stride = Builder.CreateZExtOrBitCast(Stride, LoopIVType); Value *IncrementedIV = Builder.CreateNSWAdd(IV, Stride, "polly.indvar_next"); Value *LoopCondition; UB = Builder.CreateSub(UB, Stride, "polly.adjust_ub"); @@ -148,12 +147,6 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, Value *ParallelLoopGenerator::createParallelLoop( Value *LB, Value *UB, Value *Stride, SetVector<Value *> &UsedValues, ValueMapT &Map, BasicBlock::iterator *LoopBody) { - - // Adjust the types to match the GOMP API. - LB = Builder.CreateSExt(LB, LongType); - UB = Builder.CreateSExt(UB, LongType); - Stride = Builder.CreateSExt(Stride, LongType); - Function *SubFn; AllocaInst *Struct = storeValuesIntoStruct(UsedValues); diff --git a/polly/lib/Support/SCEVAffinator.cpp b/polly/lib/Support/SCEVAffinator.cpp index 347c12f60fd..bff074761e0 100644 --- a/polly/lib/Support/SCEVAffinator.cpp +++ b/polly/lib/Support/SCEVAffinator.cpp @@ -565,10 +565,6 @@ __isl_give PWACtx SCEVAffinator::visitSRemInstruction(Instruction *SRem) { __isl_give PWACtx SCEVAffinator::visitUnknown(const SCEVUnknown *Expr) { if (Instruction *I = dyn_cast<Instruction>(Expr->getValue())) { switch (I->getOpcode()) { - case Instruction::IntToPtr: - return visit(SE.getSCEVAtScope(I->getOperand(0), getScope())); - case Instruction::PtrToInt: - return visit(SE.getSCEVAtScope(I->getOperand(0), getScope())); case Instruction::SDiv: return visitSDivInstruction(I); case Instruction::SRem: diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index 4b8516338e6..85bf815a21d 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -368,10 +368,6 @@ public: if (Instruction *I = dyn_cast<Instruction>(Expr->getValue())) { switch (I->getOpcode()) { - case Instruction::IntToPtr: - return visit(SE.getSCEVAtScope(I->getOperand(0), Scope)); - case Instruction::PtrToInt: - return visit(SE.getSCEVAtScope(I->getOperand(0), Scope)); case Instruction::Load: return visitLoadInstruction(I, Expr); case Instruction::SDiv: diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index c97eedffcf1..8e7fb1edfff 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -246,27 +246,6 @@ private: const Region &R; ValueMapT *VMap; - const SCEV *visitGenericInst(const SCEVUnknown *E, Instruction *Inst, - Instruction *IP) { - if (!Inst || !R.contains(Inst)) - return E; - - assert(!Inst->mayThrow() && !Inst->mayReadOrWriteMemory() && - !isa<PHINode>(Inst)); - - auto *InstClone = Inst->clone(); - for (auto &Op : Inst->operands()) { - assert(SE.isSCEVable(Op->getType())); - auto *OpSCEV = SE.getSCEV(Op); - auto *OpClone = expandCodeFor(OpSCEV, Op->getType(), IP); - InstClone->replaceUsesOfWith(Op, OpClone); - } - - InstClone->setName(Name + Inst->getName()); - InstClone->insertBefore(IP); - return SE.getSCEV(InstClone); - } - const SCEV *visitUnknown(const SCEVUnknown *E) { // If a value mapping was given try if the underlying value is remapped. @@ -280,19 +259,15 @@ private: return visit(NewE); } - auto *EnteringBB = R.getEnteringBlock(); Instruction *Inst = dyn_cast<Instruction>(E->getValue()); - Instruction *IP; - if (Inst && !R.contains(Inst)) - IP = Inst; - else if (Inst && EnteringBB->getParent() == Inst->getFunction()) - IP = EnteringBB->getTerminator(); - else - IP = EnteringBB->getParent()->getEntryBlock().getTerminator(); - if (!Inst || (Inst->getOpcode() != Instruction::SRem && Inst->getOpcode() != Instruction::SDiv)) - return visitGenericInst(E, Inst, IP); + return E; + + if (!R.contains(Inst)) + return E; + + Instruction *StartIP = R.getEnteringBlock()->getTerminator(); const SCEV *LHSScev = SE.getSCEV(Inst->getOperand(0)); const SCEV *RHSScev = SE.getSCEV(Inst->getOperand(1)); @@ -300,11 +275,11 @@ private: if (!SE.isKnownNonZero(RHSScev)) RHSScev = SE.getUMaxExpr(RHSScev, SE.getConstant(E->getType(), 1)); - Value *LHS = expandCodeFor(LHSScev, E->getType(), IP); - Value *RHS = expandCodeFor(RHSScev, E->getType(), IP); + Value *LHS = expandCodeFor(LHSScev, E->getType(), StartIP); + Value *RHS = expandCodeFor(RHSScev, E->getType(), StartIP); Inst = BinaryOperator::Create((Instruction::BinaryOps)Inst->getOpcode(), - LHS, RHS, Inst->getName() + Name, IP); + LHS, RHS, Inst->getName() + Name, StartIP); return SE.getSCEV(Inst); } diff --git a/polly/test/Isl/CodeGen/LoopParallelMD/loop_nest_param_parallel.ll b/polly/test/Isl/CodeGen/LoopParallelMD/loop_nest_param_parallel.ll index d3791599e59..b546c09824d 100644 --- a/polly/test/Isl/CodeGen/LoopParallelMD/loop_nest_param_parallel.ll +++ b/polly/test/Isl/CodeGen/LoopParallelMD/loop_nest_param_parallel.ll @@ -2,10 +2,10 @@ ; ; Check that we mark multiple parallel loops correctly including the memory instructions. ; -; CHECK-DAG: %polly.loop_cond[[COuter:[0-9]*]] = icmp sle i11 %polly.indvar{{[0-9]*}}, 1022 +; CHECK-DAG: %polly.loop_cond[[COuter:[0-9]*]] = icmp sle i64 %polly.indvar{{[0-9]*}}, 1022 ; CHECK-DAG: br i1 %polly.loop_cond[[COuter]], label %polly.loop_header{{[0-9]*}}, label %polly.loop_exit{{[0-9]*}}, !llvm.loop ![[IDOuter:[0-9]*]] ; -; CHECK-DAG: %polly.loop_cond[[CInner:[0-9]*]] = icmp sle i10 %polly.indvar{{[0-9]*}}, 510 +; CHECK-DAG: %polly.loop_cond[[CInner:[0-9]*]] = icmp sle i64 %polly.indvar{{[0-9]*}}, 510 ; CHECK-DAG: br i1 %polly.loop_cond[[CInner]], label %polly.loop_header{{[0-9]*}}, label %polly.loop_exit{{[0-9]*}}, !llvm.loop ![[IDInner:[0-9]*]] ; ; CHECK-DAG: store i32 %{{[a-z_0-9]*}}, i32* %{{[a-z_0-9]*}}, {{[ ._!,a-zA-Z0-9]*}}, !llvm.mem.parallel_loop_access !4 diff --git a/polly/test/Isl/CodeGen/MemAccess/codegen_address_space.ll b/polly/test/Isl/CodeGen/MemAccess/codegen_address_space.ll index f68df2283f2..4bb9cee8335 100644 --- a/polly/test/Isl/CodeGen/MemAccess/codegen_address_space.ll +++ b/polly/test/Isl/CodeGen/MemAccess/codegen_address_space.ll @@ -40,5 +40,5 @@ for.end: ; preds = %for.cond } ; CHECK: %polly.access.cast.A = bitcast [100 x i32] addrspace(5)* %A to i32 addrspace(5)* -; CHECK: %polly.access.A = getelementptr i32, i32 addrspace(5)* %polly.access.cast.A, i1 false +; CHECK: %polly.access.A = getelementptr i32, i32 addrspace(5)* %polly.access.cast.A, i64 0 ; CHECK: %tmp2_p_scalar_ = load i32, i32 addrspace(5)* %polly.access.A, align 4, !alias.scope !0, !noalias !2 diff --git a/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md.ll b/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md.ll index 81aa8b2c16a..9a86b7fb920 100644 --- a/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md.ll +++ b/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md.ll @@ -54,28 +54,19 @@ for.end6: ; preds = %for.cond ret i32 0 } -; WITHCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHCONST: %[[IVOutSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVOut]] to i12 -; WITHCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i12 16, %[[IVOutSext]] -; WITHCONST: %[[IVInSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVIn]] to i9 -; WITHCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i9 2, %[[IVInSext]] -; WITHCONST: %[[MUL1Sext:[._a-zA-Z0-9]+]] = sext i12 %[[MUL1]] to i13 -; WITHCONST: %[[MUL2Sext:[._a-zA-Z0-9]+]] = sext i9 %[[MUL2]] to i13 -; WITHCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i13 %[[MUL1Sext]], %[[MUL2Sext]] -; WITHCONST: %[[SUM1Sext:[._a-zA-Z0-9]+]] = sext i13 %[[SUM1]] to i14 -; WITHCONST: %[[SUM2:[._a-zA-Z0-9]+]] = add nsw i14 %[[SUM1Sext]], 5 -; WITHCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr i32, i32* getelementptr inbounds ([1040 x i32], [1040 x i32]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i14 %[[SUM2]] +; WITHCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i64 16, %[[IVOut]] +; WITHCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i64 2, %[[IVIn]] +; WITHCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i64 %[[MUL1]], %[[MUL2]] +; WITHCONST: %[[SUM2:[._a-zA-Z0-9]+]] = add nsw i64 %[[SUM1]], 5 +; WITHCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr i32, i32* getelementptr inbounds ([1040 x i32], [1040 x i32]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i64 %[[SUM2]] ; WITHCONST: store i32 100, i32* %[[ACC]] -; WITHOUTCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHOUTCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHOUTCONST: %[[IVOutSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVOut]] to i12 -; WITHOUTCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i12 16, %[[IVOutSext]] -; WITHOUTCONST: %[[IVInSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVIn]] to i9 -; WITHOUTCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i9 2, %[[IVInSext]] -; WITHOUTCONST: %[[MUL1Sext:[._a-zA-Z0-9]+]] = sext i12 %[[MUL1]] to i13 -; WITHOUTCONST: %[[MUL2Sext:[._a-zA-Z0-9]+]] = sext i9 %[[MUL2]] to i13 -; WITHOUTCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i13 %[[MUL1Sext]], %[[MUL2Sext]] -; WITHOUTCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr i32, i32* getelementptr inbounds ([1040 x i32], [1040 x i32]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i13 %[[SUM1]] +; WITHOUTCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHOUTCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHOUTCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i64 16, %[[IVOut]] +; WITHOUTCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i64 2, %[[IVIn]] +; WITHOUTCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i64 %[[MUL1]], %[[MUL2]] +; WITHOUTCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr i32, i32* getelementptr inbounds ([1040 x i32], [1040 x i32]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i64 %[[SUM1]] ; WITHOUTCONST: store i32 100, i32* %[[ACC]] diff --git a/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md_float.ll b/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md_float.ll index dd4b962149a..942e4c488ee 100644 --- a/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md_float.ll +++ b/polly/test/Isl/CodeGen/MemAccess/codegen_simple_md_float.ll @@ -51,28 +51,19 @@ for.end6: ; preds = %for.cond ret void } -; WITHCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHCONST: %[[IVOutSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVOut]] to i12 -; WITHCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i12 16, %[[IVOutSext]] -; WITHCONST: %[[IVInSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVIn]] to i9 -; WITHCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i9 2, %[[IVInSext]] -; WITHCONST: %[[MUL1Sext:[._a-zA-Z0-9]+]] = sext i12 %[[MUL1]] to i13 -; WITHCONST: %[[MUL2Sext:[._a-zA-Z0-9]+]] = sext i9 %[[MUL2]] to i13 -; WITHCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i13 %[[MUL1Sext]], %[[MUL2Sext]] -; WITHCONST: %[[SUM1Sext:[._a-zA-Z0-9]+]] = sext i13 %[[SUM1]] to i14 -; WITHCONST: %[[SUM2:[._a-zA-Z0-9]+]] = add nsw i14 %[[SUM1Sext]], 5 -; WITHCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr float, float* getelementptr inbounds ([1040 x float], [1040 x float]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i14 %[[SUM2]] +; WITHCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i64 16, %[[IVOut]] +; WITHCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i64 2, %[[IVIn]] +; WITHCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i64 %[[MUL1]], %[[MUL2]] +; WITHCONST: %[[SUM2:[._a-zA-Z0-9]+]] = add nsw i64 %[[SUM1]], 5 +; WITHCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr float, float* getelementptr inbounds ([1040 x float], [1040 x float]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i64 %[[SUM2]] ; WITHCONST: store float 1.000000e+02, float* %[[ACC]] -; WITHOUTCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHOUTCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i6 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] -; WITHOUTCONST: %[[IVOutSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVOut]] to i12 -; WITHOUTCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i12 16, %[[IVOutSext]] -; WITHOUTCONST: %[[IVInSext:[._a-zA-Z0-9]+]] = sext i6 %[[IVIn]] to i9 -; WITHOUTCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i9 2, %[[IVInSext]] -; WITHOUTCONST: %[[MUL1Sext:[._a-zA-Z0-9]+]] = sext i12 %[[MUL1]] to i13 -; WITHOUTCONST: %[[MUL2Sext:[._a-zA-Z0-9]+]] = sext i9 %[[MUL2]] to i13 -; WITHOUTCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i13 %[[MUL1Sext]], %[[MUL2Sext]] -; WITHOUTCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr float, float* getelementptr inbounds ([1040 x float], [1040 x float]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i13 %[[SUM1]] +; WITHOUTCONST: %[[IVOut:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHOUTCONST: %[[IVIn:polly.indvar[0-9]*]] = phi i64 [ 0, %polly.loop_preheader{{[0-9]*}} ], [ %polly.indvar_next{{[0-9]*}}, %polly.{{[._a-zA-Z0-9]*}} ] +; WITHOUTCONST: %[[MUL1:[._a-zA-Z0-9]+]] = mul nsw i64 16, %[[IVOut]] +; WITHOUTCONST: %[[MUL2:[._a-zA-Z0-9]+]] = mul nsw i64 2, %[[IVIn]] +; WITHOUTCONST: %[[SUM1:[._a-zA-Z0-9]+]] = add nsw i64 %[[MUL1]], %[[MUL2]] +; WITHOUTCONST: %[[ACC:[._a-zA-Z0-9]*]] = getelementptr float, float* getelementptr inbounds ([1040 x float], [1040 x float]* @A, i{{(32|64)}} 0, i{{(32|64)}} 0), i64 %[[SUM1]] ; WITHOUTCONST: store float 1.000000e+02, float* %[[ACC]] diff --git a/polly/test/Isl/CodeGen/MemAccess/different_types.ll b/polly/test/Isl/CodeGen/MemAccess/different_types.ll index 3cfb0239d5d..527c6ceaa00 100644 --- a/polly/test/Isl/CodeGen/MemAccess/different_types.ll +++ b/polly/test/Isl/CodeGen/MemAccess/different_types.ll @@ -9,14 +9,12 @@ ; A[i] += 10; ; } -; CHECK: %polly.access.cast.A{{[0-9]*}} = bitcast float* %A to i32* -; CHECK: %[[R0:[._0-9]*]] = sext i8 %polly.indvar{{[0-9]*}} to i9 -; CHECK: %[[R1:[._0-9]*]] = sub nsw i9 0, %[[R0]] -; CHECK: %[[R1s:[._0-9]*]] = sext i9 %[[R1]] to i10 -; CHECK: %[[R2:[._0-9]*]] = add nsw i10 %[[R1s]], 99 -; CHECK: %polly.access.A{{[0-9]*}} = getelementptr i32, i32* %polly.access.cast.A{{[0-9]*}}, i10 %[[R2]] -; CHECK: %[[R3:[._0-9]*]] = bitcast i32* %polly.access.A{{[0-9]*}} to float* -; CHECK: %tmp14_p_scalar_ = load float, float* %[[R3]] +; CHECK: %polly.access.cast.A14 = bitcast float* %A to i32* +; CHECK: %[[R1:[._0-9]*]] = sub nsw i64 0, %polly.indvar11 +; CHECK: %[[R2:[._0-9]*]] = add nsw i64 %[[R1]], 99 +; CHECK: %polly.access.A15 = getelementptr i32, i32* %polly.access.cast.A14, i64 %[[R2]] +; CHECK: %[[R3:[._0-9]*]] = bitcast i32* %polly.access.A15 to float* +; CHECK: %tmp14_p_scalar_ = load float, float* %[[R3]], align 4, !alias.scope !3, !noalias !4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/MemAccess/multiple_types.ll b/polly/test/Isl/CodeGen/MemAccess/multiple_types.ll index dc627043853..9a97e3f7385 100644 --- a/polly/test/Isl/CodeGen/MemAccess/multiple_types.ll +++ b/polly/test/Isl/CodeGen/MemAccess/multiple_types.ll @@ -12,21 +12,20 @@ ; } ; Short[0] -; CHECK: %polly.access.Short{{[0-9]*}} = getelementptr i8, i8* %Short, i1 false -; CHECK: %[[R0:[0-9]*]] = bitcast i8* %polly.access.Short{{[0-9]*}} to i16* -; CHECK: %tmp5_p_scalar_ = load i16, i16* %[[R0]] +; CHECK: %polly.access.Short10 = getelementptr i8, i8* %Short, i64 0 +; CHECK: %24 = bitcast i8* %polly.access.Short10 to i16* +; CHECK: %tmp5_p_scalar_ = load i16, i16* %24 ; Float[8 * i] -; CHECK: %[[R1:[0-9]*]] = sext i8 %polly.indvar to i13 -; CHECK: %[[R2:[0-9]*]] = mul nsw i13 8, %[[R1]] -; CHECK: %polly.access.Float{{[0-9]*}} = getelementptr i8, i8* %Float, i13 %[[R2]] -; CHECK: %[[R3:[0-9]*]] = bitcast i8* %polly.access.Float{{[0-9]*}} to float* -; CHECK: %tmp11_p_scalar_ = load float, float* %[[R3]] +; CHECK: %25 = mul nsw i64 8, %polly.indvar +; CHECK: %polly.access.Float11 = getelementptr i8, i8* %Float, i64 %25 +; CHECK: %26 = bitcast i8* %polly.access.Float11 to float* +; CHECK: %tmp11_p_scalar_ = load float, float* %26 ; Double[8] -; CHECK: %polly.access.Double{{[0-9]*}} = getelementptr i8, i8* %Double, i5 8 -; CHECK: %[[R4:[0-9]*]] = bitcast i8* %polly.access.Double{{[0-9]*}} to double* -; CHECK: %tmp17_p_scalar_ = load double, double* %[[R4]] +; CHECK: %polly.access.Double13 = getelementptr i8, i8* %Double, i64 8 +; CHECK: %27 = bitcast i8* %polly.access.Double13 to double* +; CHECK: %tmp17_p_scalar_ = load double, double* %27 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/MemAccess/simple_stride_test.ll b/polly/test/Isl/CodeGen/MemAccess/simple_stride_test.ll index 937a526a7ca..afa4fcaf610 100644 --- a/polly/test/Isl/CodeGen/MemAccess/simple_stride_test.ll +++ b/polly/test/Isl/CodeGen/MemAccess/simple_stride_test.ll @@ -4,12 +4,12 @@ ; stride zero for B ; stride one for A ; -; CHECK: %polly.access.B = getelementptr i32, i32* %B, i1 false +; CHECK: %polly.access.B = getelementptr i32, i32* %B, i64 0 ; CHECK: %[[BC:[._a-zA-Z0-9]*]] = bitcast i32* %polly.access.B to <1 x i32>* ; CHECK: %[[LD:[._a-zA-Z0-9]*]] = load <1 x i32>, <1 x i32>* %[[BC]], align 8 ; CHECK: %[[SV:[._a-zA-Z0-9]*]] = shufflevector <1 x i32> %[[LD]], <1 x i32> %[[LD]], <16 x i32> zeroinitializer ; -; CHECK: %polly.access.A = getelementptr i32, i32* %A, i5 0 +; CHECK: %polly.access.A = getelementptr i32, i32* %A, i64 0 ; CHECK: %[[VP:[._a-zA-Z0-9]*]] = bitcast i32* %polly.access.A to <16 x i32>* ; CHECK: store <16 x i32> %[[SV]], <16 x i32>* %[[VP]], align 8 ; diff --git a/polly/test/Isl/CodeGen/MemAccess/update_access_functions.ll b/polly/test/Isl/CodeGen/MemAccess/update_access_functions.ll index 9a35a233142..63f2edac0f9 100644 --- a/polly/test/Isl/CodeGen/MemAccess/update_access_functions.ll +++ b/polly/test/Isl/CodeGen/MemAccess/update_access_functions.ll @@ -3,7 +3,7 @@ ; RUN: < %s -S | FileCheck %s ; CHECK: polly.stmt.loop2: -; CHECK-NEXT: %polly.access.A = getelementptr double, double* %A, i7 42 +; CHECK-NEXT: %polly.access.A = getelementptr double, double* %A, i64 42 ; CHECK-NEXT: %val_p_scalar_ = load double, double* %polly.access.A ; CHECK: polly.stmt.loop3: diff --git a/polly/test/Isl/CodeGen/OpenMP/invariant_base_pointer_preloaded_pass_only_needed.ll b/polly/test/Isl/CodeGen/OpenMP/invariant_base_pointer_preloaded_pass_only_needed.ll index 77c48ed0ae7..b044684794a 100644 --- a/polly/test/Isl/CodeGen/OpenMP/invariant_base_pointer_preloaded_pass_only_needed.ll +++ b/polly/test/Isl/CodeGen/OpenMP/invariant_base_pointer_preloaded_pass_only_needed.ll @@ -15,7 +15,7 @@ ; } ; ; i A[0] A -; CHECK: %polly.par.userContext = alloca { i11, float, float* } +; CHECK: %polly.par.userContext = alloca { i64, float, float* } ; ; CHECK: %polly.access.B.load = ; CHECK: %polly.subfn.storeaddr.polly.access.A.load = getelementptr inbounds diff --git a/polly/test/Isl/CodeGen/OpenMP/new_multidim_access.ll b/polly/test/Isl/CodeGen/OpenMP/new_multidim_access.ll index b87253a62d3..74c0823b317 100644 --- a/polly/test/Isl/CodeGen/OpenMP/new_multidim_access.ll +++ b/polly/test/Isl/CodeGen/OpenMP/new_multidim_access.ll @@ -20,18 +20,14 @@ ; CHECK: new: [n, m] -> { Stmt_bb4[i0, i1] -> MemRef_A[i0, 43 + i1] }; ; IR: %polly.access.mul.polly.subfunc.arg.A = mul nsw i64 %polly.indvar, %polly.subfunc.arg.m -; IR: %[[R0:[0-9]*]] = sext i8 %polly.indvar5 to i9 -; IR: %[[R1:[0-9]*]] = add nsw i9 %[[R0]], 13 -; IR: %[[R2:[0-9]*]] = sext i9 %[[R1]] to i64 -; IR: %polly.access.add.polly.subfunc.arg.A = add nsw i64 %polly.access.mul.polly.subfunc.arg.A, %[[R2]] +; IR: %6 = add nsw i64 %polly.indvar5, 13 +; IR: %polly.access.add.polly.subfunc.arg.A = add nsw i64 %polly.access.mul.polly.subfunc.arg.A, %6 ; IR: %polly.access.polly.subfunc.arg.A = getelementptr float, float* %polly.subfunc.arg.A, i64 %polly.access.add.polly.subfunc.arg.A ; IR: %tmp10_p_scalar_ = load float, float* %polly.access.polly.subfunc.arg.A, align 4, !alias.scope !0, !noalias !2, !llvm.mem.parallel_loop_access !3 ; IR: %polly.access.mul.polly.subfunc.arg.A8 = mul nsw i64 %polly.indvar, %polly.subfunc.arg.m -; IR: %[[P0:[0-9]*]] = sext i8 %polly.indvar5 to i9 -; IR: %[[P1:[0-9]*]] = add nsw i9 %[[P0]], 43 -; IR: %[[P2:[0-9]*]] = sext i9 %[[P1]] to i64 -; IR: %polly.access.add.polly.subfunc.arg.A9 = add nsw i64 %polly.access.mul.polly.subfunc.arg.A8, %[[P2]] +; IR: %7 = add nsw i64 %polly.indvar5, 43 +; IR: %polly.access.add.polly.subfunc.arg.A9 = add nsw i64 %polly.access.mul.polly.subfunc.arg.A8, %7 ; IR: %polly.access.polly.subfunc.arg.A10 = getelementptr float, float* %polly.subfunc.arg.A, i64 %polly.access.add.polly.subfunc.arg.A9 ; IR: store float %p_tmp11, float* %polly.access.polly.subfunc.arg.A10, align 4, !alias.scope !0, !noalias !2, !llvm.mem.parallel_ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/OpenMP/recomputed-srem.ll b/polly/test/Isl/CodeGen/OpenMP/recomputed-srem.ll index 9aff6d5f63d..c05830c2c23 100644 --- a/polly/test/Isl/CodeGen/OpenMP/recomputed-srem.ll +++ b/polly/test/Isl/CodeGen/OpenMP/recomputed-srem.ll @@ -3,7 +3,7 @@ ; ; Test to verify that we pass %rem96 to the parallel subfunction. ; -; CHECK: %[[R:[0-9]*]] = getelementptr inbounds { i32, i32, float*, float*, i32 }, { i32, i32, float*, float*, i32 }* %polly.par.userContext1, i32 0, i32 4 +; CHECK: %[[R:[0-9]*]] = getelementptr inbounds { i32, i32, i64, float*, float*, i32 }, { i32, i32, i64, float*, float*, i32 }* %polly.par.userContext1, i32 0, i32 5 ; CHECK-NEXT: %polly.subfunc.arg.rem96 = load i32, i32* %[[R]] ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/RuntimeDebugBuilder/combine_different_values.ll b/polly/test/Isl/CodeGen/RuntimeDebugBuilder/combine_different_values.ll index 28ea5bf72cc..0555f5b350d 100644 --- a/polly/test/Isl/CodeGen/RuntimeDebugBuilder/combine_different_values.ll +++ b/polly/test/Isl/CodeGen/RuntimeDebugBuilder/combine_different_values.ll @@ -50,53 +50,46 @@ ; CHECK: @21 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00" ; CHECK: @22 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00" ; CHECK: @23 = private unnamed_addr constant [12 x i8] c"%s%ld%s%f%s\00" -; -; CHECK: %0 = zext i5 %polly.indvar to i64 -; CHECK: %scevgep = getelementptr double, double* %B, i64 %0 -; CHECK: %tmp3_p_scalar_ = load double, double* %scevgep -; CHECK: %1 = ptrtoint double* %scevgep to i64 -; CHECK: %2 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @3, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @0, i32 0, i32 0), i64 %1, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @1, i32 0, i32 0), double %tmp3_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @2, i32 0, i32 0)) -; CHECK: %3 = call i32 @fflush(i8* null) -; CHECK: %4 = zext i5 %polly.indvar to i64 -; CHECK: %scevgep1 = getelementptr i8, i8* %C, i64 %4 + +; CHECK: %0 = ptrtoint double* %scevgep to i64 +; CHECK: %1 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @3, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @0, i32 0, i32 0), i64 %0, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @1, i32 0, i32 0), double %tmp3_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @2, i32 0, i32 0)) +; CHECK: %2 = call i32 @fflush(i8* null) +; CHECK: %scevgep1 = getelementptr i8, i8* %C, i64 %polly.indvar ; CHECK: %tmp5_p_scalar_ = load i8, i8* %scevgep1 -; CHECK: %5 = ptrtoint i8* %scevgep1 to i64 -; CHECK: %6 = sext i8 %tmp5_p_scalar_ to i64 -; CHECK: %7 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @7, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @4, i32 0, i32 0), i64 %5, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @5, i32 0, i32 0), i64 %6, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @6, i32 0, i32 0)) -; CHECK: %8 = call i32 @fflush(i8* null) +; CHECK: %3 = ptrtoint i8* %scevgep1 to i64 +; CHECK: %4 = sext i8 %tmp5_p_scalar_ to i64 +; CHECK: %5 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @7, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @4, i32 0, i32 0), i64 %3, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @5, i32 0, i32 0), i64 %4, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @6, i32 0, i32 0)) +; CHECK: %6 = call i32 @fflush(i8* null) ; CHECK: %p_tmp6 = sitofp i8 %tmp5_p_scalar_ to double ; CHECK: %p_tmp7 = fadd double %tmp3_p_scalar_, %p_tmp6 -; CHECK: %9 = zext i5 %polly.indvar to i64 -; CHECK: %scevgep2 = getelementptr i32, i32* %D, i64 %9 +; CHECK: %scevgep2 = getelementptr i32, i32* %D, i64 %polly.indvar ; CHECK: %tmp9_p_scalar_ = load i32, i32* %scevgep2 -; CHECK: %10 = ptrtoint i32* %scevgep2 to i64 -; CHECK: %11 = sext i32 %tmp9_p_scalar_ to i64 -; CHECK: %12 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @11, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @8, i32 0, i32 0), i64 %10, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @9, i32 0, i32 0), i64 %11, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @10, i32 0, i32 0)) -; CHECK: %13 = call i32 @fflush(i8* null) +; CHECK: %7 = ptrtoint i32* %scevgep2 to i64 +; CHECK: %8 = sext i32 %tmp9_p_scalar_ to i64 +; CHECK: %9 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @11, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @8, i32 0, i32 0), i64 %7, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @9, i32 0, i32 0), i64 %8, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @10, i32 0, i32 0)) +; CHECK: %10 = call i32 @fflush(i8* null) ; CHECK: %p_tmp10 = sitofp i32 %tmp9_p_scalar_ to double ; CHECK: %p_tmp11 = fadd double %p_tmp7, %p_tmp10 -; CHECK: %14 = zext i5 %polly.indvar to i64 -; CHECK: %scevgep3 = getelementptr i64, i64* %E, i64 %14 +; CHECK: %scevgep3 = getelementptr i64, i64* %E, i64 %polly.indvar ; CHECK: %tmp13_p_scalar_ = load i64, i64* %scevgep3 -; CHECK: %15 = ptrtoint i64* %scevgep3 to i64 -; CHECK: %16 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @15, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @12, i32 0, i32 0), i64 %15, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @13, i32 0, i32 0), i64 %tmp13_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @14, i32 0, i32 0)) -; CHECK: %17 = call i32 @fflush(i8* null) +; CHECK: %11 = ptrtoint i64* %scevgep3 to i64 +; CHECK: %12 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @15, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @12, i32 0, i32 0), i64 %11, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @13, i32 0, i32 0), i64 %tmp13_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @14, i32 0, i32 0)) +; CHECK: %13 = call i32 @fflush(i8* null) ; CHECK: %p_tmp14 = sitofp i64 %tmp13_p_scalar_ to double ; CHECK: %p_tmp15 = fadd double %p_tmp11, %p_tmp14 -; CHECK: %18 = zext i5 %polly.indvar to i64 -; CHECK: %scevgep4 = getelementptr float, float* %A, i64 %18 +; CHECK: %scevgep4 = getelementptr float, float* %A, i64 %polly.indvar ; CHECK: %tmp17_p_scalar_ = load float, float* %scevgep4 -; CHECK: %19 = ptrtoint float* %scevgep4 to i64 -; CHECK: %20 = fpext float %tmp17_p_scalar_ to double -; CHECK: %21 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @19, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @16, i32 0, i32 0), i64 %19, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @17, i32 0, i32 0), double %20, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @18, i32 0, i32 0)) -; CHECK: %22 = call i32 @fflush(i8* null) +; CHECK: %14 = ptrtoint float* %scevgep4 to i64 +; CHECK: %15 = fpext float %tmp17_p_scalar_ to double +; CHECK: %16 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @19, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @16, i32 0, i32 0), i64 %14, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @17, i32 0, i32 0), double %15, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @18, i32 0, i32 0)) +; CHECK: %17 = call i32 @fflush(i8* null) ; CHECK: %p_tmp18 = fpext float %tmp17_p_scalar_ to double ; CHECK: %p_tmp19 = fadd double %p_tmp18, %p_tmp15 ; CHECK: %p_tmp20 = fptrunc double %p_tmp19 to float -; CHECK: %23 = ptrtoint float* %scevgep4 to i64 -; CHECK: %24 = fpext float %p_tmp20 to double -; CHECK: %25 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @23, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @20, i32 0, i32 0), i64 %23, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @21, i32 0, i32 0), double %24, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @22, i32 0, i32 0)) -; CHECK: %26 = call i32 @fflush(i8* null) +; CHECK: %18 = ptrtoint float* %scevgep4 to i64 +; CHECK: %19 = fpext float %p_tmp20 to double +; CHECK: %20 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @23, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @20, i32 0, i32 0), i64 %18, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @21, i32 0, i32 0), double %19, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @22, i32 0, i32 0)) +; CHECK: %21 = call i32 @fflush(i8* null) target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" @@ -111,25 +104,25 @@ bb1: ; preds = %bb21, %bb bb2: ; preds = %bb1 %tmp = getelementptr inbounds double, double* %B, i64 %i.0 - %tmp3 = load double, double* %tmp + %tmp3 = load double, double* %tmp, align 8 %tmp4 = getelementptr inbounds i8, i8* %C, i64 %i.0 - %tmp5 = load i8, i8* %tmp4 + %tmp5 = load i8, i8* %tmp4, align 1 %tmp6 = sitofp i8 %tmp5 to double %tmp7 = fadd double %tmp3, %tmp6 %tmp8 = getelementptr inbounds i32, i32* %D, i64 %i.0 - %tmp9 = load i32, i32* %tmp8 + %tmp9 = load i32, i32* %tmp8, align 4 %tmp10 = sitofp i32 %tmp9 to double %tmp11 = fadd double %tmp7, %tmp10 %tmp12 = getelementptr inbounds i64, i64* %E, i64 %i.0 - %tmp13 = load i64, i64* %tmp12 + %tmp13 = load i64, i64* %tmp12, align 8 %tmp14 = sitofp i64 %tmp13 to double %tmp15 = fadd double %tmp11, %tmp14 %tmp16 = getelementptr inbounds float, float* %A, i64 %i.0 - %tmp17 = load float, float* %tmp16 + %tmp17 = load float, float* %tmp16, align 4 %tmp18 = fpext float %tmp17 to double %tmp19 = fadd double %tmp18, %tmp15 %tmp20 = fptrunc double %tmp19 to float - store float %tmp20, float* %tmp16 + store float %tmp20, float* %tmp16, align 4 br label %bb21 bb21: ; preds = %bb2 @@ -142,11 +135,11 @@ bb23: ; preds = %bb1 define i32 @main() { bb: - %A = alloca [10 x float] - %B = alloca [10 x double] - %C = alloca [10 x i8] - %D = alloca [10 x i32] - %E = alloca [10 x i64] + %A = alloca [10 x float], align 16 + %B = alloca [10 x double], align 16 + %C = alloca [10 x i8], align 1 + %D = alloca [10 x i32], align 16 + %E = alloca [10 x i64], align 16 br label %bb1 bb1: ; preds = %bb7, %bb @@ -157,15 +150,15 @@ bb1: ; preds = %bb7, %bb bb2: ; preds = %bb1 fence seq_cst %tmp = getelementptr inbounds [10 x i64], [10 x i64]* %E, i64 0, i64 %i.0 - store i64 42, i64* %tmp + store i64 42, i64* %tmp, align 8 %tmp3 = getelementptr inbounds [10 x i32], [10 x i32]* %D, i64 0, i64 %i.0 - store i32 42, i32* %tmp3 + store i32 42, i32* %tmp3, align 4 %tmp4 = getelementptr inbounds [10 x i8], [10 x i8]* %C, i64 0, i64 %i.0 - store i8 42, i8* %tmp4 + store i8 42, i8* %tmp4, align 1 %tmp5 = getelementptr inbounds [10 x double], [10 x double]* %B, i64 0, i64 %i.0 - store double 4.200000e+01, double* %tmp5 + store double 4.200000e+01, double* %tmp5, align 8 %tmp6 = getelementptr inbounds [10 x float], [10 x float]* %A, i64 0, i64 %i.0 - store float 4.200000e+01, float* %tmp6 + store float 4.200000e+01, float* %tmp6, align 4 br label %bb7 bb7: ; preds = %bb2 @@ -180,7 +173,7 @@ bb9: ; preds = %bb1 %tmp14 = getelementptr inbounds [10 x i64], [10 x i64]* %E, i64 0, i64 0 call void @foo(float* %tmp10, double* %tmp11, i8* %tmp12, i32* %tmp13, i64* %tmp14) %tmp15 = getelementptr inbounds [10 x float], [10 x float]* %A, i64 0, i64 8 - %tmp16 = load float, float* %tmp15 + %tmp16 = load float, float* %tmp15, align 16 %tmp17 = fptosi float %tmp16 to i32 ret i32 %tmp17 } diff --git a/polly/test/Isl/CodeGen/aliasing_different_base_and_access_type.ll b/polly/test/Isl/CodeGen/aliasing_different_base_and_access_type.ll index 60e80be1a47..a5d2f7a6dec 100644 --- a/polly/test/Isl/CodeGen/aliasing_different_base_and_access_type.ll +++ b/polly/test/Isl/CodeGen/aliasing_different_base_and_access_type.ll @@ -3,7 +3,7 @@ ; We have to cast %B to "short *" before we create RTCs. ; ; CHECK: %polly.access.cast.B = bitcast i32* %B to i16* -; CHECK-NEXT: %polly.access.B = getelementptr i16, i16* %polly.access.cast.B, i12 1024 +; CHECK-NEXT: %polly.access.B = getelementptr i16, i16* %polly.access.cast.B, i64 1024 ; ; We should never access %B as an i32 pointer: ; diff --git a/polly/test/Isl/CodeGen/aliasing_different_pointer_types.ll b/polly/test/Isl/CodeGen/aliasing_different_pointer_types.ll index 0f8b142121f..43a06bf090e 100644 --- a/polly/test/Isl/CodeGen/aliasing_different_pointer_types.ll +++ b/polly/test/Isl/CodeGen/aliasing_different_pointer_types.ll @@ -4,15 +4,15 @@ ; them in the RTC's. We use i8* as max pointer type. ; ; CHECK: polly.split_new_and_old: -; CHECK: %polly.access.B = getelementptr float*, float** %B, i12 1024 -; CHECK: %polly.access.A = getelementptr double*, double** %A, i1 false +; CHECK: %polly.access.B = getelementptr float*, float** %B, i64 1024 +; CHECK: %polly.access.A = getelementptr double*, double** %A, i64 0 ; CHECK: %[[paBb:[._a-zA-Z0-9]]] = ptrtoint float** %polly.access.B to i64 ; CHECK: %[[paAb:[._a-zA-Z0-9]]] = ptrtoint double** %polly.access.A to i64 ; CHECK: %[[ALeB:[._a-zA-Z0-9]]] = icmp ule i64 %[[paBb]], %[[paAb]] -; CHECK: %polly.access.A[[R0:[0-9]*]] = getelementptr double*, double** %A, i12 1024 -; CHECK: %polly.access.B[[R1:[0-9]*]] = getelementptr float*, float** %B, i1 false -; CHECK: %[[paA1b:[._a-zA-Z0-9]]] = ptrtoint double** %polly.access.A[[R0]] to i64 -; CHECK: %[[paB2b:[._a-zA-Z0-9]]] = ptrtoint float** %polly.access.B[[R1]] to i64 +; CHECK: %polly.access.A1 = getelementptr double*, double** %A, i64 1024 +; CHECK: %polly.access.B2 = getelementptr float*, float** %B, i64 0 +; CHECK: %[[paA1b:[._a-zA-Z0-9]]] = ptrtoint double** %polly.access.A1 to i64 +; CHECK: %[[paB2b:[._a-zA-Z0-9]]] = ptrtoint float** %polly.access.B2 to i64 ; CHECK: %[[A1LeB2:[._a-zA-Z0-9]]] = icmp ule i64 %[[paA1b]], %[[paB2b]] ; CHECK: %[[le1OrLe2:[._a-zA-Z0-9]]] = or i1 %[[ALeB]], %[[A1LeB2]] ; CHECK: %[[orAndTrue:[._a-zA-Z0-9]]] = and i1 true, %[[le1OrLe2]] diff --git a/polly/test/Isl/CodeGen/aliasing_parametric_simple_1.ll b/polly/test/Isl/CodeGen/aliasing_parametric_simple_1.ll index a2151a66f80..eaf5c7f2e13 100644 --- a/polly/test/Isl/CodeGen/aliasing_parametric_simple_1.ll +++ b/polly/test/Isl/CodeGen/aliasing_parametric_simple_1.ll @@ -5,21 +5,26 @@ ; A[i] = B[c]; ; } ; -; CHECK: %[[Cext:[._a-zA-Z0-9]*]] = sext i32 %c to i33 -; CHECK: %[[Cp1:[._a-zA-Z0-9]*]] = add nsw i33 %[[Cext]], 1 -; CHECK: %[[BMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i33 %[[Cp1]] -; CHECK: %[[AMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i1 false +; CHECK: %[[Cext:[._a-zA-Z0-9]*]] = sext i32 %c to i64 +; CHECK: %[[Cp1:[._a-zA-Z0-9]*]] = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %[[Cext]], i64 1) +; CHECK: %[[Cp1O:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[Cp1]], 1 +; CHECK: %[[OS:[._a-zA-Z0-9]*]] = or i1 false, %[[Cp1O]] +; CHECK: %[[Cp1R:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[Cp1]], 0 +; CHECK: %[[BMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i64 %[[Cp1R]] +; CHECK: %[[AMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 0 ; CHECK: %[[BMaxI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[BMax]] to i64 ; CHECK: %[[AMinI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[AMin]] to i64 ; CHECK: %[[BltA:[._a-zA-Z0-9]*]] = icmp ule i64 %[[BMaxI]], %[[AMinI]] -; CHECK: %[[AMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i12 1024 +; CHECK: %[[AMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 1024 ; CHECK: %[[BMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i32 %c ; CHECK: %[[AMaxI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[AMax]] to i64 ; CHECK: %[[BMinI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[BMin]] to i64 ; CHECK: %[[AltB:[._a-zA-Z0-9]*]] = icmp ule i64 %[[AMaxI]], %[[BMinI]] ; CHECK: %[[NoAlias:[._a-zA-Z0-9]*]] = or i1 %[[BltA]], %[[AltB]] ; CHECK: %[[RTC:[._a-zA-Z0-9]*]] = and i1 true, %[[NoAlias]] -; CHECK: br i1 %[[RTC]], label %polly.start, label %for.cond +; CHECK: %[[NOV:[._a-zA-Z0-9]*]] = xor i1 %[[OS]], true +; CHECK: %[[RTCV:[._a-zA-Z0-9]*]] = and i1 %[[RTC]], %[[NOV]] +; CHECK: br i1 %[[RTCV]], label %polly.start, label %for.cond ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/aliasing_parametric_simple_2.ll b/polly/test/Isl/CodeGen/aliasing_parametric_simple_2.ll index 4f14c41bbf3..24b52ce80bd 100644 --- a/polly/test/Isl/CodeGen/aliasing_parametric_simple_2.ll +++ b/polly/test/Isl/CodeGen/aliasing_parametric_simple_2.ll @@ -6,27 +6,35 @@ ; } ; ; CHECK: %[[Ctx:[._a-zA-Z0-9]*]] = and i1 true -; CHECK-NEXT: %[[M0:[._a-zA-Z0-9]*]] = sext i32 %c to i33 -; CHECK-NEXT: %[[M3:[._a-zA-Z0-9]*]] = sub nsw i33 %[[M0]], 9 -; CHECK-NEXT: %[[M1:[._a-zA-Z0-9]*]] = icmp sgt i33 6, %[[M3]] -; CHECK-NEXT: %[[M4:[._a-zA-Z0-9]*]] = select i1 %[[M1]], i33 6, i33 %[[M3]] -; CHECK-NEXT: %[[BMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i33 %[[M4]] -; CHECK-NEXT: %[[AMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i1 false +; CHECK-NEXT: %[[M0:[._a-zA-Z0-9]*]] = sext i32 %c to i64 +; CHECK-NEXT: %[[M3:[._a-zA-Z0-9]*]] = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %[[M0]], i64 9) +; CHECK-NEXT: %[[M3O:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[M3]], 1 +; CHECK-NEXT: %[[OS0:[._a-zA-Z0-9]*]] = or i1 false, %[[M3O]] +; CHECK-NEXT: %[[M3R:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[M3]], 0 +; CHECK-NEXT: %[[M1:[._a-zA-Z0-9]*]] = icmp sgt i64 6, %[[M3R]] +; CHECK-NEXT: %[[M4:[._a-zA-Z0-9]*]] = select i1 %[[M1]], i64 6, i64 %[[M3R]] +; CHECK-NEXT: %[[BMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i64 %[[M4]] +; CHECK-NEXT: %[[AMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 0 ; CHECK-NEXT: %[[BMaxI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[BMax]] to i64 ; CHECK-NEXT: %[[AMinI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[AMin]] to i64 ; CHECK-NEXT: %[[BltA:[._a-zA-Z0-9]*]] = icmp ule i64 %[[BMaxI]], %[[AMinI]] -; CHECK-NEXT: %[[AMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i12 1024 -; CHECK-NEXT: %[[m0:[._a-zA-Z0-9]*]] = sext i32 %c to i33 -; CHECK-NEXT: %[[m3:[._a-zA-Z0-9]*]] = sub nsw i33 %[[m0]], 10 -; CHECK-NEXT: %[[m1:[._a-zA-Z0-9]*]] = icmp slt i33 5, %[[m3]] -; CHECK-NEXT: %[[m4:[._a-zA-Z0-9]*]] = select i1 %[[m1]], i33 5, i33 %[[m3]] -; CHECK-NEXT: %[[BMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i33 %[[m4]] +; CHECK-NEXT: %[[AMax:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %A, i64 1024 +; CHECK-NEXT: %[[m0:[._a-zA-Z0-9]*]] = sext i32 %c to i64 +; CHECK-NEXT: %[[m3:[._a-zA-Z0-9]*]] = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %[[m0]], i64 10) +; CHECK-NEXT: %[[m3O:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[m3]], 1 +; CHECK-NEXT: %[[OS1:[._a-zA-Z0-9]*]] = or i1 %[[OS0]], %[[m3O]] +; CHECK-NEXT: %[[m3R:[._a-zA-Z0-9]*]] = extractvalue { i64, i1 } %[[m3]], 0 +; CHECK-NEXT: %[[m1:[._a-zA-Z0-9]*]] = icmp slt i64 5, %[[m3R]] +; CHECK-NEXT: %[[m4:[._a-zA-Z0-9]*]] = select i1 %[[m1]], i64 5, i64 %[[m3R]] +; CHECK-NEXT: %[[BMin:[._a-zA-Z0-9]*]] = getelementptr i32, i32* %B, i64 %[[m4]] ; CHECK-NEXT: %[[AMaxI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[AMax]] to i64 ; CHECK-NEXT: %[[BMinI:[._a-zA-Z0-9]*]] = ptrtoint i32* %[[BMin]] to i64 ; CHECK-NEXT: %[[AltB:[._a-zA-Z0-9]*]] = icmp ule i64 %[[AMaxI]], %[[BMinI]] ; CHECK-NEXT: %[[NoAlias:[._a-zA-Z0-9]*]] = or i1 %[[BltA]], %[[AltB]] ; CHECK-NEXT: %[[RTC:[._a-zA-Z0-9]*]] = and i1 %[[Ctx]], %[[NoAlias]] -; CHECK-NEXT: br i1 %[[RTC]], label %polly.start, label %for.cond +; CHECK-NEXT: %[[NOV:[._a-zA-Z0-9]*]] = xor i1 %[[OS1]], true +; CHECK-NEXT: %[[RTCV:[._a-zA-Z0-9]*]] = and i1 %[[RTC]], %[[NOV]] +; CHECK-NEXT: br i1 %[[RTCV]], label %polly.start, label %for.cond ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/aliasing_struct_element.ll b/polly/test/Isl/CodeGen/aliasing_struct_element.ll index ce6ec72f873..ceec5ee8796 100644 --- a/polly/test/Isl/CodeGen/aliasing_struct_element.ll +++ b/polly/test/Isl/CodeGen/aliasing_struct_element.ll @@ -11,7 +11,7 @@ ; compute runtime alias checks but treat it as if it was a char array. ; ; CHECK: %polly.access.cast.S = bitcast %struct.st* %S to i8* -; CHECK: %polly.access.S = getelementptr i8, i8* %polly.access.cast.S, i12 1424 +; CHECK: %polly.access.S = getelementptr i8, i8* %polly.access.cast.S, i64 1424 ; ; struct st { ; int Dummy[100]; diff --git a/polly/test/Isl/CodeGen/annotated_alias_scopes.ll b/polly/test/Isl/CodeGen/annotated_alias_scopes.ll index 05e2cab8952..912a090fbeb 100644 --- a/polly/test/Isl/CodeGen/annotated_alias_scopes.ll +++ b/polly/test/Isl/CodeGen/annotated_alias_scopes.ll @@ -3,14 +3,11 @@ ; Check that we create alias scopes that indicate the accesses to A, B and C cannot alias in any way. ; ; SCOPES-LABEL: polly.stmt.for.body: -; SCOPES: %[[R0:[0-9]*]] = zext i11 %polly.indvar to i64 -; SCOPES: %[[BIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} i32* %B, i64 %[[R0]] +; SCOPES: %[[BIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} i32* %B, i64 %polly.indvar ; SCOPES: load i32, i32* %[[BIdx]], align 4, !alias.scope ![[AliasScopeB:[0-9]*]], !noalias ![[NoAliasB:[0-9]*]] -; SCOPES: %[[R1:[0-9]*]] = zext i11 %polly.indvar to i64 -; SCOPES: %[[CIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} float* %C, i64 %[[R1]] +; SCOPES: %[[CIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} float* %C, i64 %polly.indvar ; SCOPES: load float, float* %[[CIdx]], align 4, !alias.scope ![[AliasScopeC:[0-9]*]], !noalias ![[NoAliasC:[0-9]*]] -; SCOPES: %[[R2:[0-9]*]] = zext i11 %polly.indvar to i64 -; SCOPES: %[[AIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} i32* %A, i64 %[[R2]] +; SCOPES: %[[AIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} i32* %A, i64 %polly.indvar ; SCOPES: store i32 %{{[._a-zA-Z0-9]*}}, i32* %[[AIdx]], align 4, !alias.scope ![[AliasScopeA:[0-9]*]], !noalias ![[NoAliasA:[0-9]*]] ; ; SCOPES: ![[AliasScopeB]] = distinct !{![[AliasScopeB]], !{{[0-9]*}}, !"polly.alias.scope.B"} diff --git a/polly/test/Isl/CodeGen/exprModDiv.ll b/polly/test/Isl/CodeGen/exprModDiv.ll index 7453a93cff0..43117819aa6 100644 --- a/polly/test/Isl/CodeGen/exprModDiv.ll +++ b/polly/test/Isl/CodeGen/exprModDiv.ll @@ -18,7 +18,7 @@ ; A[i % 127] ; CHECK: %pexp.pdiv_r = urem i64 %polly.indvar, 127 -; CHECK: %polly.access.A{{[0-9]*}} = getelementptr float, float* %A, i64 %pexp.pdiv_r +; CHECK: %polly.access.A9 = getelementptr float, float* %A, i64 %pexp.pdiv_r ; A[floor(i / 127)] ; @@ -28,8 +28,7 @@ ; each value of i to indeed be mapped to a value. ; ; CHECK: %pexp.p_div_q = udiv i64 %polly.indvar, 127 -; CHECK: %polly.div.trunc = trunc i64 %pexp.p_div_q to i58 -; CHECK: %polly.access.B{{[0-9]*}} = getelementptr float, float* %B, i58 %polly.div.trunc +; CHECK: %polly.access.B10 = getelementptr float, float* %B, i64 %pexp.p_div_q ; #define floord(n,d) ((n < 0) ? (n - d + 1) : n) / d ; A[p + 127 * floord(-p - 1, 127) + 127] @@ -38,39 +37,32 @@ ; CHECK: %pexp.fdiv_q.2 = icmp slt i64 %p, 0 ; CHECK: %pexp.fdiv_q.3 = select i1 %pexp.fdiv_q.2, i64 %pexp.fdiv_q.1, i64 %p ; CHECK: %pexp.fdiv_q.4 = sdiv i64 %pexp.fdiv_q.3, 127 -; CHECK: %polly.div.trunc1 = trunc i64 %pexp.fdiv_q.4 to i58 -; CHECK: %[[r0:[0-9]*]] = sext i58 %polly.div.trunc1 to i64 -; CHECK: %[[r1:[0-9]*]] = mul nsw i64 127, %[[r0]] +; CHECK: %[[r1:[0-9]*]] = mul nsw i64 127, %pexp.fdiv_q.4 ; CHECK: %[[r2:[0-9]*]] = sub nsw i64 %p, %[[r1]] -; CHECK: %polly.access.A{{[0-9]*}} = getelementptr float, float* %A, i64 %[[r2]] +; CHECK: %polly.access.A11 = getelementptr float, float* %A, i64 %[[r2]] ; A[p / 127] ; CHECK: %pexp.div = sdiv exact i64 %p, 127 -; CHECK: %polly.div.trunc3 = trunc i64 %pexp.div to i58 -; CHECK: %polly.access.B{{[0-9]*}} = getelementptr float, float* %B, i58 %polly.div.trunc3 +; CHECK: %polly.access.B12 = getelementptr float, float* %B, i64 %pexp.div ; A[i % 128] ; POW2: %pexp.pdiv_r = urem i64 %polly.indvar, 128 -; POW2: %polly.access.A{{[0-9]*}} = getelementptr float, float* %A, i64 %pexp.pdiv_r +; POW2: %polly.access.A9 = getelementptr float, float* %A, i64 %pexp.pdiv_r ; A[floor(i / 128)] -; POW2: %polly.div.shr = ashr i64 %polly.indvar, 7 -; POW2: %polly.div.trunc = trunc i64 %polly.div.shr to i57 -; POW2: %polly.access.B{{[0-9]*}} = getelementptr float, float* %B, i57 %polly.div.trunc +; POW2: %pexp.p_div_q = udiv i64 %polly.indvar, 128 +; POW2: %polly.access.B10 = getelementptr float, float* %B, i64 %pexp.p_div_q ; #define floord(n,d) ((n < 0) ? (n - d + 1) : n) / d ; A[p + 128 * floord(-p - 1, 128) + 128] -; POW2: %polly.div.shr1 = ashr i64 %p, 7 -; POW2: %polly.div.trunc2 = trunc i64 %polly.div.shr1 to i57 -; POW2: %[[r0:[0-9]*]] = sext i57 %polly.div.trunc2 to i64 -; POW2: %[[r1:[0-9]*]] = mul nsw i64 128, %[[r0]] +; POW2: %polly.fdiv_q.shr = ashr i64 %p, 7 +; POW2: %[[r1:[0-9]*]] = mul nsw i64 128, %polly.fdiv_q.shr ; POW2: %[[r2:[0-9]*]] = sub nsw i64 %p, %[[r1]] -; POW2: %polly.access.A{{[0-9]*}} = getelementptr float, float* %A, i64 %[[r2]] +; POW2: %polly.access.A11 = getelementptr float, float* %A, i64 %[[r2]] ; A[p / 128] -; POW2: %polly.div.shr4 = ashr i64 %p, 7 -; POW2: %polly.div.trunc5 = trunc i64 %polly.div.shr4 to i57 -; POW2: %polly.access.B{{[0-9]*}} = getelementptr float, float* %B, i57 %polly.div.trunc5 +; POW2: %pexp.div = sdiv exact i64 %p, 128 +; POW2: %polly.access.B12 = getelementptr float, float* %B, i64 %pexp.div target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/inner_scev_sdiv_2.ll b/polly/test/Isl/CodeGen/inner_scev_sdiv_2.ll index 9b925443300..b98846a469e 100644 --- a/polly/test/Isl/CodeGen/inner_scev_sdiv_2.ll +++ b/polly/test/Isl/CodeGen/inner_scev_sdiv_2.ll @@ -3,9 +3,10 @@ ; The SCEV expression in this test case refers to a sequence of sdiv ; instructions, which are part of different bbs in the SCoP. When code ; generating the parameter expressions, the code that is generated by the SCEV -; expander has still references to the in-scop instructions, which was invalid. +; expander has still references to the in-scop instructions, which is invalid. ; -; CHECK: polly.start +; CHECK: polly.split_new_and_old: +; CHECK-NOT: = sdiv i64 0, -4 ; target triple = "x86_64-unknown-linux-gnu" diff --git a/polly/test/Isl/CodeGen/invariant_cannot_handle_void.ll b/polly/test/Isl/CodeGen/invariant_cannot_handle_void.ll index 3f42227af1b..e9d607be371 100644 --- a/polly/test/Isl/CodeGen/invariant_cannot_handle_void.ll +++ b/polly/test/Isl/CodeGen/invariant_cannot_handle_void.ll @@ -18,7 +18,7 @@ ; ; CHECK-LABEL: polly.preload.begin: ; CHECK-NEXT: %polly.access.cast.buff = bitcast i8* %buff to i16* -; CHECK-NEXT: %polly.access.buff = getelementptr i16, i16* %polly.access.cast.buff, i6 31 +; CHECK-NEXT: %polly.access.buff = getelementptr i16, i16* %polly.access.cast.buff, i64 31 ; CHECK-NEXT: %polly.access.buff.cast = bitcast i16* %polly.access.buff to i32* ; CHECK-NEXT: %polly.access.buff.load = load i32, i32* %polly.access.buff.cast, align 4 ; CHECK-NEXT: store i32 %polly.access.buff.load, i32* %tmp1.preload.s2a diff --git a/polly/test/Isl/CodeGen/invariant_load.ll b/polly/test/Isl/CodeGen/invariant_load.ll index b61731945fb..a48dc207c74 100644 --- a/polly/test/Isl/CodeGen/invariant_load.ll +++ b/polly/test/Isl/CodeGen/invariant_load.ll @@ -1,12 +1,11 @@ ; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK-NEXT: %polly.access.B = getelementptr i32, i32* %B, i1 false +; CHECK-NEXT: %polly.access.B = getelementptr i32, i32* %B, i64 0 ; CHECK-NEXT: %polly.access.B.load = load i32, i32* %polly.access.B ; ; CHECK-LABEL: polly.stmt.bb2: -; CHECK-NEXT: %[[R:[0-9]*]] = zext i11 %polly.indvar to i64 -; CHECK-NEXT: %scevgep = getelementptr i32, i32* %A, i64 %[[R]] +; CHECK-NEXT: %scevgep = getelementptr i32, i32* %A, i64 %polly.indvar ; CHECK-NEXT: store i32 %polly.access.B.load, i32* %scevgep, align 4 ; ; void f(int *restrict A, int *restrict B) { diff --git a/polly/test/Isl/CodeGen/invariant_load_base_pointer.ll b/polly/test/Isl/CodeGen/invariant_load_base_pointer.ll index 77cbd04c757..4a6db933920 100644 --- a/polly/test/Isl/CodeGen/invariant_load_base_pointer.ll +++ b/polly/test/Isl/CodeGen/invariant_load_base_pointer.ll @@ -1,12 +1,11 @@ ; RUN: opt %loadPolly -polly-codegen -polly-ignore-aliasing -polly-process-unprofitable -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK-NEXT: %polly.access.BPLoc = getelementptr i32*, i32** %BPLoc, i1 false +; CHECK-NEXT: %polly.access.BPLoc = getelementptr i32*, i32** %BPLoc, i64 0 ; CHECK-NEXT: %polly.access.BPLoc.load = load i32*, i32** %polly.access.BPLoc ; ; CHECK-LABEL: polly.stmt.bb2: -; CHECK-NEXT: %[[R:[0-9]*]] = zext i11 %polly.indvar to i64 -; CHECK-NEXT: %p_tmp3 = getelementptr inbounds i32, i32* %polly.access.BPLoc.load, i64 %[[R]] +; CHECK-NEXT: %p_tmp3 = getelementptr inbounds i32, i32* %polly.access.BPLoc.load, i64 %polly.indvar ; ; void f(int **BPLoc) { ; for (int i = 0; i < 1024; i++) diff --git a/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional.ll b/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional.ll index 3aaa45e7989..6ede0b4f1e1 100644 --- a/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional.ll +++ b/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional.ll @@ -1,18 +1,18 @@ ; RUN: opt %loadPolly -polly-codegen -polly-ignore-aliasing -polly-process-unprofitable -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK-NEXT: %0 = icmp sge i32 %N, 514 +; CHECK-NEXT: %0 = sext i32 %N to i64 +; CHECK-NEXT: %1 = icmp sge i64 %0, 514 ; CHECK-NEXT: br label %polly.preload.cond ; ; CHECK-LABEL: polly.preload.cond: -; CHECK-NEXT: br i1 %0, label %polly.preload.exec, label %polly.preload.merge +; CHECK-NEXT: br i1 %1, label %polly.preload.exec, label %polly.preload.merge ; ; CHECK-LABEL: polly.preload.merge: ; CHECK-NEXT: %polly.preload.tmp6.merge = phi i32* [ %polly.access.BPLoc.load, %polly.preload.exec ], [ null, %polly.preload.cond ] ; ; CHECK-LABEL: polly.stmt.bb5: -; CHECK-NEXT: %[[R:[0-9]*]] = zext i32 %polly.indvar6 to i64 -; CHECK-NEXT: %p_tmp7 = getelementptr inbounds i32, i32* %polly.preload.tmp6.merge, i64 %[[R]] +; CHECK-NEXT: %p_tmp7 = getelementptr inbounds i32, i32* %polly.preload.tmp6.merge, i64 %polly.indvar6 ; ; void f(int **BPLoc, int *A, int N) { ; for (int i = 0; i < N; i++) diff --git a/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional_2.ll b/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional_2.ll index 67de3036c46..048b7fc383a 100644 --- a/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional_2.ll +++ b/polly/test/Isl/CodeGen/invariant_load_base_pointer_conditional_2.ll @@ -14,56 +14,66 @@ ; CHECK-NEXT: Execution Context: [N, p, q] -> { : N > 0 } ; CHECK-NEXT: } ; -; IR: polly.preload.merge: +; IR: polly.preload.merge: ; IR-NEXT: %polly.preload.tmp1.merge = phi i32* [ %polly.access.I.load, %polly.preload.exec ], [ null, %polly.preload.cond ] ; IR-NEXT: store i32* %polly.preload.tmp1.merge, i32** %tmp1.preload.s2a -; IR-NEXT: %11 = icmp sge i32 %N, 1 -; IR-NEXT: %12 = sext i32 %p to i33 -; IR-NEXT: %13 = sext i32 %q to i33 -; IR-NEXT: %14 = add nsw i33 %12, %13 -; IR-NEXT: %15 = icmp sle i33 %14, 2147483647 -; IR-NEXT: %16 = and i1 %11, %15 -; IR-NEXT: %17 = sext i32 %p to i33 -; IR-NEXT: %18 = sext i32 %q to i33 -; IR-NEXT: %19 = add nsw i33 %17, %18 -; IR-NEXT: %20 = icmp sge i33 %19, -2147483648 -; IR-NEXT: %21 = and i1 %16, %20 -; IR-NEXT: br label %polly.preload.cond1 +; IR-NEXT: %12 = sext i32 %N to i64 +; IR-NEXT: %13 = icmp sge i64 %12, 1 +; IR-NEXT: %14 = sext i32 %q to i64 +; IR-NEXT: %15 = sext i32 %p to i64 +; IR-NEXT: %16 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %15, i64 %14) +; IR-NEXT: %.obit4 = extractvalue { i64, i1 } %16, 1 +; IR-NEXT: %polly.overflow.state5 = or i1 false, %.obit4 +; IR-NEXT: %.res6 = extractvalue { i64, i1 } %16, 0 +; IR-NEXT: %17 = icmp sle i64 %.res6, 2147483647 +; IR-NEXT: %18 = and i1 %13, %17 +; IR-NEXT: %19 = sext i32 %q to i64 +; IR-NEXT: %20 = sext i32 %p to i64 +; IR-NEXT: %21 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %20, i64 %19) +; IR-NEXT: %.obit7 = extractvalue { i64, i1 } %21, 1 +; IR-NEXT: %polly.overflow.state8 = or i1 %polly.overflow.state5, %.obit7 +; IR-NEXT: %.res9 = extractvalue { i64, i1 } %21, 0 +; IR-NEXT: %22 = icmp sge i64 %.res9, -2147483648 +; IR-NEXT: %23 = and i1 %18, %22 +; IR-NEXT: %polly.preload.cond.overflown10 = xor i1 %polly.overflow.state8, true +; IR-NEXT: %polly.preload.cond.result11 = and i1 %23, %polly.preload.cond.overflown10 +; IR-NEXT: br label %polly.preload.cond12 ; -; IR: polly.preload.cond1: -; IR-NEXT: br i1 %21, label %polly.preload.exec3, label %polly.preload.merge2 - -; IR: polly.preload.exec3: -; IR-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i1 false +; IR: polly.preload.cond12: +; IR-NEXT: br i1 %polly.preload.cond.result11 +; +; IR: polly.preload.exec14: +; IR-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i64 0 ; IR-NEXT: %polly.access.polly.preload.tmp1.merge.load = load i32, i32* %polly.access.polly.preload.tmp1.merge, align 4 ; ; IRA: polly.preload.merge: ; IRA-NEXT: %polly.preload.tmp1.merge = phi i32* [ %polly.access.I.load, %polly.preload.exec ], [ null, %polly.preload.cond ] ; IRA-NEXT: store i32* %polly.preload.tmp1.merge, i32** %tmp1.preload.s2a -; IRA-NEXT: %11 = icmp sge i32 %N, 1 -; IRA-NEXT: %12 = sext i32 %p to i33 -; IRA-NEXT: %13 = sext i32 %q to i33 -; IRA-NEXT: %14 = call { i33, i1 } @llvm.sadd.with.overflow.i33(i33 %12, i33 %13) -; IRA-NEXT: %.obit5 = extractvalue { i33, i1 } %14, 1 -; IRA-NEXT: %.res6 = extractvalue { i33, i1 } %14, 0 -; IRA-NEXT: %15 = icmp sle i33 %.res6, 2147483647 -; IRA-NEXT: %16 = and i1 %11, %15 -; IRA-NEXT: %17 = sext i32 %p to i33 -; IRA-NEXT: %18 = sext i32 %q to i33 -; IRA-NEXT: %19 = call { i33, i1 } @llvm.sadd.with.overflow.i33(i33 %17, i33 %18) -; IRA-NEXT: %.obit7 = extractvalue { i33, i1 } %19, 1 -; IRA-NEXT: %.res8 = extractvalue { i33, i1 } %19, 0 -; IRA-NEXT: %20 = icmp sge i33 %.res8, -2147483648 -; IRA-NEXT: %21 = and i1 %16, %20 +; IRA-NEXT: %12 = sext i32 %N to i64 +; IRA-NEXT: %13 = icmp sge i64 %12, 1 +; IRA-NEXT: %14 = sext i32 %q to i64 +; IRA-NEXT: %15 = sext i32 %p to i64 +; IRA-NEXT: %16 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %15, i64 %14) +; IRA-NEXT: %.obit5 = extractvalue { i64, i1 } %16, 1 +; IRA-NEXT: %.res6 = extractvalue { i64, i1 } %16, 0 +; IRA-NEXT: %17 = icmp sle i64 %.res6, 2147483647 +; IRA-NEXT: %18 = and i1 %13, %17 +; IRA-NEXT: %19 = sext i32 %q to i64 +; IRA-NEXT: %20 = sext i32 %p to i64 +; IRA-NEXT: %21 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %20, i64 %19) +; IRA-NEXT: %.obit7 = extractvalue { i64, i1 } %21, 1 +; IRA-NEXT: %.res8 = extractvalue { i64, i1 } %21, 0 +; IRA-NEXT: %22 = icmp sge i64 %.res8, -2147483648 +; IRA-NEXT: %23 = and i1 %18, %22 ; IRA-NEXT: %polly.preload.cond.overflown9 = xor i1 %.obit7, true -; IRA-NEXT: %polly.preload.cond.result10 = and i1 %21, %polly.preload.cond.overflown9 +; IRA-NEXT: %polly.preload.cond.result10 = and i1 %23, %polly.preload.cond.overflown9 ; IRA-NEXT: br label %polly.preload.cond11 ; ; IRA: polly.preload.cond11: ; IRA-NEXT: br i1 %polly.preload.cond.result10 ; ; IRA: polly.preload.exec13: -; IRA-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i1 false +; IRA-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i64 0 ; IRA-NEXT: %polly.access.polly.preload.tmp1.merge.load = load i32, i32* %polly.access.polly.preload.tmp1.merge, align 4 ; ; void f(int **I, int *A, int N, int p, int q) { diff --git a/polly/test/Isl/CodeGen/invariant_load_condition.ll b/polly/test/Isl/CodeGen/invariant_load_condition.ll index e50447f046e..a192dd3917b 100644 --- a/polly/test/Isl/CodeGen/invariant_load_condition.ll +++ b/polly/test/Isl/CodeGen/invariant_load_condition.ll @@ -1,15 +1,17 @@ ; RUN: opt %loadPolly -polly-process-unprofitable -polly-codegen -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK-NEXT: %polly.access.C = getelementptr i32, i32* %C, i1 false +; CHECK-NEXT: %polly.access.C = getelementptr i32, i32* %C, i64 0 ; CHECK-NEXT: %polly.access.C.load = load i32, i32* %polly.access.C ; CHECK-NOT: %polly.access.C.load = load i32, i32* %polly.access.C ; ; CHECK: polly.cond -; CHECK: %[[R1:[0-9]*]] = icmp sle i32 %polly.access.C.load, -1 +; CHECK: %[[R0:[0-9]*]] = sext i32 %polly.access.C.load to i64 +; CHECK: %[[R1:[0-9]*]] = icmp sle i64 %[[R0]], -1 ; ; CHECK: polly.cond -; CHECK: %[[R3:[0-9]*]] = icmp sge i32 %polly.access.C.load, 1 +; CHECK: %[[R2:[0-9]*]] = sext i32 %polly.access.C.load to i64 +; CHECK: %[[R3:[0-9]*]] = icmp sge i64 %[[R2]], 1 ; ; CHECK-NOT: polly.stmt.bb2 ; diff --git a/polly/test/Isl/CodeGen/invariant_load_different_sized_types.ll b/polly/test/Isl/CodeGen/invariant_load_different_sized_types.ll index 027f57afc10..969a87f516f 100644 --- a/polly/test/Isl/CodeGen/invariant_load_different_sized_types.ll +++ b/polly/test/Isl/CodeGen/invariant_load_different_sized_types.ll @@ -5,7 +5,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; CHECK: polly.preload.begin: ; preds = %polly.split_new_and_old ; CHECK-NEXT: %polly.access.cast.tmp2 = bitcast %struct.hoge* %tmp2 to i32* -; CHECK-NEXT: %polly.access.tmp2 = getelementptr i32, i32* %polly.access.cast.tmp2, i2 1 +; CHECK-NEXT: %polly.access.tmp2 = getelementptr i32, i32* %polly.access.cast.tmp2, i64 1 ; CHECK-NEXT: %polly.access.tmp2.load = load i32, i32* %polly.access.tmp2, align 1 ; CHECK-NEXT: store i32 %polly.access.tmp2.load, i32* %tmp.preload.s2a diff --git a/polly/test/Isl/CodeGen/invariant_load_escaping.ll b/polly/test/Isl/CodeGen/invariant_load_escaping.ll index 8b971c99b2f..56918bfa54d 100644 --- a/polly/test/Isl/CodeGen/invariant_load_escaping.ll +++ b/polly/test/Isl/CodeGen/invariant_load_escaping.ll @@ -16,7 +16,7 @@ ; } ; ; CHECK: polly.preload.begin: -; CHECK: %polly.access.B = getelementptr i32, i32* %B, i1 false +; CHECK: %polly.access.B = getelementptr i32, i32* %B, i64 0 ; CHECK: %polly.access.B.load = load i32, i32* %polly.access.B ; CHECK: store i32 %polly.access.B.load, i32* %tmp.preload.s2a ; diff --git a/polly/test/Isl/CodeGen/invariant_load_escaping_second_scop.ll b/polly/test/Isl/CodeGen/invariant_load_escaping_second_scop.ll index d4cef143732..d835adfa0cf 100644 --- a/polly/test/Isl/CodeGen/invariant_load_escaping_second_scop.ll +++ b/polly/test/Isl/CodeGen/invariant_load_escaping_second_scop.ll @@ -19,9 +19,7 @@ ; } ; ; CHECK: polly.stmt.stmt.P: -; CHECK: %polly.div.shr = ashr i32 %tmp.merge, 1 -; CHECK: %polly.div.trunc = trunc i32 %polly.div.shr to i31 -; CHECK: sext i31 %polly.div.trunc to i32 +; CHECK: sext i32 %tmp.merge to i64 ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/invariant_load_ptr_ptr_noalias.ll b/polly/test/Isl/CodeGen/invariant_load_ptr_ptr_noalias.ll index aa9350ac353..81b029919b6 100644 --- a/polly/test/Isl/CodeGen/invariant_load_ptr_ptr_noalias.ll +++ b/polly/test/Isl/CodeGen/invariant_load_ptr_ptr_noalias.ll @@ -1,14 +1,13 @@ ; RUN: opt %loadPolly -polly-process-unprofitable -polly-codegen -polly-ignore-aliasing -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK: %polly.access.A = getelementptr i32**, i32*** %A, i7 42 +; CHECK: %polly.access.A = getelementptr i32**, i32*** %A, i64 42 ; CHECK: %polly.access.A.load = load i32**, i32*** %polly.access.A -; CHECK: %polly.access.polly.access.A.load = getelementptr i32*, i32** %polly.access.A.load, i7 32 +; CHECK: %polly.access.polly.access.A.load = getelementptr i32*, i32** %polly.access.A.load, i64 32 ; CHECK: %polly.access.polly.access.A.load.load = load i32*, i32** %polly.access.polly.access.A.load ; ; CHECK: polly.stmt.bb2: -; CHECK: %[[R:[0-9]]] = zext i11 %polly.indvar to i64 -; CHECK: %p_tmp6 = getelementptr inbounds i32, i32* %polly.access.polly.access.A.load.load, i64 %[[R]] +; CHECK: %p_tmp6 = getelementptr inbounds i32, i32* %polly.access.polly.access.A.load.load, i64 %polly.indvar ; CHECK: store i32 0, i32* %p_tmp6, align 4 ; ; void f(int ***A) { diff --git a/polly/test/Isl/CodeGen/invariant_load_scalar_dep.ll b/polly/test/Isl/CodeGen/invariant_load_scalar_dep.ll index fa26899b7e2..24bd68ae89c 100644 --- a/polly/test/Isl/CodeGen/invariant_load_scalar_dep.ll +++ b/polly/test/Isl/CodeGen/invariant_load_scalar_dep.ll @@ -1,12 +1,11 @@ ; RUN: opt %loadPolly -polly-codegen -polly-ignore-aliasing -polly-process-unprofitable -S < %s | FileCheck %s ; ; CHECK-LABEL: polly.preload.begin: -; CHECK: %polly.access.B = getelementptr i32, i32* %B, i1 false +; CHECK: %polly.access.B = getelementptr i32, i32* %B, i64 0 ; CHECK: %polly.access.B.load = load i32, i32* %polly.access.B ; ; CHECK-LABEL: polly.stmt.bb2.split: -; CHECK: %[[R:[0-9]*]] = zext i11 %polly.indvar to i64 -; CHECK: %scevgep = getelementptr i32, i32* %A, i64 %[[R]] +; CHECK: %scevgep = getelementptr i32, i32* %A, i64 %polly.indvar ; CHECK: store i32 %polly.access.B.load, i32* %scevgep, align 4 ; ; void f(int *restrict A, int *restrict B) { diff --git a/polly/test/Isl/CodeGen/multiple-types-invariant-load.ll b/polly/test/Isl/CodeGen/multiple-types-invariant-load.ll index 52201ed18e4..71d1be2dedd 100644 --- a/polly/test/Isl/CodeGen/multiple-types-invariant-load.ll +++ b/polly/test/Isl/CodeGen/multiple-types-invariant-load.ll @@ -1,7 +1,7 @@ ; RUN: opt %loadPolly -polly-allow-differing-element-types -polly-codegen -S < %s | FileCheck %s ; CHECK: %polly.access.cast.global.load = bitcast %struct.hoge* %global.load to i32* -; CHECK: %polly.access.global.load = getelementptr i32, i32* %polly.access.cast.global.load, i1 false +; CHECK: %polly.access.global.load = getelementptr i32, i32* %polly.access.cast.global.load, i64 0 ; CHECK: %polly.access.global.load.load = load i32, i32* %polly.access.global.load target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/no-overflow-tracking.ll b/polly/test/Isl/CodeGen/no-overflow-tracking.ll index 107a0df7e62..3a7d7c0b3b6 100644 --- a/polly/test/Isl/CodeGen/no-overflow-tracking.ll +++ b/polly/test/Isl/CodeGen/no-overflow-tracking.ll @@ -16,24 +16,25 @@ ; IR: polly.preload.merge: ; IR-NEXT: %polly.preload.tmp1.merge = phi i32* [ %polly.access.I.load, %polly.preload.exec ], [ null, %polly.preload.cond ] ; IR-NEXT: store i32* %polly.preload.tmp1.merge, i32** %tmp1.preload.s2a -; IR-NEXT: %11 = icmp sge i32 %N, 1 -; IR-NEXT: %12 = sext i32 %p to i33 -; IR-NEXT: %13 = sext i32 %q to i33 -; IR-NEXT: %14 = add nsw i33 %12, %13 -; IR-NEXT: %15 = icmp sle i33 %14, 2147483647 -; IR-NEXT: %16 = and i1 %11, %15 -; IR-NEXT: %17 = sext i32 %p to i33 -; IR-NEXT: %18 = sext i32 %q to i33 -; IR-NEXT: %19 = add nsw i33 %17, %18 -; IR-NEXT: %20 = icmp sge i33 %19, -2147483648 -; IR-NEXT: %21 = and i1 %16, %20 +; IR-NEXT: %12 = sext i32 %N to i64 +; IR-NEXT: %13 = icmp sge i64 %12, 1 +; IR-NEXT: %14 = sext i32 %q to i64 +; IR-NEXT: %15 = sext i32 %p to i64 +; IR-NEXT: %16 = add nsw i64 %15, %14 +; IR-NEXT: %17 = icmp sle i64 %16, 2147483647 +; IR-NEXT: %18 = and i1 %13, %17 +; IR-NEXT: %19 = sext i32 %q to i64 +; IR-NEXT: %20 = sext i32 %p to i64 +; IR-NEXT: %21 = add nsw i64 %20, %19 +; IR-NEXT: %22 = icmp sge i64 %21, -2147483648 +; IR-NEXT: %23 = and i1 %18, %22 ; IR-NEXT: br label %polly.preload.cond1 ; ; IR: polly.preload.cond1: -; IR-NEXT: br i1 %21 +; IR-NEXT: br i1 %23 ; ; IR: polly.preload.exec3: -; IR-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i1 false +; IR-NEXT: %polly.access.polly.preload.tmp1.merge = getelementptr i32, i32* %polly.preload.tmp1.merge, i64 0 ; IR-NEXT: %polly.access.polly.preload.tmp1.merge.load = load i32, i32* %polly.access.polly.preload.tmp1.merge, align 4 ; ; void f(int **I, int *A, int N, int p, int q) { diff --git a/polly/test/Isl/CodeGen/non-affine-switch.ll b/polly/test/Isl/CodeGen/non-affine-switch.ll index 60603c70fa5..d180f51e703 100644 --- a/polly/test/Isl/CodeGen/non-affine-switch.ll +++ b/polly/test/Isl/CodeGen/non-affine-switch.ll @@ -14,7 +14,7 @@ ; } ; ; CHECK: polly.stmt.for.body: -; CHECK: %scevgep = getelementptr i32, i32* %A +; CHECK: %scevgep = getelementptr i32, i32* %A, i64 %polly.indvar ; CHECK: %tmp1_p_scalar_ = load i32, i32* %scevgep, align 4 ; CHECK: switch i32 %tmp1_p_scalar_, label %polly.stmt.sw.epilog.exit [ ; CHECK: i32 0, label %polly.stmt.sw.bb diff --git a/polly/test/Isl/CodeGen/non-affine-update.ll b/polly/test/Isl/CodeGen/non-affine-update.ll index f449660bb65..54c02f04f46 100644 --- a/polly/test/Isl/CodeGen/non-affine-update.ll +++ b/polly/test/Isl/CodeGen/non-affine-update.ll @@ -15,16 +15,15 @@ ; unique within non-affine scop statements. ; CHECK: polly.stmt.bb2: -; CHECK: %[[R:[0-9]*]] = zext i5 %polly.indvar to i64 -; CHECK: %scevgep = getelementptr double, double* %A, i64 %[[R]] +; CHECK: %scevgep = getelementptr double, double* %A, i64 %polly.indvar ; CHECK: polly.stmt.bb9: -; CHECK: %polly.access.C{{.*}} = getelementptr double, double* %C, i7 42 -; CHECK: %polly.access.C{{.*}} = getelementptr double, double* %C, i7 42 +; CHECK: %polly.access.C{{.*}} = getelementptr double, double* %C, i64 42 +; CHECK: %polly.access.C{{.*}} = getelementptr double, double* %C, i64 42 ; CHECK: polly.stmt.bb5: -; CHECK: %polly.access.B{{.*}} = getelementptr double, double* %B, i8 113 -; CHECK: %polly.access.B{{.*}} = getelementptr double, double* %B, i8 113 +; CHECK: %polly.access.B{{.*}} = getelementptr double, double* %B, i64 113 +; CHECK: %polly.access.B{{.*}} = getelementptr double, double* %B, i64 113 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/non_affine_float_compare.ll b/polly/test/Isl/CodeGen/non_affine_float_compare.ll index cb766c2546c..0b7527b1ee9 100644 --- a/polly/test/Isl/CodeGen/non_affine_float_compare.ll +++ b/polly/test/Isl/CodeGen/non_affine_float_compare.ll @@ -11,18 +11,15 @@ ; ; ; CHECK: polly.stmt.bb2: -; CHECK: %0 = zext i11 %polly.indvar to i64 -; CHECK: %scevgep[[R0:[0-9]*]] = getelementptr float, float* %A, i64 %0 +; CHECK: %scevgep[[R0:[0-9]*]] = getelementptr float, float* %A, i64 %polly.indvar ; CHECK: %tmp3_p_scalar_ = load float, float* %scevgep[[R0]], align 4, !alias.scope !0, !noalias !2 -; CHECK: %1 = zext i11 %polly.indvar to i64 -; CHECK: %scevgep[[R2:[0-9]*]] = getelementptr float, float* %scevgep{{[0-9]*}}, i64 %1 +; CHECK: %scevgep[[R2:[0-9]*]] = getelementptr float, float* %scevgep{{[0-9]*}}, i64 %polly.indvar ; CHECK: %tmp6_p_scalar_ = load float, float* %scevgep[[R2]], align 4, !alias.scope !0, !noalias !2 ; CHECK: %p_tmp7 = fcmp oeq float %tmp3_p_scalar_, %tmp6_p_scalar_ ; CHECK: br i1 %p_tmp7, label %polly.stmt.bb8, label %polly.stmt.bb12.[[R:[a-zA-Z_.0-9]*]] ; CHECK: polly.stmt.bb8: -; CHECK: %2 = zext i11 %polly.indvar to i64 -; CHECK: %scevgep[[R3:[0-9]*]] = getelementptr float, float* %A, i64 %2 +; CHECK: %scevgep[[R3:[0-9]*]] = getelementptr float, float* %A, i64 %polly.indvar ; CHECK: %tmp10_p_scalar_ = load float, float* %scevgep[[R3]], align 4, !alias.scope !0, !noalias !2 ; CHECK: %p_tmp11 = fadd float %tmp10_p_scalar_, 1.000000e+00 ; CHECK: store float %p_tmp11, float* %scevgep[[R3]], align 4, !alias.scope !0, !noalias !2 @@ -32,13 +29,12 @@ ; CHECK: br label %polly.stmt.bb12 ; CHECK: polly.stmt.bb12: -; CHECK: %3 = zext i11 %polly.indvar to i64 -; CHECK: %scevgep[[R4:[0-9]*]] = getelementptr float, float* %A, i64 %3 +; CHECK: %scevgep[[R4:[0-9]*]] = getelementptr float, float* %A, i64 %polly.indvar ; CHECK: %tmp10b_p_scalar_ = load float, float* %scevgep[[R4]], align 4, !alias.scope !0, !noalias !2 ; CHECK: %p_tmp11b = fadd float %tmp10b_p_scalar_, 1.000000e+00 ; CHECK: store float %p_tmp11b, float* %scevgep[[R4]], align 4, !alias.scope !0, !noalias !2 -; CHECK: %polly.indvar_next = add nsw i11 %polly.indvar, 1 -; CHECK: %polly.loop_cond = icmp sle i11 %polly.indvar, 1022 +; CHECK: %polly.indvar_next = add nsw i64 %polly.indvar, 1 +; CHECK: %polly.loop_cond = icmp sle i64 %polly.indvar, 1022 ; CHECK: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/phi_conditional_simple_1.ll b/polly/test/Isl/CodeGen/phi_conditional_simple_1.ll index 099241db4dc..88699d31343 100644 --- a/polly/test/Isl/CodeGen/phi_conditional_simple_1.ll +++ b/polly/test/Isl/CodeGen/phi_conditional_simple_1.ll @@ -22,7 +22,8 @@ ; CHECK-NEXT: %phi.phiops = alloca i32 ; CHECK-LABEL: polly.stmt.if.end: ; CHECK-NEXT: %phi.phiops.reload = load i32, i32* %phi.phiops -; CHECK: store i32 %phi.phiops.reload, i32* +; CHECK-NEXT: %scevgep +; CHECK-NEXT: store i32 %phi.phiops.reload, i32* ; CHECK-LABEL: polly.stmt.if.then: ; CHECK-NEXT: store i32 1, i32* %phi.phiops ; CHECK-NEXT: br label %polly.merge{{[.]?}} diff --git a/polly/test/Isl/CodeGen/phi_loop_carried_float.ll b/polly/test/Isl/CodeGen/phi_loop_carried_float.ll index 7938c83a933..cfcdb58d7df 100644 --- a/polly/test/Isl/CodeGen/phi_loop_carried_float.ll +++ b/polly/test/Isl/CodeGen/phi_loop_carried_float.ll @@ -17,6 +17,7 @@ ; CHECK-NEXT: ret ; CHECK-LABEL: polly.start: +; CHECK-NEXT: sext ; CHECK-NEXT: store float 0.000000e+00, float* %tmp.0.phiops ; CHECK-LABEL: polly.exiting: diff --git a/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll b/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll index 2f99bdc2623..cce111282e9 100644 --- a/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll +++ b/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll @@ -16,6 +16,7 @@ ; CHECK-NEXT: br label %exit ; CHECK-LABEL: polly.start: +; CHECK-NEXT: sext ; CHECK-NEXT: store float 0.000000e+00, float* %tmp.0.phiops ; CHECK-LABEL: polly.exiting: diff --git a/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll b/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll index bccf0ea0560..f0812fea1f3 100644 --- a/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll +++ b/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll @@ -28,6 +28,7 @@ entry: ; CHECK: ret i32 %x.addr.0.merge ; CHECK-LABEL: polly.start: +; CHECK-NEXT: sext ; CHECK-NEXT: store i32 %x, i32* %x.addr.0.phiops ; CHECK-LABEL: polly.merge21: diff --git a/polly/test/Isl/CodeGen/ptrtoint_as_parameter.ll b/polly/test/Isl/CodeGen/ptrtoint_as_parameter.ll deleted file mode 100644 index 1bbb9dd27ff..00000000000 --- a/polly/test/Isl/CodeGen/ptrtoint_as_parameter.ll +++ /dev/null @@ -1,34 +0,0 @@ -; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -; -; CHECK: polly.split_new_and_old: -; CHECK-NEXT: %pollysub.ptr.lhs.cast263 = ptrtoint i8* inttoptr (i64 1 to i8*) to i64 -; -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" - -; Function Attrs: nounwind uwtable -define void @XS_MIME__QuotedPrint_encode_qp() { -entry: - %Perl_sv_len = alloca i64, align 8 - br label %if.end - -if.end: ; preds = %entry - br label %while.cond - -while.cond: ; preds = %cond.true270, %if.then260, %if.end - %p.0 = phi i8* [ null, %if.end ], [ %p.4, %if.then260 ], [ %p.4, %cond.true270 ] - br i1 undef, label %if.then260, label %while.body210 - -while.body210: ; preds = %while.cond - unreachable - -if.then260: ; preds = %while.cond - %p.4 = getelementptr inbounds i8, i8* null, i64 1 - %sub.ptr.lhs.cast263 = ptrtoint i8* %p.4 to i64 - %sub.ptr.sub265 = sub i64 %sub.ptr.lhs.cast263, 0 - %div = udiv i64 0, %sub.ptr.sub265 - %cmp268 = icmp ult i64 0, %div - br i1 %cmp268, label %cond.true270, label %while.cond - -cond.true270: ; preds = %if.then260 - br label %while.cond -} diff --git a/polly/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll b/polly/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll index 221576f76ec..abbda0e1412 100644 --- a/polly/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll +++ b/polly/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll @@ -8,11 +8,14 @@ ; CHECK-NEXT: %0 = zext i32 %n to i64 ; CHECK: polly.split_new_and_old: -; CHECK-NEXT: %1 = icmp sge i32 %n, 1 -; CHECK-NEXT: %2 = icmp sle i32 %n, -1 -; CHECK-NEXT: %3 = icmp eq i1 false, %2 -; CHECK-NEXT: %4 = and i1 %1, %3 -; CHECK-NEXT: br i1 %4, label %polly.start, label %for.body4 +; CHECK-NEXT: %1 = sext i32 %n to i64 +; CHECK-NEXT: %2 = icmp sge i64 %1, 1 +; CHECK-NEXT: %3 = sext i32 %n to i64 +; CHECK-NEXT: %4 = icmp sle i64 %3, -1 +; CHECK-NEXT: %5 = sext i1 %4 to i64 +; CHECK-NEXT: %6 = icmp eq i64 0, %5 +; CHECK-NEXT: %7 = and i1 %2, %6 +; CHECK-NEXT: br i1 %7, label %polly.start, label %for.body4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/scalar-store-from-same-bb.ll b/polly/test/Isl/CodeGen/scalar-store-from-same-bb.ll index 381c9b1db77..a3b45ae58a8 100644 --- a/polly/test/Isl/CodeGen/scalar-store-from-same-bb.ll +++ b/polly/test/Isl/CodeGen/scalar-store-from-same-bb.ll @@ -4,8 +4,8 @@ ; This test ensures that the expression N + 1 that is stored in the phi-node ; alloca, is directly computed and not incorrectly transfered through memory. -; CHECK: store i64 %3, i64* %res.phiops -; CHECK: %3 = add i64 %N, 1 +; CHECK: store i64 %2, i64* %res.phiops +; CHECK: %2 = add i64 %N, 1 define i64 @foo(float* %A, i64 %N) { entry: diff --git a/polly/test/Isl/CodeGen/scev_expansion_in_nonaffine.ll b/polly/test/Isl/CodeGen/scev_expansion_in_nonaffine.ll index 18285594855..217a1d9654f 100644 --- a/polly/test/Isl/CodeGen/scev_expansion_in_nonaffine.ll +++ b/polly/test/Isl/CodeGen/scev_expansion_in_nonaffine.ll @@ -8,14 +8,12 @@ ; whole subregion. ; CHECK-LABEL: polly.stmt.if.then.110: -; CHECK: %[[R1_0:[0-9]*]] = zext i32 %polly.indvar[[R0_1:[0-9]*]] to i64 -; CHECK: %[[R1_1:[0-9]*]] = mul i64 %[[R1_0]], 30 +; CHECK: %[[R1_1:[0-9]*]] = mul i64 %polly.indvar[[R0_1:[0-9]*]], 30 ; CHECK: %scevgep[[R1_2:[0-9]*]] = getelementptr i32, i32* %scevgep{{[0-9]*}}, i64 %[[R1_1]] ; CHECK: store i32 0, i32* %scevgep[[R1_2]], align 8 ; CHECK-LABEL: polly.stmt.if.else: -; CHECK: %[[R2_0:[0-9]*]] = zext i32 %polly.indvar[[R0_1]] to i64 -; CHECK: %[[R2_1:[0-9]*]] = mul i64 %[[R2_0]], 30 +; CHECK: %[[R2_1:[0-9]*]] = mul i64 %polly.indvar[[R0_1]], 30 ; CHECK: %scevgep[[R2_2:[0-9]*]] = getelementptr i32, i32* %scevgep{{[0-9]*}}, i64 %[[R2_1]] ; CHECK: store i32 21, i32* %scevgep[[R2_2]], align 8 diff --git a/polly/test/Isl/CodeGen/scop_expander_insert_point.ll b/polly/test/Isl/CodeGen/scop_expander_insert_point.ll deleted file mode 100644 index 2ca28098cbb..00000000000 --- a/polly/test/Isl/CodeGen/scop_expander_insert_point.ll +++ /dev/null @@ -1,43 +0,0 @@ -; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -; -; CHECK: entry: -; CHECK-NEXT: %outvalue.141.phiops = alloca i64 -; CHECK-NEXT: %.preload.s2a = alloca i8 -; CHECK-NEXT: %divpolly = sdiv i32 undef, 1 -; CHECK-NEXT: %div = sdiv i32 undef, undef -; -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" - -; Function Attrs: nounwind uwtable -define void @int_downsample() #0 { -entry: - %div = sdiv i32 undef, undef - br label %for.cond10.preheader.lr.ph - -for.cond10.preheader.lr.ph: ; preds = %entry - br label %for.body17.lr.ph - -for.body17.lr.ph: ; preds = %for.end22, %for.cond10.preheader.lr.ph - %outcol_h.048 = phi i32 [ 0, %for.cond10.preheader.lr.ph ], [ %add31, %for.end22 ] - %0 = load i8*, i8** undef - %idx.ext = zext i32 %outcol_h.048 to i64 - %add.ptr = getelementptr inbounds i8, i8* %0, i64 %idx.ext - br label %for.body17 - -for.body17: ; preds = %for.body17, %for.body17.lr.ph - %outvalue.141 = phi i64 [ undef, %for.body17.lr.ph ], [ %add19, %for.body17 ] - %inptr.040 = phi i8* [ %add.ptr, %for.body17.lr.ph ], [ undef, %for.body17 ] - %1 = load i8, i8* %inptr.040 - %add19 = add nsw i64 0, %outvalue.141 - br i1 false, label %for.body17, label %for.end22 - -for.end22: ; preds = %for.body17 - %add31 = add i32 %outcol_h.048, %div - br i1 undef, label %for.body17.lr.ph, label %for.end32 - -for.end32: ; preds = %for.end22 - br label %for.end36 - -for.end36: ; preds = %for.end32 - ret void -} diff --git a/polly/test/Isl/CodeGen/scop_never_executed_runtime_check_location.ll b/polly/test/Isl/CodeGen/scop_never_executed_runtime_check_location.ll index 47b99b0a9a6..07c92e53444 100644 --- a/polly/test/Isl/CodeGen/scop_never_executed_runtime_check_location.ll +++ b/polly/test/Isl/CodeGen/scop_never_executed_runtime_check_location.ll @@ -7,7 +7,8 @@ ; CHECK-NEXT: %0 = zext i32 %n to i64 ; CHECK-NEXT: br i1 false ; -; CHECK: %[[T1:[._a-zA-Z0-9]]] = icmp sge i32 %n, 1 +; CHECK: %[[T0:[._a-zA-Z0-9]]] = sext i32 %n to i64 +; CHECK: %[[T1:[._a-zA-Z0-9]]] = icmp sge i64 %[[T0]], 1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/Isl/CodeGen/switch-in-non-affine-region.ll b/polly/test/Isl/CodeGen/switch-in-non-affine-region.ll index 6d8028a2a89..4887f898d24 100644 --- a/polly/test/Isl/CodeGen/switch-in-non-affine-region.ll +++ b/polly/test/Isl/CodeGen/switch-in-non-affine-region.ll @@ -15,7 +15,8 @@ ; } ; ; CHECK: polly.stmt.if.then: -; CHECK: %p_rem = srem i32 %polly.indvar, 4 +; CHECK: %1 = trunc i64 %polly.indvar to i32 +; CHECK: %p_rem = srem i32 %1, 4 ; CHECK: switch i32 %p_rem, label %polly.stmt.sw.epilog [ ; CHECK: i32 0, label %polly.stmt.sw.bb ; CHECK: i32 1, label %polly.stmt.sw.bb.3 diff --git a/polly/test/ScopInfo/int2ptr_ptr2int.ll b/polly/test/ScopInfo/int2ptr_ptr2int.ll deleted file mode 100644 index c4deab0ee48..00000000000 --- a/polly/test/ScopInfo/int2ptr_ptr2int.ll +++ /dev/null @@ -1,71 +0,0 @@ -; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s -; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s --check-prefix=IR -; -; void f(long *A, long *ptr, long val) { -; for (long i = 0; i < 100; i++) { -; long ptrV = ((long)(ptr + 1)) + 1; -; long valP = (long)(((long *)(val + 1)) + 1); -; A[ptrV] += A[valP]; -; } -; } -; -; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + val] }; -; CHECK-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] }; -; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] }; -; -; IR: polly.stmt.for.body: -; IR-NEXT: %p_tmp = ptrtoint i64* %scevgep to i64 -; IR-NEXT: %p_add = add nsw i64 %p_tmp, 1 -; IR-NEXT: %p_tmp1 = inttoptr i64 %9 to i64* -; IR-NEXT: %p_add.ptr2 = getelementptr inbounds i64, i64* %p_tmp1, i64 1 -; IR-NEXT: %p_tmp2 = ptrtoint i64* %p_add.ptr2 to i64 -; IR-NEXT: %p_arrayidx = getelementptr inbounds i64, i64* %A, i64 %p_tmp2 -; IR-NEXT: %tmp3_p_scalar_ = load i64, i64* %p_arrayidx -; IR-NEXT: %p_arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %p_add -; IR-NEXT: %tmp4_p_scalar_ = load i64, i64* %p_arrayidx3 -; IR-NEXT: %p_add4 = add nsw i64 %tmp4_p_scalar_, %tmp3_p_scalar_ -; IR-NEXT: store i64 %p_add4, i64* %p_arrayidx3 -; -; IR: polly.loop_preheader: -; IR-NEXT: %scevgep = getelementptr i64, i64* %ptr, i64 1 -; IR-NEXT: %9 = add i64 %val, 1 -; IR-NEXT: br label %polly.loop_header -; -; -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" - -define void @f(i64* %A, i64* %ptr, i64 %val) { -entry: - br label %for.cond - -for.cond: ; preds = %for.inc, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ] - %exitcond = icmp ne i64 %i.0, 100 - br i1 %exitcond, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %add.ptr = getelementptr inbounds i64, i64* %ptr, i64 1 - %tmp = ptrtoint i64* %add.ptr to i64 - %add = add nsw i64 %tmp, 1 - %add1 = add nsw i64 %val, 1 - %tmp1 = inttoptr i64 %add1 to i64* - %add.ptr2 = getelementptr inbounds i64, i64* %tmp1, i64 1 - %tmp2 = ptrtoint i64* %add.ptr2 to i64 - %arrayidx = getelementptr inbounds i64, i64* %A, i64 %tmp2 - %tmp3 = load i64, i64* %arrayidx - %arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %add - %tmp4 = load i64, i64* %arrayidx3 - %add4 = add nsw i64 %tmp4, %tmp3 - store i64 %add4, i64* %arrayidx3 - br label %for.inc - -for.inc: ; preds = %for.body - %inc = add nuw nsw i64 %i.0, 1 - br label %for.cond - -for.end: ; preds = %for.cond - ret void -} diff --git a/polly/test/ScopInfo/int2ptr_ptr2int_2.ll b/polly/test/ScopInfo/int2ptr_ptr2int_2.ll deleted file mode 100644 index faebb10ac0c..00000000000 --- a/polly/test/ScopInfo/int2ptr_ptr2int_2.ll +++ /dev/null @@ -1,72 +0,0 @@ -; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s -; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s --check-prefix=IR -; -; void f(long *A, long *B, long *ptr, long val) { -; for (long i = 0; i < 100; i++) { -; long ptrV = ((long)(ptr + 1)) + 1; -; long valP = (long)(((long *)(val + 1)) + 1); -; A[ptrV] += B[valP]; -; } -; } -; -; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_B[9 + val] }; -; CHECK-NEXT: Execution Context: [val, ptr] -> { : val <= 9223372036854775806 } -; -; CHECK: ReadAccess := [Reduction Type: +] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] }; -; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0] -; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] }; -; -; IR: polly.stmt.for.body: -; IR-NEXT: %p_tmp = ptrtoint i64* %scevgep to i64 -; IR-NEXT: %p_add = add nsw i64 %p_tmp, 1 -; IR-NEXT: %p_tmp1 = inttoptr i64 %25 to i64* -; IR-NEXT: %p_add.ptr2 = getelementptr inbounds i64, i64* %p_tmp1, i64 1 -; IR-NEXT: %p_tmp2 = ptrtoint i64* %p_add.ptr2 to i64 -; IR-NEXT: %p_arrayidx = getelementptr inbounds i64, i64* %B, i64 %p_tmp2 -; IR-NEXT: %p_arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %p_add -; IR-NEXT: %tmp4_p_scalar_ = load i64, i64* %p_arrayidx3 -; IR-NEXT: %p_add4 = add nsw i64 %tmp4_p_scalar_, %polly.preload.tmp3.merge -; IR-NEXT: store i64 %p_add4, i64* %p_arrayidx3 -; -; IR: polly.loop_preheader: -; IR-NEXT: %scevgep = getelementptr i64, i64* %ptr, i64 1 -; IR-NEXT: %25 = add i64 %val, 1 -; IR-NEXT: br label %polly.loop_header -; -; -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" - -define void @f(i64* %A, i64* %B, i64* %ptr, i64 %val) { -entry: - br label %for.cond - -for.cond: ; preds = %for.inc, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ] - %exitcond = icmp ne i64 %i.0, 100 - br i1 %exitcond, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %add.ptr = getelementptr inbounds i64, i64* %ptr, i64 1 - %tmp = ptrtoint i64* %add.ptr to i64 - %add = add nsw i64 %tmp, 1 - %add1 = add nsw i64 %val, 1 - %tmp1 = inttoptr i64 %add1 to i64* - %add.ptr2 = getelementptr inbounds i64, i64* %tmp1, i64 1 - %tmp2 = ptrtoint i64* %add.ptr2 to i64 - %arrayidx = getelementptr inbounds i64, i64* %B, i64 %tmp2 - %tmp3 = load i64, i64* %arrayidx - %arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %add - %tmp4 = load i64, i64* %arrayidx3 - %add4 = add nsw i64 %tmp4, %tmp3 - store i64 %add4, i64* %arrayidx3 - br label %for.inc - -for.inc: ; preds = %for.body - %inc = add nuw nsw i64 %i.0, 1 - br label %for.cond - -for.end: ; preds = %for.cond - ret void -} diff --git a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type.ll b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type.ll index a75e3a8af43..52a4f2faec7 100644 --- a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type.ll +++ b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type.ll @@ -25,7 +25,7 @@ ; ; CODEGEN: %.load = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0) ; CODEGEN: store i32 %.load, i32* %S.a.preload.s2a -; CODEGEN: %.load1 = load float, float* bitcast (i32* getelementptr (i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0), i2 1) to float*) +; CODEGEN: %.load1 = load float, float* bitcast (i32* getelementptr (i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0), i64 1) to float*) ; CODEGEN: store float %.load1, float* %S.b.preload.s2a ; ; CODEGEN: polly.stmt.for.body: diff --git a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll index 50146f9133c..8f725feff4d 100644 --- a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll +++ b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll @@ -44,7 +44,7 @@ ; CODEGEN: polly.preload.begin: ; CODEGEN: %.load = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0) ; CODEGEN: store i32 %.load, i32* %S.a.preload.s2a -; CODEGEN: %.load1 = load float, float* bitcast (i32* getelementptr (i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0), i2 1) to float*) +; CODEGEN: %.load1 = load float, float* bitcast (i32* getelementptr (i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0), i64 1) to float*) ; CODEGEN: store float %.load1, float* %S.b.preload.s2a ; ; CODEGEN: polly.merge_new_and_old: diff --git a/polly/test/ScopInfo/invariant_load_zext_parameter.ll b/polly/test/ScopInfo/invariant_load_zext_parameter.ll index a554ac36bde..3ffb2a47e1e 100644 --- a/polly/test/ScopInfo/invariant_load_zext_parameter.ll +++ b/polly/test/ScopInfo/invariant_load_zext_parameter.ll @@ -20,14 +20,15 @@ ; CHECK-NEXT: [loadI0] -> { Stmt_if_then[i0] : loadI0 = 0 and 0 <= i0 <= 999 }; ; ; CODEGEN: polly.preload.begin: -; CODEGEN-NEXT: %polly.access.I0 = getelementptr i32, i32* %I0, i1 false +; CODEGEN-NEXT: %polly.access.I0 = getelementptr i32, i32* %I0, i64 0 ; CODEGEN-NEXT: %polly.access.I0.load = load i32, i32* %polly.access.I0 ; CODEGEN-NEXT: store i32 %polly.access.I0.load, i32* %loadI0.preload.s2a -; CODEGEN-NEXT: %0 = icmp eq i32 %polly.access.I0.load, 0 +; CODEGEN-NEXT: %0 = sext i32 %polly.access.I0.load to i64 +; CODEGEN-NEXT: %1 = icmp eq i64 %0, 0 ; CODEGEN-NEXT: br label %polly.preload.cond ; ; CODEGEN: polly.preload.cond: -; CODEGEN-NEXT: br i1 %0, label %polly.preload.exec, label %polly.preload.merge +; CODEGEN-NEXT: br i1 %1, label %polly.preload.exec, label %polly.preload.merge ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/ScopInfo/stride_detection.ll b/polly/test/ScopInfo/stride_detection.ll index b383d3356a3..da0abb08568 100644 --- a/polly/test/ScopInfo/stride_detection.ll +++ b/polly/test/ScopInfo/stride_detection.ll @@ -9,7 +9,7 @@ ; for (int c4 = 0; c4 <= 3; c4 += 1) ; Stmt_for_body_3(32 * c0 + 4 * c2 + c4, 32 * c1 + c3); -; CHECK: polly.stmt.for.body.3: +; CHECK: polly.stmt.for.body.3: ; preds = %polly.loop_header18 ; CHECK: %_p_splat_one = load <1 x double>, <1 x double>* %_p_vec_p, align 8, !alias.scope !1, !noalias !3, !llvm.mem.parallel_loop_access !0 ; CHECK: %_p_vec_full = load <4 x double>, <4 x double>* %vector_ptr, align 8, !alias.scope !4, !noalias !5, !llvm.mem.parallel_loop_access !0 ; CHECK: extractelement <4 x double> %addp_vec, i32 0 |

