From bd64d46188bd8f5e7418966d995cf977f18fb336 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 9 Oct 2014 20:06:29 +0000 Subject: [Reassociate] Don't canonicalize X - undef to X + (-undef). Phabricator Revision: http://reviews.llvm.org/D5674 PR21205 llvm-svn: 219434 --- llvm/lib/Transforms/Scalar/Reassociate.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp') diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index b8fb25d0b9a..0d5ad7311fb 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -967,6 +967,10 @@ static bool ShouldBreakUpSubtract(Instruction *Sub) { if (BinaryOperator::isNeg(Sub) || BinaryOperator::isFNeg(Sub)) return false; + // Don't breakup X - undef. + if (isa(Sub->getOperand(1))) + return false; + // Don't bother to break this up unless either the LHS is an associable add or // subtract or if this is only used by one. Value *V0 = Sub->getOperand(0); -- cgit v1.2.3