summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/InstructionSimplify.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-01-28 16:51:11 +0000
committerDuncan Sands <baldrick@free.fr>2011-01-28 16:51:11 +0000
commit593faa53fa6d89841e601cc4571d143a6a05f0b4 (patch)
tree0b119c1a312e445ae9c0ece500f9e574daf47818 /include/llvm/Analysis/InstructionSimplify.h
parentabcae24d991844ac6ac33b773b1007e2e901575c (diff)
downloadllvm-593faa53fa6d89841e601cc4571d143a6a05f0b4.tar.gz
llvm-593faa53fa6d89841e601cc4571d143a6a05f0b4.tar.bz2
llvm-593faa53fa6d89841e601cc4571d143a6a05f0b4.tar.xz
My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPEC
benchmarks, and that it can be simplified to X/Y. (In general you can only simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the form "X/Y" then this is the case). This patch implements that transform and moves some Div logic out of instcombine and into InstructionSimplify. Unfortunately instcombine gets in the way somewhat, since it likes to change (X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too. Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y" does not overflow, because the flag says so, so I added that logic too. This eliminates a bunch of divisions and subtractions in 447.dealII, and has good effects on some other benchmarks too. It seems to have quite an effect on tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions changed, resulting in massive changes all over. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124487 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/InstructionSimplify.h')
-rw-r--r--include/llvm/Analysis/InstructionSimplify.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Analysis/InstructionSimplify.h b/include/llvm/Analysis/InstructionSimplify.h
index 7588d6b53b..d39432d072 100644
--- a/include/llvm/Analysis/InstructionSimplify.h
+++ b/include/llvm/Analysis/InstructionSimplify.h
@@ -40,6 +40,16 @@ namespace llvm {
Value *SimplifyMulInst(Value *LHS, Value *RHS, const TargetData *TD = 0,
const DominatorTree *DT = 0);
+ /// SimplifySDivInst - Given operands for an SDiv, see if we can
+ /// fold the result. If not, this returns null.
+ Value *SimplifySDivInst(Value *LHS, Value *RHS, const TargetData *TD = 0,
+ const DominatorTree *DT = 0);
+
+ /// SimplifyUDivInst - Given operands for a UDiv, see if we can
+ /// fold the result. If not, this returns null.
+ Value *SimplifyUDivInst(Value *LHS, Value *RHS, const TargetData *TD = 0,
+ const DominatorTree *DT = 0);
+
/// SimplifyShlInst - Given operands for a Shl, see if we can
/// fold the result. If not, this returns null.
Value *SimplifyShlInst(Value *Op0, Value *Op1, const TargetData *TD = 0,