diff options
Diffstat (limited to 'polly/lib/CodeGen/IslNodeBuilder.cpp')
| -rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
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; |

