summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-09-21 16:09:37 +0000
committerSanjay Patel <spatel@rotateright.com>2015-09-21 16:09:37 +0000
commit55dcd40d3eabe3aebe4eb4cc6625d8dd7be56613 (patch)
tree7dd68bb64d49f1eb935084943af805152543dcb5 /llvm/lib/Transforms/InstCombine
parentb774834429430885d62835a9a60d58308dd72a88 (diff)
downloadbcm5719-llvm-55dcd40d3eabe3aebe4eb4cc6625d8dd7be56613.tar.gz
bcm5719-llvm-55dcd40d3eabe3aebe4eb4cc6625d8dd7be56613.zip
add ShouldChangeType() variant that takes bitwidths
This is more efficient for cases like D12965 where we already have widths. llvm-svn: 248170
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineInternal.h1
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp21
2 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 9f5cdcbb329..dbaa5a88ee3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -341,6 +341,7 @@ public:
const unsigned SIOpd);
private:
+ bool ShouldChangeType(unsigned FromBitWidth, unsigned ToBitWidth) const;
bool ShouldChangeType(Type *From, Type *To) const;
Value *dyn_castNegVal(Value *V) const;
Value *dyn_castFNegVal(Value *V, bool NoSignedZero = false) const;
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 8c70a1c5895..72548dc69ca 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -80,14 +80,12 @@ Value *InstCombiner::EmitGEPOffset(User *GEP) {
return llvm::EmitGEPOffset(Builder, DL, GEP);
}
-/// Return true if it is desirable to convert a computation from 'From' to 'To'.
+/// Return true if it is desirable to convert an integer computation from a
+/// given bit width to a new bit width.
/// We don't want to convert from a legal to an illegal type for example or from
/// a smaller to a larger illegal type.
-bool InstCombiner::ShouldChangeType(Type *From, Type *To) const {
- assert(From->isIntegerTy() && To->isIntegerTy());
-
- unsigned FromWidth = From->getPrimitiveSizeInBits();
- unsigned ToWidth = To->getPrimitiveSizeInBits();
+bool InstCombiner::ShouldChangeType(unsigned FromWidth,
+ unsigned ToWidth) const {
bool FromLegal = DL.isLegalInteger(FromWidth);
bool ToLegal = DL.isLegalInteger(ToWidth);
@@ -104,6 +102,17 @@ bool InstCombiner::ShouldChangeType(Type *From, Type *To) const {
return true;
}
+/// Return true if it is desirable to convert a computation from 'From' to 'To'.
+/// We don't want to convert from a legal to an illegal type for example or from
+/// a smaller to a larger illegal type.
+bool InstCombiner::ShouldChangeType(Type *From, Type *To) const {
+ assert(From->isIntegerTy() && To->isIntegerTy());
+
+ unsigned FromWidth = From->getPrimitiveSizeInBits();
+ unsigned ToWidth = To->getPrimitiveSizeInBits();
+ return ShouldChangeType(FromWidth, ToWidth);
+}
+
// Return true, if No Signed Wrap should be maintained for I.
// The No Signed Wrap flag can be kept if the operation "B (I.getOpcode) C",
// where both B and C should be ConstantInts, results in a constant that does
OpenPOWER on IntegriCloud