[AMDGPU] Use d16 flag for image.sample instructions
authorMariusz Sikora <mariusz.sikora@amd.com>
Mon, 25 Apr 2022 11:57:27 +0000 (12:57 +0100)
committerMariusz Sikora <mariusz.sikora@amd.com>
Thu, 5 May 2022 04:29:19 +0000 (06:29 +0200)
commit2417de2758c306c5509782400ba9e0bb70851989
treeeb269a76503ef0342b6e097f1afbea3a97df67c1
parent2407c13aa4a42f3a3438ae2d03fa38df0a5fd30b
[AMDGPU] Use d16 flag for image.sample instructions

Image.sample instruction can be forced to return half type instead of
float when d16 flag is enabled.

This patch adds new pattern in InstCombine to detect if output of
image.sample is used later only by fptrunc which converts the type
from float to half. If pattern is detected then fptrunc and image.sample
are combined to single image.sample which is returning half type.
Later in Lowering part d16 flag is added to image sample intrinsic.

Differential Revision: https://reviews.llvm.org/D124232
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/test/Transforms/InstCombine/AMDGPU/image-d16.ll [new file with mode: 0644]