aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-01-25 09:05:09 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-01-25 09:05:09 +0000
commit0d718e9afca29b047ae1c77f8c6afc1b70759e0b (patch)
tree1743db509a9d565d61fab5af488270c86e292e70
parent31e63881b373311ad699ba70aec6b69258773406 (diff)
Fix a selectcc lowering bug. Make a copy of X86ISD::CMP when folding it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25596 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 5a7b764dc9..b97c57d374 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -1696,9 +1696,14 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
// If the X86ISD::SETCC has more than one use, then it's probably better
// to use a test instead of duplicating the X86ISD::CMP (for register
// pressure reason).
+ // FIXME: Check number of live Op0 uses since we are in the middle of
+ // legalization process.
if (Op0.hasOneUse() && Op0.getOperand(1).getOpcode() == X86ISD::CMP) {
CC = Op0.getOperand(0);
Cond = Op0.getOperand(1);
+ // Make a copy as flag result cannot be used by more than one.
+ Cond = DAG.getNode(X86ISD::CMP, MVT::Flag,
+ Cond.getOperand(0), Cond.getOperand(1));
addTest =
isFPStack && !hasFPCMov(cast<ConstantSDNode>(CC)->getSignExtended());
} else
@@ -1742,11 +1747,14 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
// If the X86ISD::SETCC has more than one use, then it's probably better
// to use a test instead of duplicating the X86ISD::CMP (for register
// pressure reason).
+ // FIXME: Check number of live Cond uses since we are in the middle of
+ // legalization process.
if (Cond.hasOneUse() && Cond.getOperand(1).getOpcode() == X86ISD::CMP) {
CC = Cond.getOperand(0);
+ Cond = Cond.getOperand(1);
+ // Make a copy as flag result cannot be used by more than one.
Cond = DAG.getNode(X86ISD::CMP, MVT::Flag,
- Cond.getOperand(1).getOperand(0),
- Cond.getOperand(1).getOperand(1));
+ Cond.getOperand(0), Cond.getOperand(1));
} else
addTest = true;
} else if (Cond.getOpcode() == ISD::SETCC) {