[llvm] [AMDGPU] Model the cost of the expanded integer to/from floating point casts (PR #223572)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 03:56:16 PDT 2026


michaelselehov wrote:

The cost model looks very precise in pricing. The problem is that the scalar counterpart isn't. Hence SLP starts picking scalar form when the HW wants vector. 

See this example:
```
define void @f(ptr addrspace(1) %in, ptr addrspace(1) %out) {
  %a1 = getelementptr inbounds i8, ptr addrspace(1) %in, i64 1
  %l0 = load i8, ptr addrspace(1) %in, align 4
  %l1 = load i8, ptr addrspace(1) %a1
  %c0 = sitofp i8 %l0 to float
  %c1 = sitofp i8 %l1 to float
  %o1 = getelementptr inbounds float, ptr addrspace(1) %out, i64 1
  store float %c0, ptr addrspace(1) %out, align 8
  store float %c1, ptr addrspace(1) %o1
  ret void
}
```

`opt -passes=slp-vectorizer -mtriple=amdgcn -mcpu=gfx942 -S` has vector form before the patch and scalar form after. Backend then vectorizes loads and stores anyway, but it's probably better to fix the scalar counterpart. Maybe as a follow-up.

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


More information about the llvm-commits mailing list