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

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


================
@@ -1004,55 +1002,37 @@ static bool runImpl(Function &F, const TargetLowering &TLI,
     return false;
 
   for (auto &I : instructions(F)) {
-    switch (I.getOpcode()) {
-    case Instruction::FRem: {
-      Type *Ty = I.getType();
-      // TODO: This pass doesn't handle scalable vectors.
-      if (Ty->isScalableTy())
-        continue;
-
-      if (targetSupportsFrem(TLI, Ty) ||
-          !FRemExpander::canExpandType(Ty->getScalarType()))
-        continue;
-
-      Replace.push_back(&I);
-      Modified = true;
+    Type *Ty = I.getType();
+    // TODO: This pass doesn't handle scalable vectors.
+    if (Ty->isScalableTy())
+      continue;
 
+    switch (I.getOpcode()) {
+    case Instruction::FRem:
+      if (!targetSupportsFrem(TLI, Ty) &&
+          FRemExpander::canExpandType(Ty->getScalarType())) {
+        enqueueInstruction(I, Replace, ReplaceVector);
----------------
arsenm wrote:

Not really sure why this needs a queue, can't you just directly scalarize as you go (IIRC Scalarizer and AMDGPUCodeGenPrepare do the same without a queue) 

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


More information about the llvm-commits mailing list