aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-12-13 03:32:53 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-12-13 03:32:53 +0000
commit290edbfdc8a6fea7c3ce1b242c0f02d2c2e028e9 (patch)
tree9634b0babcd1c086a6dc6d8e838d84237a15c299 /lib
parent220c84dde0ab9b289f0c0255c6297ae924c5a8e9 (diff)
downloadexternal_llvm-290edbfdc8a6fea7c3ce1b242c0f02d2c2e028e9.zip
external_llvm-290edbfdc8a6fea7c3ce1b242c0f02d2c2e028e9.tar.gz
external_llvm-290edbfdc8a6fea7c3ce1b242c0f02d2c2e028e9.tar.bz2
Be extra careful with extension use optimation. Now turned on by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 47e60cd..8da0912 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -36,7 +36,7 @@ using namespace llvm;
namespace {
cl::opt<bool> OptExtUses("optimize-ext-uses",
- cl::init(false), cl::Hidden);
+ cl::init(true), cl::Hidden);
}
namespace {
@@ -929,6 +929,10 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
if (Src->hasOneUse())
return false;
+ // Only do this xform is truncating is free.
+ if (!TLI->isTruncateFree(I->getType(), Src->getType()))
+ return false;
+
// Only safe to perform the optimization if the source is also defined in
// this block.
if (!isa<Instruction>(Src) || DefBB != cast<Instruction>(Src)->getParent())
@@ -952,8 +956,11 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end();
UI != E; ++UI) {
Instruction *User = cast<Instruction>(*UI);
- if (User->getParent() == DefBB) continue;
- if (isa<PHINode>(User))
+ BasicBlock *UserBB = User->getParent();
+ if (UserBB == DefBB) continue;
+ // Be conservative. We don't want this xform to end up introducing
+ // reloads just before load / store instructions.
+ if (isa<PHINode>(User) || isa<LoadInst>(User) || isa<StoreInst>(User))
return false;
}