[llvm] [AMDGPU] Make v2f32 legal for G_FNEG and G_FABS and pattern update (PR #195419)

Changpeng Fang via llvm-commits llvm-commits at lists.llvm.org
Sat May 2 00:24:37 PDT 2026


================
@@ -1030,11 +1030,14 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
     .scalarize(0)
     .clampScalar(0, ST.has16BitInsts() ? S16 : S32, S64);
 
-  getActionDefinitionsBuilder({G_FNEG, G_FABS})
-    .legalFor(FPTypesPK16)
-    .clampMaxNumElementsStrict(0, S16, 2)
-    .scalarize(0)
-    .clampScalar(0, S16, S64);
+  auto &FNegAbs = getActionDefinitionsBuilder({G_FNEG, G_FABS});
+  FNegAbs.legalFor(FPTypesPK16)
+      .legalFor(ST.hasPackedFP32Ops(), {V2S32})
----------------
changpeng wrote:

I think it works fin, as long the the type is different. Here is an existing example:

getActionDefinitionsBuilder(G_PHI)
      .legalFor({S32, S64, V2S16, S16, V4S16, S1, S128, S256})
      .legalFor(AllS32Vectors)
      .legalFor(AllS64Vectors)
      .legalFor(AddrSpaces64)
      .legalFor(AddrSpaces32)
      .legalFor(AddrSpaces128)

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


More information about the llvm-commits mailing list