Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/polly/lib
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-06-03 18:14:58 +0300
committerTobias Grosser <tobias@grosser.es>2015-06-03 18:14:58 +0300
commit244c8297cf111014bf1ca90d2219cf6e1656721d (patch)
tree1506012f6fd882ae6d629732cece3875249501f3 /polly/lib
parent14c4dab6036607c38f5f1dc522a5025618ef55db (diff)
Lower signed-divisions without rounding to ashr instructions
llvm-svn: 238929
Diffstat (limited to 'polly/lib')
-rw-r--r--polly/lib/CodeGen/IslExprBuilder.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp
index e7d7d9e296ec..701a2a514f23 100644
--- a/polly/lib/CodeGen/IslExprBuilder.cpp
+++ b/polly/lib/CodeGen/IslExprBuilder.cpp
@@ -295,6 +295,13 @@ 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");
break;
case isl_ast_op_pdiv_q: // Dividend is non-negative