@@ -11501,28 +11501,28 @@ static SDValue foldBoolSelectToLogic(SDNode *N, const SDLoc &DL,
11501
11501
if (VT != Cond.getValueType() || VT.getScalarSizeInBits() != 1)
11502
11502
return SDValue();
11503
11503
11504
- // select Cond, Cond, F --> or Cond, F
11505
- // select Cond, 1, F --> or Cond, F
11504
+ // select Cond, Cond, F --> or Cond, freeze(F)
11505
+ // select Cond, 1, F --> or Cond, freeze(F)
11506
11506
if (Cond == T || isOneOrOneSplat(T, /* AllowUndefs */ true))
11507
- return matcher.getNode(ISD::OR, DL, VT, Cond, F );
11507
+ return matcher.getNode(ISD::OR, DL, VT, Cond, DAG.getFreeze(F) );
11508
11508
11509
- // select Cond, T, Cond --> and Cond, T
11510
- // select Cond, T, 0 --> and Cond, T
11509
+ // select Cond, T, Cond --> and Cond, freeze(T)
11510
+ // select Cond, T, 0 --> and Cond, freeze(T)
11511
11511
if (Cond == F || isNullOrNullSplat(F, /* AllowUndefs */ true))
11512
- return matcher.getNode(ISD::AND, DL, VT, Cond, T );
11512
+ return matcher.getNode(ISD::AND, DL, VT, Cond, DAG.getFreeze(T) );
11513
11513
11514
- // select Cond, T, 1 --> or (not Cond), T
11514
+ // select Cond, T, 1 --> or (not Cond), freeze(T)
11515
11515
if (isOneOrOneSplat(F, /* AllowUndefs */ true)) {
11516
11516
SDValue NotCond =
11517
11517
matcher.getNode(ISD::XOR, DL, VT, Cond, DAG.getAllOnesConstant(DL, VT));
11518
- return matcher.getNode(ISD::OR, DL, VT, NotCond, T );
11518
+ return matcher.getNode(ISD::OR, DL, VT, NotCond, DAG.getFreeze(T) );
11519
11519
}
11520
11520
11521
- // select Cond, 0, F --> and (not Cond), F
11521
+ // select Cond, 0, F --> and (not Cond), freeze(F)
11522
11522
if (isNullOrNullSplat(T, /* AllowUndefs */ true)) {
11523
11523
SDValue NotCond =
11524
11524
matcher.getNode(ISD::XOR, DL, VT, Cond, DAG.getAllOnesConstant(DL, VT));
11525
- return matcher.getNode(ISD::AND, DL, VT, NotCond, F );
11525
+ return matcher.getNode(ISD::AND, DL, VT, NotCond, DAG.getFreeze(F) );
11526
11526
}
11527
11527
11528
11528
return SDValue();
@@ -11550,37 +11550,37 @@ static SDValue foldVSelectToSignBitSplatMask(SDNode *N, SelectionDAG &DAG) {
11550
11550
else
11551
11551
return SDValue();
11552
11552
11553
- // (Cond0 s< 0) ? N1 : 0 --> (Cond0 s>> BW-1) & N1
11553
+ // (Cond0 s< 0) ? N1 : 0 --> (Cond0 s>> BW-1) & freeze(N1)
11554
11554
if (isNullOrNullSplat(N2)) {
11555
11555
SDLoc DL(N);
11556
11556
SDValue ShiftAmt = DAG.getConstant(VT.getScalarSizeInBits() - 1, DL, VT);
11557
11557
SDValue Sra = DAG.getNode(ISD::SRA, DL, VT, Cond0, ShiftAmt);
11558
- return DAG.getNode(ISD::AND, DL, VT, Sra, N1 );
11558
+ return DAG.getNode(ISD::AND, DL, VT, Sra, DAG.getFreeze(N1) );
11559
11559
}
11560
11560
11561
- // (Cond0 s< 0) ? -1 : N2 --> (Cond0 s>> BW-1) | N2
11561
+ // (Cond0 s< 0) ? -1 : N2 --> (Cond0 s>> BW-1) | freeze(N2)
11562
11562
if (isAllOnesOrAllOnesSplat(N1)) {
11563
11563
SDLoc DL(N);
11564
11564
SDValue ShiftAmt = DAG.getConstant(VT.getScalarSizeInBits() - 1, DL, VT);
11565
11565
SDValue Sra = DAG.getNode(ISD::SRA, DL, VT, Cond0, ShiftAmt);
11566
- return DAG.getNode(ISD::OR, DL, VT, Sra, N2 );
11566
+ return DAG.getNode(ISD::OR, DL, VT, Sra, DAG.getFreeze(N2) );
11567
11567
}
11568
11568
11569
11569
// If we have to invert the sign bit mask, only do that transform if the
11570
11570
// target has a bitwise 'and not' instruction (the invert is free).
11571
- // (Cond0 s< -0) ? 0 : N2 --> ~(Cond0 s>> BW-1) & N2
11571
+ // (Cond0 s< -0) ? 0 : N2 --> ~(Cond0 s>> BW-1) & freeze(N2)
11572
11572
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
11573
11573
if (isNullOrNullSplat(N1) && TLI.hasAndNot(N1)) {
11574
11574
SDLoc DL(N);
11575
11575
SDValue ShiftAmt = DAG.getConstant(VT.getScalarSizeInBits() - 1, DL, VT);
11576
11576
SDValue Sra = DAG.getNode(ISD::SRA, DL, VT, Cond0, ShiftAmt);
11577
11577
SDValue Not = DAG.getNOT(DL, Sra, VT);
11578
- return DAG.getNode(ISD::AND, DL, VT, Not, N2 );
11578
+ return DAG.getNode(ISD::AND, DL, VT, Not, DAG.getFreeze(N2) );
11579
11579
}
11580
11580
11581
11581
// TODO: There's another pattern in this family, but it may require
11582
11582
// implementing hasOrNot() to check for profitability:
11583
- // (Cond0 s> -1) ? -1 : N2 --> ~(Cond0 s>> BW-1) | N2
11583
+ // (Cond0 s> -1) ? -1 : N2 --> ~(Cond0 s>> BW-1) | freeze(N2)
11584
11584
11585
11585
return SDValue();
11586
11586
}
0 commit comments