mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
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
This commit is contained in:
@@ -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
|
// 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
|
// to use a test instead of duplicating the X86ISD::CMP (for register
|
||||||
// pressure reason).
|
// 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) {
|
if (Op0.hasOneUse() && Op0.getOperand(1).getOpcode() == X86ISD::CMP) {
|
||||||
CC = Op0.getOperand(0);
|
CC = Op0.getOperand(0);
|
||||||
Cond = Op0.getOperand(1);
|
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 =
|
addTest =
|
||||||
isFPStack && !hasFPCMov(cast<ConstantSDNode>(CC)->getSignExtended());
|
isFPStack && !hasFPCMov(cast<ConstantSDNode>(CC)->getSignExtended());
|
||||||
} else
|
} 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
|
// 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
|
// to use a test instead of duplicating the X86ISD::CMP (for register
|
||||||
// pressure reason).
|
// 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) {
|
if (Cond.hasOneUse() && Cond.getOperand(1).getOpcode() == X86ISD::CMP) {
|
||||||
CC = Cond.getOperand(0);
|
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 = DAG.getNode(X86ISD::CMP, MVT::Flag,
|
||||||
Cond.getOperand(1).getOperand(0),
|
Cond.getOperand(0), Cond.getOperand(1));
|
||||||
Cond.getOperand(1).getOperand(1));
|
|
||||||
} else
|
} else
|
||||||
addTest = true;
|
addTest = true;
|
||||||
} else if (Cond.getOpcode() == ISD::SETCC) {
|
} else if (Cond.getOpcode() == ISD::SETCC) {
|
||||||
|
Reference in New Issue
Block a user