[llvm] [AMDGPU][AMDGPULateCodeGenPrepare] Combine scalarized selects back into vector selects (PR #173990)

Pankaj Dwivedi via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 30 08:12:59 PST 2025


================
@@ -551,6 +593,113 @@ bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) {
   return true;
 }
 
+bool AMDGPULateCodeGenPrepare::tryCombineSelectsFromBitcast(BitCastInst &BC) {
+  auto *SrcVecTy = dyn_cast<FixedVectorType>(BC.getSrcTy());
+  auto *DstVecTy = dyn_cast<FixedVectorType>(BC.getDestTy());
+  if (!SrcVecTy || !DstVecTy)
+    return false;
+
+  // Must be: bitcast <N x i32> to <M x i8>
+  if (!SrcVecTy->getElementType()->isIntegerTy(32) ||
+      !DstVecTy->getElementType()->isIntegerTy(8))
----------------
PankajDwivedi-25 wrote:

> Have you checked what happens with other combinations? Like `64/8` `64/16` `32/16` ?

possibly should work for other as well. Let me update the patch and add the test case for each of these case.

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


More information about the llvm-commits mailing list