|
19 | 19 | #include "WebAssemblyTargetMachine.h"
|
20 | 20 | #include "WebAssemblyUtilities.h"
|
21 | 21 | #include "llvm/CodeGen/CallingConvLower.h"
|
| 22 | +#include "llvm/CodeGen/ISDOpcodes.h" |
22 | 23 | #include "llvm/CodeGen/MachineFrameInfo.h"
|
23 | 24 | #include "llvm/CodeGen/MachineInstrBuilder.h"
|
24 | 25 | #include "llvm/CodeGen/MachineJumpTableInfo.h"
|
@@ -3248,6 +3249,37 @@ static SDValue performSETCCCombine(SDNode *N,
|
3248 | 3249 | ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
|
3249 | 3250 | SDLoc DL(N);
|
3250 | 3251 | EVT VT = N->getValueType(0);
|
| 3252 | + // N LHS LhsL LhsLL LhsLR InnerCond RHS Cond |
| 3253 | + // setcc (iN (bitcast (setcc vNi1 (vNiY X), <vNiY 0>, eq)), 0, eq |
| 3254 | + // => all_true (vNi1 X) |
| 3255 | + if (DCI.isBeforeLegalize() && VT.isScalarInteger() && (Cond == ISD::SETEQ) && |
| 3256 | + (isNullConstant(RHS)) && LHS->getOpcode() == ISD::BITCAST) { |
| 3257 | + SDValue LhsL = LHS.getOperand(0); |
| 3258 | + EVT LhsLType = LhsL.getValueType(); |
| 3259 | + if (LhsL.getOpcode() == ISD::SETCC) { |
| 3260 | + ISD::CondCode InnerCond = |
| 3261 | + cast<CondCodeSDNode>(LhsL->getOperand(2))->get(); |
| 3262 | + if (InnerCond == ISD::SETEQ) { |
| 3263 | + SDValue LhsLL = LhsL.getOperand(0); // vNiY X |
| 3264 | + SDValue LhsLR = LhsL.getOperand(1); // <0> |
| 3265 | + unsigned NumElts = LhsLType.getVectorNumElements(); |
| 3266 | + bool Vectorizable = |
| 3267 | + NumElts == 2 || NumElts == 4 || NumElts == 8 || NumElts == 16; |
| 3268 | + EVT Width = MVT::getIntegerVT(128 / NumElts); |
| 3269 | + |
| 3270 | + if (Vectorizable && LhsLR.getOpcode() == ISD::BUILD_VECTOR && |
| 3271 | + LhsLType.isFixedLengthVector()) { |
| 3272 | + return DAG.getZExtOrTrunc( |
| 3273 | + DAG.getNode( |
| 3274 | + ISD::INTRINSIC_WO_CHAIN, DL, MVT::i32, |
| 3275 | + {DAG.getConstant(Intrinsic::wasm_alltrue, DL, MVT::i32), |
| 3276 | + DAG.getSExtOrTrunc( |
| 3277 | + LhsLL, DL, LhsLType.changeVectorElementType(Width))}), |
| 3278 | + DL, MVT::i1); |
| 3279 | + } |
| 3280 | + } |
| 3281 | + } |
| 3282 | + } |
3251 | 3283 |
|
3252 | 3284 | // setcc (iN (bitcast (vNi1 X))), 0, ne
|
3253 | 3285 | // ==> any_true (vNi1 X)
|
|
0 commit comments