[llvm-commits] [llvm] r51816 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2008-05-31-AddBool.ll
Nick Lewycky
nicholas at mxc.ca
Sat May 31 10:10:29 PDT 2008
Author: nicholas
Date: Sat May 31 12:10:28 2008
New Revision: 51816
URL: http://llvm.org/viewvc/llvm-project?rev=51816&view=rev
Log:
Adding i1 is always Xor.
Added:
llvm/trunk/test/Transforms/InstCombine/2008-05-31-AddBool.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=51816&r1=51815&r2=51816&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat May 31 12:10:28 2008
@@ -2551,6 +2551,9 @@
bool Changed = SimplifyCommutative(I);
Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
+ if (I.getType() == Type::Int1Ty)
+ return BinaryOperator::CreateXor(LHS, RHS);
+
if (Constant *RHSC = dyn_cast<Constant>(RHS)) {
// X + undef -> undef
if (isa<UndefValue>(RHS))
Added: llvm/trunk/test/Transforms/InstCombine/2008-05-31-AddBool.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-05-31-AddBool.ll?rev=51816&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-05-31-AddBool.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2008-05-31-AddBool.ll Sat May 31 12:10:28 2008
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {xor}
+; PR2389
+
+define i1 @test(i1 %a, i1 %b) {
+ %A = add i1 %a, %b
+ ret i1 %A
+}
More information about the llvm-commits
mailing list