[llvm-commits] [llvm] r95333 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp

Bob Wilson bob.wilson at apple.com
Thu Feb 4 15:32:37 PST 2010


Author: bwilson
Date: Thu Feb  4 17:32:37 2010
New Revision: 95333

URL: http://llvm.org/viewvc/llvm-project?rev=95333&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=95333&r1=95332&r2=95333&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Thu Feb  4 17:32:37 2010
@@ -933,6 +933,15 @@
         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) {





More information about the llvm-commits mailing list