[llvm-commits] [llvm] r44318 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/select.ll
Chris Lattner
sabre at nondot.org
Sun Nov 25 13:27:54 PST 2007
Author: lattner
Date: Sun Nov 25 15:27:53 2007
New Revision: 44318
URL: http://llvm.org/viewvc/llvm-project?rev=44318&view=rev
Log:
Implement PR1822
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/select.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=44318&r1=44317&r2=44318&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sun Nov 25 15:27:53 2007
@@ -7326,6 +7326,13 @@
return BinaryOperator::createOr(NotCond, TrueVal);
}
}
+
+ // select a, b, a -> a&b
+ // select a, a, b -> a|b
+ if (CondVal == TrueVal)
+ return BinaryOperator::createOr(CondVal, FalseVal);
+ else if (CondVal == FalseVal)
+ return BinaryOperator::createAnd(CondVal, TrueVal);
}
// Selecting between two integer constants?
Modified: llvm/trunk/test/Transforms/InstCombine/select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select.ll?rev=44318&r1=44317&r2=44318&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select.ll Sun Nov 25 15:27:53 2007
@@ -1,8 +1,7 @@
; This test makes sure that these instructions are properly eliminated.
+; PR1822
-; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
-; RUN: not grep select
-; END.
+; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep select
implementation
@@ -180,3 +179,12 @@
ret short %retval
}
+bool %test23(bool %a, bool %b) {
+ %c = select bool %a, bool %b, bool %a
+ ret bool %c
+}
+
+bool %test24(bool %a, bool %b) {
+ %c = select bool %a, bool %a, bool %b
+ ret bool %c
+}
More information about the llvm-commits
mailing list