[llvm] [NVPTX] Eliminate `prmt`s that result from `BUILD_VECTOR` of `LoadV2` (PR #149581)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 18 13:11:06 PDT 2025


================
@@ -5833,6 +5834,80 @@ PerformBUILD_VECTORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI) {
   return DAG.getBitcast(VT, PRMT);
 }
 
+static SDValue
+PerformBUILD_VECTOROfTargetLoadCombine(SDNode *N,
+                                       TargetLowering::DAGCombinerInfo &DCI) {
+  // Match: BUILD_VECTOR of v4i8, where first two elements are from a
+  // NVPTXISD::LoadV2 or NVPTXISD::LDUV2 of i8, and the last two elements are
+  // zero constants. Replace with: zext the loaded i16 to i32, and return as a
+  // bitcast to v4i8.
+  EVT VT = N->getValueType(0);
+  if (VT != MVT::v4i8)
+    return SDValue();
+  // Check operands: [0]=lo, [1]=hi
+  SDValue Op0 = N->getOperand(0);
+  SDValue Op1 = N->getOperand(1);
+  // Check that Op0 and Op1 are from the same NVPTXISD::LoadV2 or
+  // NVPTXISD::LDUV2
+  if (Op0.getNode() != Op1.getNode())
----------------
justinfargnoli wrote:

Bug: we need to check that they're different values from the same node. 

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


More information about the llvm-commits mailing list