Skip to content

Commit 7b02020

Browse files
committed
[X86] Remove portions of r275950 that are no longer needed with i1 not being a legal type
Summary: r275950 added support for turning (trunc (X >> N) to i1) into BT(X, N). But that's no longer necessary now that i1 isn't legal. This patch removes the support for that, but preserves some of the refactorings done in that commit. Reviewers: guyblank, RKSimon, spatel, zvi Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37673 llvm-svn: 312925
1 parent 8dff57a commit 7b02020

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16959,6 +16959,7 @@ static SDValue getBitTestCondition(SDValue Src, SDValue BitNo, ISD::CondCode CC,
1695916959
/// Result of 'and' is compared against zero. Change to a BT node if possible.
1696016960
static SDValue LowerAndToBT(SDValue And, ISD::CondCode CC,
1696116961
const SDLoc &dl, SelectionDAG &DAG) {
16962+
assert(And.getOpcode() == ISD::AND && "Expected AND node!");
1696216963
SDValue Op0 = And.getOperand(0);
1696316964
SDValue Op1 = And.getOperand(1);
1696416965
if (Op0.getOpcode() == ISD::TRUNCATE)
@@ -17007,32 +17008,6 @@ static SDValue LowerAndToBT(SDValue And, ISD::CondCode CC,
1700717008
return SDValue();
1700817009
}
1700917010

17010-
// Convert (truncate (srl X, N) to i1) to (bt X, N)
17011-
static SDValue LowerTruncateToBT(SDValue Op, ISD::CondCode CC,
17012-
const SDLoc &dl, SelectionDAG &DAG) {
17013-
17014-
assert(Op.getOpcode() == ISD::TRUNCATE && Op.getValueType() == MVT::i1 &&
17015-
"Expected TRUNCATE to i1 node");
17016-
17017-
if (Op.getOperand(0).getOpcode() != ISD::SRL)
17018-
return SDValue();
17019-
17020-
SDValue ShiftRight = Op.getOperand(0);
17021-
return getBitTestCondition(ShiftRight.getOperand(0), ShiftRight.getOperand(1),
17022-
CC, dl, DAG);
17023-
}
17024-
17025-
/// Result of 'and' or 'trunc to i1' is compared against zero.
17026-
/// Change to a BT node if possible.
17027-
SDValue X86TargetLowering::LowerToBT(SDValue Op, ISD::CondCode CC,
17028-
const SDLoc &dl, SelectionDAG &DAG) const {
17029-
if (Op.getOpcode() == ISD::AND)
17030-
return LowerAndToBT(Op, CC, dl, DAG);
17031-
if (Op.getOpcode() == ISD::TRUNCATE && Op.getValueType() == MVT::i1)
17032-
return LowerTruncateToBT(Op, CC, dl, DAG);
17033-
return SDValue();
17034-
}
17035-
1703617011
/// Turns an ISD::CondCode into a value suitable for SSE floating-point mask
1703717012
/// CMPs.
1703817013
static int translateX86FSETCC(ISD::CondCode SetCCOpcode, SDValue &Op0,
@@ -17554,14 +17529,10 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
1755417529
// Lower (X & (1 << N)) == 0 to BT(X, N).
1755517530
// Lower ((X >>u N) & 1) != 0 to BT(X, N).
1755617531
// Lower ((X >>s N) & 1) != 0 to BT(X, N).
17557-
// Lower (trunc (X >> N) to i1) to BT(X, N).
17558-
if (Op0.hasOneUse() && isNullConstant(Op1) &&
17532+
if (Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && isNullConstant(Op1) &&
1755917533
(CC == ISD::SETEQ || CC == ISD::SETNE)) {
17560-
if (SDValue NewSetCC = LowerToBT(Op0, CC, dl, DAG)) {
17561-
if (VT == MVT::i1)
17562-
return DAG.getNode(ISD::TRUNCATE, dl, MVT::i1, NewSetCC);
17534+
if (SDValue NewSetCC = LowerAndToBT(Op0, CC, dl, DAG))
1756317535
return NewSetCC;
17564-
}
1756517536
}
1756617537

1756717538
// Look for X == 0, X == 1, X != 0, or X != 1. We can simplify some forms of
@@ -17935,7 +17906,7 @@ SDValue X86TargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const {
1793517906
// We know the result of AND is compared against zero. Try to match
1793617907
// it to BT.
1793717908
if (Cond.getOpcode() == ISD::AND && Cond.hasOneUse()) {
17938-
if (SDValue NewSetCC = LowerToBT(Cond, ISD::SETNE, DL, DAG)) {
17909+
if (SDValue NewSetCC = LowerAndToBT(Cond, ISD::SETNE, DL, DAG)) {
1793917910
CC = NewSetCC.getOperand(0);
1794017911
Cond = NewSetCC.getOperand(1);
1794117912
AddTest = false;
@@ -18790,9 +18761,10 @@ SDValue X86TargetLowering::LowerBRCOND(SDValue Op, SelectionDAG &DAG) const {
1879018761
if (isTruncWithZeroHighBitsInput(Cond, DAG))
1879118762
Cond = Cond.getOperand(0);
1879218763

18793-
// We know the result is compared against zero. Try to match it to BT.
18794-
if (Cond.hasOneUse()) {
18795-
if (SDValue NewSetCC = LowerToBT(Cond, ISD::SETNE, dl, DAG)) {
18764+
// We know the result of AND is compared against zero. Try to match
18765+
// it to BT.
18766+
if (Cond.getOpcode() == ISD::AND && Cond.hasOneUse()) {
18767+
if (SDValue NewSetCC = LowerAndToBT(Cond, ISD::SETNE, dl, DAG)) {
1879618768
CC = NewSetCC.getOperand(0);
1879718769
Cond = NewSetCC.getOperand(1);
1879818770
addTest = false;

llvm/lib/Target/X86/X86ISelLowering.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,6 @@ namespace llvm {
12031203
SDValue lowerUINT_TO_FP_vec(SDValue Op, SelectionDAG &DAG) const;
12041204
SDValue LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const;
12051205
SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const;
1206-
SDValue LowerToBT(SDValue And, ISD::CondCode CC, const SDLoc &dl,
1207-
SelectionDAG &DAG) const;
12081206
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
12091207
SDValue LowerSETCCCARRY(SDValue Op, SelectionDAG &DAG) const;
12101208
SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)