summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-20 06:41:35 +0000
committerChris Lattner <sabre@nondot.org>2006-09-20 06:41:35 +0000
commitc8cd62d3816fb97529d6a0c0037806106c020bf9 (patch)
treec310151778f3a2050d68f8f3a6b12db3877d71b4 /llvm/lib
parent2b09e1d2fc5a7102d13a129010e16598b46dfb64 (diff)
downloadbcm5719-llvm-c8cd62d3816fb97529d6a0c0037806106c020bf9.tar.gz
bcm5719-llvm-c8cd62d3816fb97529d6a0c0037806106c020bf9.zip
Compile:
int test3(int a, int b) { return (a < 0) ? a : 0; } to: _test3: srawi r2, r3, 31 and r3, r2, r3 blr instead of: _test3: cmpwi cr0, r3, 1 li r2, 0 blt cr0, LBB2_2 ;entry LBB2_1: ;entry mr r3, r2 LBB2_2: ;entry blr This implements: PowerPC/select_lt0.ll:seli32_a_a llvm-svn: 30517
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index bcbac950f4a..43028a80c2e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3168,7 +3168,6 @@ SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
ISD::CondCode CC) {
MVT::ValueType VT = N2.getValueType();
- //ConstantSDNode *N0C = dyn_cast<ConstantSDNode>(N0.Val);
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val);
ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val);
ConstantSDNode *N3C = dyn_cast<ConstantSDNode>(N3.Val);
@@ -3204,9 +3203,11 @@ SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
// Check to see if we can perform the "gzip trick", transforming
// select_cc setlt X, 0, A, 0 -> and (sra X, size(X)-1), A
- if (N1C && N1C->isNullValue() && N3C && N3C->isNullValue() &&
+ if (N1C && N3C && N3C->isNullValue() && CC == ISD::SETLT &&
MVT::isInteger(N0.getValueType()) &&
- MVT::isInteger(N2.getValueType()) && CC == ISD::SETLT) {
+ MVT::isInteger(N2.getValueType()) &&
+ (N1C->isNullValue() || // (a < 0) ? b : 0
+ (N1C->getValue() == 1 && N0 == N2))) { // (a < 1) ? a : 0
MVT::ValueType XType = N0.getValueType();
MVT::ValueType AType = N2.getValueType();
if (XType >= AType) {
OpenPOWER on IntegriCloud