@@ -3213,26 +3213,18 @@ static SDValue performTruncateCombine(SDNode *N,
3213
3213
return truncateVectorWithNARROW (OutVT, In, DL, DAG);
3214
3214
}
3215
3215
3216
- static SDValue performVSelectCombine (SDNode *N, SelectionDAG &DAG) {
3216
+ static SDValue performVSelectCombine (SDNode *N,
3217
+ TargetLowering::DAGCombinerInfo &DCI) {
3217
3218
// In the tablegen.td, vselect A B C -> bitselect B C A
3218
3219
3219
- // SCENARIO A
3220
- // vselect <0>, X, Y
3221
- // -> bitselect X, Y, <0>
3222
- // -> or (AND(X, <0>), AND(<Y>, !<0>))
3223
- // -> or (0, AND(<Y>, !<0>))
3224
- // -> AND(Y, !<0>)
3225
- // -> AND(Y, 1)
3226
- // -> Y
3227
-
3228
- // SCENARIO B
3220
+ // SCENARIO 1
3229
3221
// vselect Y, <0>, X
3230
3222
// -> bitselect <0>, X, Y
3231
3223
// -> or (AND(<0>, Y), AND(<X>, !<Y>))
3232
3224
// -> or (0, AND(<X>, !<Y>))
3233
3225
// -> AND(<X>, !<Y>)
3234
3226
3235
- // SCENARIO C
3227
+ // SCENARIO 2
3236
3228
// vselect X, Y, <0>
3237
3229
// -> bitselect Y, <0>, X
3238
3230
// -> or (AND(Y, X), AND(<0>, !X))
@@ -3242,28 +3234,28 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
3242
3234
using namespace llvm ::SDPatternMatch;
3243
3235
assert (N->getOpcode () == ISD::VSELECT);
3244
3236
3237
+ // INFO: There is degradation in performance pre-legalization,
3238
+ // fpclamptosat_vec.ll
3239
+ if (DCI.isBeforeLegalize ())
3240
+ return SDValue ();
3241
+
3245
3242
SDLoc DL (N);
3246
3243
3247
3244
SDValue Cond = N->getOperand (0 ), LHS = N->getOperand (1 ),
3248
3245
RHS = N->getOperand (2 );
3249
3246
EVT NVT = N->getValueType (0 );
3250
-
3247
+ SelectionDAG &DAG = DCI. DAG ;
3251
3248
APInt SplatValue;
3252
3249
3253
- // SCENARIO A
3254
- if (ISD::isConstantSplatVector (Cond.getNode (), SplatValue) &&
3255
- SplatValue.isZero ())
3256
- return RHS;
3257
-
3258
- // SCENARIO B
3250
+ // SCENARIO 1
3259
3251
if (ISD::isConstantSplatVector (LHS.getNode (), SplatValue) &&
3260
3252
SplatValue.isZero ())
3261
3253
return DAG.getNode (
3262
3254
ISD::AND, DL, NVT,
3263
3255
{RHS, DAG.getSExtOrTrunc (DAG.getNOT (DL, Cond, Cond.getValueType ()), DL,
3264
3256
NVT)});
3265
3257
3266
- // SCENARIO C
3258
+ // SCENARIO 2
3267
3259
if (ISD::isConstantSplatVector (RHS.getNode (), SplatValue) &&
3268
3260
SplatValue.isZero ())
3269
3261
return DAG.getNode (ISD::AND, DL, NVT,
@@ -3567,7 +3559,7 @@ WebAssemblyTargetLowering::PerformDAGCombine(SDNode *N,
3567
3559
default :
3568
3560
return SDValue ();
3569
3561
case ISD::VSELECT:
3570
- return performVSelectCombine (N, DCI. DAG );
3562
+ return performVSelectCombine (N, DCI);
3571
3563
case ISD::BITCAST:
3572
3564
return performBitcastCombine (N, DCI);
3573
3565
case ISD::SETCC:
0 commit comments