diff options
author | Bob Wilson <bob.wilson@apple.com> | 2010-02-04 23:32:37 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2010-02-04 23:32:37 +0000 |
commit | fc375d22001d27ba6d22db67821da057e36f7f89 (patch) | |
tree | 06bfcfaed16ff437632dd5add4f4e97f8a705caa /lib/Transforms/Scalar | |
parent | 85bb54f96421461aaafcde83b6302530179337e9 (diff) | |
download | external_llvm-fc375d22001d27ba6d22db67821da057e36f7f89.zip external_llvm-fc375d22001d27ba6d22db67821da057e36f7f89.tar.gz external_llvm-fc375d22001d27ba6d22db67821da057e36f7f89.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 4a99f4a..1decde1 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/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) { |