[Support] Add MVT::getDoubleNumVectorElementsVT helper.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 17 Apr 2023 13:42:14 +0000 (14:42 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 17 Apr 2023 13:42:19 +0000 (14:42 +0100)
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
llvm/lib/Target/X86/X86ISelLowering.cpp

index eb97239..2a2ab24 100644 (file)
@@ -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();
index ac94dee..4f6462d 100644 (file)
@@ -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));