[llvm] [AMDGPU] Elide bitcast fold i64 imm to build_vector (PR #154115)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 06:51:00 PDT 2025


================
@@ -14584,13 +14584,39 @@ SITargetLowering::performExtractVectorEltCombine(SDNode *N,
     return V;
   }
 
+  // EXTRACT_VECTOR_ELT (v2i32 bitcast (i64/f64:k), Idx)
+  //   =>
+  // i32:Lo(k) if Idx == 0, or
+  // i32:Hi(k) if Idx == 1
+  auto *Idx = dyn_cast<ConstantSDNode>(N->getOperand(1));
+  if (Vec.getOpcode() == ISD::BITCAST && VecVT == MVT::v2i32 && Idx) {
+    SDLoc SL(N);
+    SDValue PeekThrough = peekThroughBitcasts(Vec);
----------------
arsenm wrote:

This is checking the same bitcast twice. Directly use Vec.getOperand(0)? Or check if peekThroughBitcasts changed the value. The way it is currently you may be looking at unexpected nodes and types if multiple bitcasts were to appear in sequence 

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


More information about the llvm-commits mailing list