[llvm] [AMDGPU] expand-fp: unify scalarization (NFC) (PR #158588)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 03:45:59 PDT 2025


================
@@ -948,12 +927,21 @@ static void scalarize(Instruction *I, SmallVectorImpl<Instruction *> &Replace) {
   Value *Result = PoisonValue::get(VTy);
   for (unsigned Idx = 0; Idx < NumElements; ++Idx) {
     Value *Ext = Builder.CreateExtractElement(I->getOperand(0), Idx);
-    Value *Cast = Builder.CreateCast(cast<CastInst>(I)->getOpcode(), Ext,
-                                     I->getType()->getScalarType());
-    Result = Builder.CreateInsertElement(Result, Cast, Idx);
-    if (isa<Instruction>(Cast))
-      Replace.push_back(cast<Instruction>(Cast));
+    Value *Op;
----------------
arsenm wrote:

We really could use some utility functions for scalarization, there are at least 4 passes all doing approximately the same thing 

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


More information about the llvm-commits mailing list