@@ -16959,6 +16959,7 @@ static SDValue getBitTestCondition(SDValue Src, SDValue BitNo, ISD::CondCode CC,
16959
16959
/// Result of 'and' is compared against zero. Change to a BT node if possible.
16960
16960
static SDValue LowerAndToBT(SDValue And, ISD::CondCode CC,
16961
16961
const SDLoc &dl, SelectionDAG &DAG) {
16962
+ assert(And.getOpcode() == ISD::AND && "Expected AND node!");
16962
16963
SDValue Op0 = And.getOperand(0);
16963
16964
SDValue Op1 = And.getOperand(1);
16964
16965
if (Op0.getOpcode() == ISD::TRUNCATE)
@@ -17007,32 +17008,6 @@ static SDValue LowerAndToBT(SDValue And, ISD::CondCode CC,
17007
17008
return SDValue();
17008
17009
}
17009
17010
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
-
17036
17011
/// Turns an ISD::CondCode into a value suitable for SSE floating-point mask
17037
17012
/// CMPs.
17038
17013
static int translateX86FSETCC(ISD::CondCode SetCCOpcode, SDValue &Op0,
@@ -17554,14 +17529,10 @@ SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
17554
17529
// Lower (X & (1 << N)) == 0 to BT(X, N).
17555
17530
// Lower ((X >>u N) & 1) != 0 to BT(X, N).
17556
17531
// 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) &&
17559
17533
(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))
17563
17535
return NewSetCC;
17564
- }
17565
17536
}
17566
17537
17567
17538
// 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 {
17935
17906
// We know the result of AND is compared against zero. Try to match
17936
17907
// it to BT.
17937
17908
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)) {
17939
17910
CC = NewSetCC.getOperand(0);
17940
17911
Cond = NewSetCC.getOperand(1);
17941
17912
AddTest = false;
@@ -18790,9 +18761,10 @@ SDValue X86TargetLowering::LowerBRCOND(SDValue Op, SelectionDAG &DAG) const {
18790
18761
if (isTruncWithZeroHighBitsInput(Cond, DAG))
18791
18762
Cond = Cond.getOperand(0);
18792
18763
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)) {
18796
18768
CC = NewSetCC.getOperand(0);
18797
18769
Cond = NewSetCC.getOperand(1);
18798
18770
addTest = false;
0 commit comments