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
This commit is contained in:
Bob Wilson 2010-02-04 23:32:37 +00:00
parent 67da35c832
commit 27dfb1e1a4
1 changed files with 9 additions and 0 deletions

View File

@ -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) {