[llvm] [AMDGPU][DAGCombiner][GlobalISel] Prevent FMA contraction when multiply cannot be eliminated (PR #169735)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 09:06:37 PST 2025


================
@@ -0,0 +1,2385 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+
+; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx9-generic < %s | FileCheck -check-prefixes=GFX9-SDAG %s
+; RUN: llc -global-isel=1 -global-isel-abort=2 -mtriple=amdgcn -mcpu=gfx9-generic < %s | FileCheck -check-prefixes=GFX9-GISEL %s
+; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx1010  < %s | FileCheck -check-prefixes=GFX10-SDAG %s
+; RUN: llc -global-isel=1 -global-isel-abort=2 -mtriple=amdgcn -mcpu=gfx1010 < %s | FileCheck -check-prefixes=GFX10-GISEL %s
+; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx11-generic < %s | FileCheck -check-prefixes=GFX11-SDAG %s
+; RUN: llc -global-isel=1 -global-isel-abort=2 -mtriple=amdgcn -mcpu=gfx11-generic < %s | FileCheck -check-prefixes=GFX11-GISEL %s
+; RUN: llc -global-isel=0 -mtriple=amdgcn -mcpu=gfx12-generic < %s | FileCheck -check-prefixes=GFX12-SDAG %s
+; RUN: llc -global-isel=1 -global-isel-abort=2 -mtriple=amdgcn -mcpu=gfx12-generic < %s | FileCheck -check-prefixes=GFX12-GISEL %s
+
+; Test that FMA contraction is prevented when multiply has uses that cannot
+; all be contracted, which would result in duplicating the multiply without
+; reducing total operation count.
+
+; Test case: multiply has one non-contractable use (another multiply)
+; Should NOT contract the fadd since the multiply would be duplicated
+define amdgpu_kernel void @mul_has_noncontractable_use(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %in) #0 {
----------------
arsenm wrote:

Better to test this with non-kernel functions with function arguments instead of loads for the source values 

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


More information about the llvm-commits mailing list