[llvm-commits] [llvm] r53715 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-07-16-fsub.ll
Chris Lattner
sabre at nondot.org
Wed Jul 16 23:07:20 PDT 2008
Author: lattner
Date: Thu Jul 17 01:07:20 2008
New Revision: 53715
URL: http://llvm.org/viewvc/llvm-project?rev=53715&view=rev
Log:
Fix PR2553
Added:
llvm/trunk/test/Transforms/InstCombine/2008-07-16-fsub.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=53715&r1=53714&r2=53715&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Jul 17 01:07:20 2008
@@ -2255,7 +2255,8 @@
Instruction *InstCombiner::visitSub(BinaryOperator &I) {
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- if (Op0 == Op1) // sub X, X -> 0
+ if (Op0 == Op1 && // sub X, X -> 0
+ !I.getType()->isFPOrFPVector())
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// If this is a 'B = x-(-A)', change to B = x+A...
Added: llvm/trunk/test/Transforms/InstCombine/2008-07-16-fsub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-07-16-fsub.ll?rev=53715&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-07-16-fsub.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2008-07-16-fsub.ll Thu Jul 17 01:07:20 2008
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep sub
+; PR2553
+
+define double @test(double %X) nounwind {
+ ; fsub of self can't be optimized away.
+ %Y = sub double %X, %X
+ ret double %Y
+}
More information about the llvm-commits
mailing list