diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-06-04 07:45:09 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-06-04 07:45:09 +0000 |
| commit | 22adfb4373081540c86d27073f5c6b7b1cac1bfe (patch) | |
| tree | 81cf9c3a05a371662c65ce8e938f78ee7a7436ce | |
| parent | 5cf78607047227d000df187946986c98bd301660 (diff) | |
| download | bcm5719-llvm-22adfb4373081540c86d27073f5c6b7b1cac1bfe.tar.gz bcm5719-llvm-22adfb4373081540c86d27073f5c6b7b1cac1bfe.zip | |
Mark sdivs as 'exact' instead of lowering them ourselves
LLVM's instcombine already translates power-of-two sdivs that are known to be
exact to fast ashr instructions. Hence, there is no need to add this logic
ourselves.
Pointed-out-by: Johannes Doerfert
llvm-svn: 239025
| -rw-r--r-- | polly/lib/CodeGen/IslExprBuilder.cpp | 9 | ||||
| -rw-r--r-- | polly/test/Isl/CodeGen/exprModDiv.ll | 6 |
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" |

