|
24 | 24 | #include "llvm/CodeGen/MachineJumpTableInfo.h"
|
25 | 25 | #include "llvm/CodeGen/MachineModuleInfo.h"
|
26 | 26 | #include "llvm/CodeGen/MachineRegisterInfo.h"
|
| 27 | +#include "llvm/CodeGen/SDPatternMatch.h" |
27 | 28 | #include "llvm/CodeGen/SelectionDAG.h"
|
28 | 29 | #include "llvm/CodeGen/SelectionDAGNodes.h"
|
29 | 30 | #include "llvm/IR/DiagnosticInfo.h"
|
|
37 | 38 | #include "llvm/Support/MathExtras.h"
|
38 | 39 | #include "llvm/Target/TargetOptions.h"
|
39 | 40 | using namespace llvm;
|
40 |
| - |
41 | 41 | #define DEBUG_TYPE "wasm-lower"
|
42 | 42 |
|
43 | 43 | WebAssemblyTargetLowering::WebAssemblyTargetLowering(
|
@@ -3243,34 +3243,29 @@ static SDValue performAnyTrueCombine(SDNode *N, SelectionDAG &DAG) {
|
3243 | 3243 | // any_true (setcc <X>, 0, eq)
|
3244 | 3244 | // => not (all_true X)
|
3245 | 3245 |
|
| 3246 | + using namespace llvm::SDPatternMatch; |
| 3247 | + |
3246 | 3248 | SDLoc DL(N);
|
3247 | 3249 | assert(N->getOpcode() == ISD::INTRINSIC_WO_CHAIN);
|
3248 | 3250 | if (N->getConstantOperandVal(0) != Intrinsic::wasm_anytrue)
|
3249 | 3251 | return SDValue();
|
3250 | 3252 |
|
3251 |
| - SDValue SetCC = N->getOperand(1); |
3252 |
| - if (SetCC.getOpcode() != ISD::SETCC) |
| 3253 | + SDValue LHS; |
| 3254 | + if (!sd_match(N->getOperand(1), m_c_SetCC(m_Value(LHS), m_Zero(), |
| 3255 | + m_SpecificCondCode(ISD::SETEQ)))) |
3253 | 3256 | return SDValue();
|
3254 | 3257 |
|
3255 |
| - SDValue LHS = SetCC->getOperand(0); |
3256 |
| - SDValue RHS = SetCC->getOperand(1); |
3257 |
| - ISD::CondCode Cond = cast<CondCodeSDNode>(SetCC->getOperand(2))->get(); |
3258 | 3258 | EVT LT = LHS.getValueType();
|
3259 | 3259 | unsigned NumElts = LT.getVectorNumElements();
|
3260 |
| - if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) |
3261 |
| - return SDValue(); |
3262 |
| - |
3263 |
| - EVT Width = MVT::getIntegerVT(128 / NumElts); |
3264 |
| - |
3265 |
| - if (!isNullOrNullSplat(RHS) || Cond != ISD::SETEQ) |
| 3260 | + if (LT.getScalarSizeInBits() > 128 / NumElts) |
3266 | 3261 | return SDValue();
|
3267 | 3262 |
|
3268 | 3263 | SDValue Ret = DAG.getZExtOrTrunc(
|
3269 | 3264 | DAG.getNode(
|
3270 | 3265 | ISD::INTRINSIC_WO_CHAIN, DL, MVT::i32,
|
3271 |
| - {DAG.getConstant(Intrinsic::wasm_alltrue, DL, MVT::i32), |
3272 |
| - DAG.getSExtOrTrunc(LHS, DL, LT.changeVectorElementType(Width))}), |
| 3266 | + {DAG.getConstant(Intrinsic::wasm_alltrue, DL, MVT::i32), LHS}), |
3273 | 3267 | DL, MVT::i1);
|
| 3268 | + |
3274 | 3269 | Ret = DAG.getNOT(DL, Ret, MVT::i1);
|
3275 | 3270 | return DAG.getZExtOrTrunc(Ret, DL, N->getValueType(0));
|
3276 | 3271 | }
|
@@ -3437,7 +3432,7 @@ WebAssemblyTargetLowering::PerformDAGCombine(SDNode *N,
|
3437 | 3432 | case ISD::TRUNCATE:
|
3438 | 3433 | return performTruncateCombine(N, DCI);
|
3439 | 3434 | case ISD::INTRINSIC_WO_CHAIN: {
|
3440 |
| - if (auto AnyTrueCombine = performAnyTrueCombine(N, DCI.DAG)) |
| 3435 | + if (SDValue AnyTrueCombine = performAnyTrueCombine(N, DCI.DAG)) |
3441 | 3436 | return AnyTrueCombine;
|
3442 | 3437 | return performLowerPartialReduction(N, DCI.DAG);
|
3443 | 3438 | }
|
|
0 commit comments