diff options
author | Tobias Grosser <tobias@grosser.es> | 2015-06-24 04:13:29 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2015-06-24 04:13:29 +0000 |
commit | 50165ffdee8b2be80b1dfc2b439c0131fb943958 (patch) | |
tree | e7ddff5f7232ad9eda1f2afa194b7d36097d4c49 /polly/lib/Support | |
parent | d157d470621134aa556e6aee940cfce5ce553a5b (diff) | |
download | bcm5719-llvm-50165ffdee8b2be80b1dfc2b439c0131fb943958.tar.gz bcm5719-llvm-50165ffdee8b2be80b1dfc2b439c0131fb943958.zip |
Add support for srem instruction
Remainder operations with constant divisor can be modeled as quasi-affine
expression. This patch adds support for detecting and modeling them. We also
add a test that ensures they are correctly code generated.
This patch was extracted from a larger patch contributed by Johannes Doerfert
in http://reviews.llvm.org/D5293
llvm-svn: 240518
Diffstat (limited to 'polly/lib/Support')
-rw-r--r-- | polly/lib/Support/SCEVValidator.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index b06e8beb7f9..2092047e92e 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -349,6 +349,20 @@ public: return visit(DividendSCEV); } + ValidatorResult visitSRemInstruction(Instruction *SRem, const SCEV *S) { + assert(SRem->getOpcode() == Instruction::SRem && + "Assumed SRem instruction!"); + + auto *Divisor = SRem->getOperand(1); + auto *CI = dyn_cast<ConstantInt>(Divisor); + if (!CI) + return visitGenericInst(SRem, S); + + auto *Dividend = SRem->getOperand(0); + auto *DividendSCEV = SE.getSCEV(Dividend); + return visit(DividendSCEV); + } + ValidatorResult visitUnknown(const SCEVUnknown *Expr) { Value *V = Expr->getValue(); @@ -371,6 +385,8 @@ public: switch (I->getOpcode()) { case Instruction::SDiv: return visitSDivInstruction(I, Expr); + case Instruction::SRem: + return visitSRemInstruction(I, Expr); default: return visitGenericInst(I, Expr); } |