summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-02-04 23:32:37 +0000
committerBob Wilson <bob.wilson@apple.com>2010-02-04 23:32:37 +0000
commit27dfb1e1a4e6d3c36e0ade15792dbd1487c7a931 (patch)
tree596485e88585e2181df2491eb8d87c3e079bf6b3
parent67da35c832e66d3310ed67486cb46306f20cc642 (diff)
downloadbcm5719-llvm-27dfb1e1a4e6d3c36e0ade15792dbd1487c7a931.tar.gz
bcm5719-llvm-27dfb1e1a4e6d3c36e0ade15792dbd1487c7a931.zip
Do not reassociate expressions with i1 type. SimplifyCFG converts some
short-circuited conditions to AND/OR expressions, and those expressions are often converted back to a short-circuited form in code gen. The original source order may have been optimized to take advantage of the expected values, and if we reassociate them, we change the order and subvert that optimization. Radar 7497329. llvm-svn: 95333
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 4a99f4a844e..1decde13b83 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -933,6 +933,15 @@ void Reassociate::ReassociateBB(BasicBlock *BB) {
isa<VectorType>(BI->getType()))
continue; // Floating point ops are not associative.
+ // Do not reassociate boolean (i1) expressions. We want to preserve the
+ // original order of evaluation for short-circuited comparisons that
+ // SimplifyCFG has folded to AND/OR expressions. If the expression
+ // is not further optimized, it is likely to be transformed back to a
+ // short-circuited form for code gen, and the source order may have been
+ // optimized for the most likely conditions.
+ if (BI->getType()->isInteger(1))
+ continue;
+
// If this is a subtract instruction which is not already in negate form,
// see if we can convert it to X+-Y.
if (BI->getOpcode() == Instruction::Sub) {
OpenPOWER on IntegriCloud