[polly] r278017 - [IslNodeBuilder] Move run-time check generation to NodeBuilder [NFC]
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 08:41:52 PDT 2016
Author: grosser
Date: Mon Aug 8 10:41:52 2016
New Revision: 278017
URL: http://llvm.org/viewvc/llvm-project?rev=278017&view=rev
Log:
[IslNodeBuilder] Move run-time check generation to NodeBuilder [NFC]
This improves the structure of the code and allows us to reuse the runtime
code generation in the PPCGCodeGeneration.
Modified:
polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
polly/trunk/lib/CodeGen/CodeGeneration.cpp
polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
Modified: polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslNodeBuilder.h?rev=278017&r1=278016&r2=278017&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslNodeBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslNodeBuilder.h Mon Aug 8 10:41:52 2016
@@ -66,6 +66,20 @@ public:
virtual ~IslNodeBuilder() {}
void addParameters(__isl_take isl_set *Context);
+
+ /// @brief Generate code that evaluates @p Condition at run-time.
+ ///
+ /// This function is typically called to generate the LLVM-IR for the
+ /// run-time condition of the scop, that verifies that all the optimistic
+ /// assumptions we have taken during scop modeling and transformation
+ /// hold at run-time.
+ ///
+ /// @param Condition The condition to evaluate
+ ///
+ /// @result An llvm::Value that is true if the condition holds and false
+ /// otherwise.
+ Value *createRTC(isl_ast_expr *Condition);
+
void create(__isl_take isl_ast_node *Node);
/// @brief Allocate memory for all new arrays created by Polly.
Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=278017&r1=278016&r2=278017&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon Aug 8 10:41:52 2016
@@ -66,19 +66,6 @@ public:
RegionInfo *RI;
///}
- /// @brief Build the runtime condition.
- ///
- /// Build the condition that evaluates at run-time to true iff all
- /// assumptions taken for the SCoP hold, and to false otherwise.
- ///
- /// @return A value evaluating to true/false if execution is save/unsafe.
- Value *buildRTC(PollyIRBuilder &Builder, IslExprBuilder &ExprBuilder) {
- Value *RTC = ExprBuilder.create(AI->getRunCondition());
- if (!RTC->getType()->isIntegerTy(1))
- RTC = Builder.CreateIsNotNull(RTC);
- return RTC;
- }
-
void verifyGeneratedFunction(Scop &S, Function &F) {
if (!verifyFunction(F, &errs()) || !Verify)
return;
@@ -147,7 +134,6 @@ public:
PollyIRBuilder Builder = createPollyIRBuilder(EnteringBB, Annotator);
IslNodeBuilder NodeBuilder(Builder, Annotator, this, *DL, *LI, *SE, *DT, S);
- IslExprBuilder &ExprBuilder = NodeBuilder.getExprBuilder();
// Only build the run-time condition and parameters _after_ having
// introduced the conditional branch. This is important as the conditional
@@ -189,15 +175,8 @@ public:
isl_ast_node_free(AstRoot);
} else {
NodeBuilder.allocateNewArrays();
-
NodeBuilder.addParameters(S.getContext());
-
- ExprBuilder.setTrackOverflow(true);
- Value *RTC = buildRTC(Builder, ExprBuilder);
- Value *OverflowHappened = Builder.CreateNot(
- ExprBuilder.getOverflowState(), "polly.rtc.overflown");
- RTC = Builder.CreateAnd(RTC, OverflowHappened, "polly.rtc.result");
- ExprBuilder.setTrackOverflow(false);
+ Value *RTC = NodeBuilder.createRTC(AI->getRunCondition());
Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC);
Builder.SetInsertPoint(&StartBlock->front());
Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=278017&r1=278016&r2=278017&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Mon Aug 8 10:41:52 2016
@@ -1239,3 +1239,20 @@ Value *IslNodeBuilder::generateSCEV(cons
return expandCodeFor(S, SE, DL, "polly", Expr, Expr->getType(),
InsertLocation, &ValueMap);
}
+
+/// The AST expression we generate to perform the run-time check assumes
+/// computations on integer types of infinite size. As we only use 64-bit
+/// arithmetic we check for overflows, in case of which we set the result
+/// of this run-time check to false to be cosnservatively correct,
+Value *IslNodeBuilder::createRTC(isl_ast_expr *Condition) {
+ auto ExprBuilder = getExprBuilder();
+ ExprBuilder.setTrackOverflow(true);
+ Value *RTC = ExprBuilder.create(Condition);
+ if (!RTC->getType()->isIntegerTy(1))
+ RTC = Builder.CreateIsNotNull(RTC);
+ Value *OverflowHappened =
+ Builder.CreateNot(ExprBuilder.getOverflowState(), "polly.rtc.overflown");
+ RTC = Builder.CreateAnd(RTC, OverflowHappened, "polly.rtc.result");
+ ExprBuilder.setTrackOverflow(false);
+ return RTC;
+}
More information about the llvm-commits
mailing list