From b68b94f6f40b4f5d89fc3bba819c2d134ff4fc69 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 17 Apr 2023 14:42:14 +0100 Subject: [PATCH] [Support] Add MVT::getDoubleNumVectorElementsVT helper. Matches the equivalent EVT::getDoubleNumVectorElementsVT helper. This allows us to consistently MVT instead of EVT in the combinePTESTCC method. --- llvm/include/llvm/Support/MachineValueType.h | 8 ++++++++ llvm/lib/Target/X86/X86ISelLowering.cpp | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Support/MachineValueType.h b/llvm/include/llvm/Support/MachineValueType.h index eb97239..2a2ab24 100644 --- a/llvm/include/llvm/Support/MachineValueType.h +++ b/llvm/include/llvm/Support/MachineValueType.h @@ -534,6 +534,14 @@ namespace llvm { return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2)); } + // Return a VT for a vector type with the same element type but + // double the number of elements. + MVT getDoubleNumVectorElementsVT() const { + MVT EltVT = getVectorElementType(); + auto EltCnt = getVectorElementCount(); + return MVT::getVectorVT(EltVT, EltCnt * 2); + } + /// Returns true if the given vector is a power of 2. bool isPow2VectorType() const { unsigned NElts = getVectorMinNumElements(); diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index ac94dee..4f6462d 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -47304,10 +47304,10 @@ static SDValue combinePTESTCC(SDValue EFLAGS, X86::CondCode &CC, // TESTZ: ZF = (Op0 & Op1) == 0 // TESTC: CF = (~Op0 & Op1) == 0 // TESTNZC: ZF == 0 && CF == 0 - EVT VT = EFLAGS.getValueType(); + MVT VT = EFLAGS.getSimpleValueType(); SDValue Op0 = EFLAGS.getOperand(0); SDValue Op1 = EFLAGS.getOperand(1); - EVT OpVT = Op0.getValueType(); + MVT OpVT = Op0.getSimpleValueType(); // TEST*(~X,Y) == TEST*(X,Y) if (SDValue NotOp0 = IsNOT(Op0, DAG)) { @@ -47442,7 +47442,7 @@ static SDValue combinePTESTCC(SDValue EFLAGS, X86::CondCode &CC, Src1 = getSplitVectorSrc(peekThroughBitcasts(Src1.getOperand(0)), peekThroughBitcasts(Src1.getOperand(1)), true); if (Src0 && Src1) { - EVT OpVT2 = OpVT.getDoubleNumVectorElementsVT(*DAG.getContext()); + MVT OpVT2 = OpVT.getDoubleNumVectorElementsVT(); return DAG.getNode(EFLAGS.getOpcode(), SDLoc(EFLAGS), VT, DAG.getBitcast(OpVT2, Src0), DAG.getBitcast(OpVT2, Src1)); -- 2.7.4