summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/GVN.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-03-29 17:22:39 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-03-29 17:22:39 +0000
commit4e55044ff52029c2345639008aab5c7a1f21cfb8 (patch)
tree567db4cf1beb44cc08bc83c844faa00fba1fe78f /llvm/lib/Transforms/Scalar/GVN.cpp
parent3e2320c8bee630fe1ffb551dc04f2ad27636d912 (diff)
downloadbcm5719-llvm-4e55044ff52029c2345639008aab5c7a1f21cfb8.tar.gz
bcm5719-llvm-4e55044ff52029c2345639008aab5c7a1f21cfb8.zip
Don't PRE compares.
CodeGenPrepare sinks compare instructions down to their uses to prevent live flags and predicate registers across basic blocks. PRE of a compare instruction prevents that, forcing the i1 compare result into a general purpose register. That is usually more expensive than the redundant compare PRE was trying to eliminate in the first place. llvm-svn: 153657
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVN.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 8b79d27b952..38afe1b83d1 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2328,7 +2328,14 @@ bool GVN::performPRE(Function &F) {
CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects() ||
isa<DbgInfoIntrinsic>(CurInst))
continue;
-
+
+ // Don't do PRE on compares. The PHI would prevent CodeGenPrepare from
+ // sinking the compare again, and it would force the code generator to
+ // move the i1 from processor flags or predicate registers into a general
+ // purpose register.
+ if (isa<CmpInst>(CurInst))
+ continue;
+
// We don't currently value number ANY inline asm calls.
if (CallInst *CallI = dyn_cast<CallInst>(CurInst))
if (CallI->isInlineAsm())
OpenPOWER on IntegriCloud