summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/CodeGen/IslExprBuilder.cpp9
-rw-r--r--polly/test/Isl/CodeGen/exprModDiv.ll6
2 files changed, 4 insertions, 11 deletions
diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp
index 701a2a514f2..a725d1c8074 100644
--- a/polly/lib/CodeGen/IslExprBuilder.cpp
+++ b/polly/lib/CodeGen/IslExprBuilder.cpp
@@ -295,14 +295,7 @@ Value *IslExprBuilder::createOpBin(__isl_take isl_ast_expr *Expr) {
Res = Builder.CreateNSWMul(LHS, RHS);
break;
case isl_ast_op_div:
- if (auto *Const = dyn_cast<ConstantInt>(RHS)) {
- auto &Val = Const->getValue();
- if (Val.isPowerOf2() && Val.isNonNegative()) {
- Res = Builder.CreateAShr(LHS, Val.ceilLogBase2(), "pexp.div.shr");
- break;
- }
- }
- Res = Builder.CreateSDiv(LHS, RHS, "pexp.div");
+ Res = Builder.CreateSDiv(LHS, RHS, "pexp.div", true);
break;
case isl_ast_op_pdiv_q: // Dividend is non-negative
Res = Builder.CreateUDiv(LHS, RHS, "pexp.p_div_q");
diff --git a/polly/test/Isl/CodeGen/exprModDiv.ll b/polly/test/Isl/CodeGen/exprModDiv.ll
index f3f8b9eb947..f77013a0484 100644
--- a/polly/test/Isl/CodeGen/exprModDiv.ll
+++ b/polly/test/Isl/CodeGen/exprModDiv.ll
@@ -42,7 +42,7 @@
; CHECK: %polly.access.A10 = getelementptr float, float* %A, i64 %24
; A[p / 127]
-; CHECK: %pexp.div = sdiv i64 %p, 127
+; CHECK: %pexp.div = sdiv exact i64 %p, 127
; CHECK: %polly.access.B12 = getelementptr float, float* %B, i64 %pexp.div
; A[i % 128]
@@ -64,8 +64,8 @@
; POW2: %polly.access.A10 = getelementptr float, float* %A, i64 %24
; A[p / 128]
-; POW2: %pexp.div.shr = ashr i64 %p, 7
-; POW2: %polly.access.B12 = getelementptr float, float* %B, i64 %pexp.div.shr
+; 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"
OpenPOWER on IntegriCloud