[llvm] [SystemZ] Fix Operand Retrieval for Vector Reduction Intrinsic in `shouldExpandReduction` (PR #88874)

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 04:28:56 PDT 2024


================
@@ -1322,26 +1323,30 @@ SystemZTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
   return BaseT::getIntrinsicInstrCost(ICA, CostKind);
 }
 
+// Find the type of the vector operand indicated by index.
+// Asserts that the operand indicated is actually a vector.
+FixedVectorType *getOperandVectorType(const IntrinsicInst *II, unsigned Index) {
+  auto *T = II->getOperand(Index)->getType();
+  assert(T->isVectorTy());
+  return cast<FixedVectorType>(T);
+}
+
----------------
JonPsson1 wrote:

Since the intrinsic is defined so that it must have a vector of integer values, we do not need to verify this. I think this should be the same for other intrinsics as well. Did you try to use some other kind of type and compile it with 'opt'? I think it will verify the module and report broken IR.

Given that we don't need to have an extra redundant check here, I think this method (at least for now) is a bit superfluous - probably easier to just get the type directly in one line below.

https://github.com/llvm/llvm-project/pull/88874


More information about the llvm-commits mailing list