[all-commits] [llvm/llvm-project] 0defde: [AMDGPU] Support D16 folding for image.sample with...

Harrison Hao via All-commits all-commits at lists.llvm.org
Tue Jun 17 18:00:28 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0defde8e06338cbe968d55d1d9e8581d55f3ae2b
      https://github.com/llvm/llvm-project/commit/0defde8e06338cbe968d55d1d9e8581d55f3ae2b
  Author: Harrison Hao <57025411+harrisonGPU at users.noreply.github.com>
  Date:   2025-06-18 (Wed, 18 Jun 2025)

  Changed paths:
    M llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
    M llvm/test/Transforms/InstCombine/AMDGPU/image-d16.ll

  Log Message:
  -----------
  [AMDGPU] Support D16 folding for image.sample with multiple extractelement and fptrunc users (#141758)

Now we only support D16 folding for `image sample` instructions with a
single user: a `fptrunc` to half.
However, we can actually support D16 folding for image.sample
instructions with multiple users,
as long as each user follows the pattern of extractelement followed by
fptrunc to half.
For example:
```
  %sample = call <4 x float> @llvm.amdgcn.image.sample
  %e0 = extractelement <4 x float> %sample, i32 0
  %h0 = fptrunc float %e0 to half
  %e1 = extractelement <4 x float> %sample, i32 1
  %h1 = fptrunc float %e1 to half
  %e2 = extractelement <4 x float> %sample, i32 2
  %h2 = fptrunc float %e2 to half
```
This change enables D16 folding for such cases and avoids generating
`v_cvt_f16_f32_e32` instructions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list