If the bias is zero, we can remove it from the image instruction.
Also move the image optimizations to IR combines.
Details
- Reviewers
arsenm rampitec foad - Commits
- rG603d18033c51: [AMDGPU][InstCombine] Remove zero LOD bias
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | ||
---|---|---|
4455 | The DAG version doesn't have the isNegative check? |
Remove the isNegative check from GlobalISel and add tests to the pre-committed test files.
Could this be done at the IR level instead, in AMDGPUInstCombineIntrinsic?
I think so. All the three combines (l -> lz, mip -> nomip and bias -> nobias) can probably be combines. It’s on my todo list, do you think it should be done before this patch?
I think optimizations should only be repeated in codegen if they could plausibly show up as a result of legalization exposing the pattern
Oh, my question was meant to ask if I should do 1. push this patch, 2. move all combines to IR combines, or if it should be 1. move the existing optimizations to IR combines, 2. implement the zero bias optimization as IR combine.
I think optimizations should only be repeated in codegen if they could plausibly show up as a result of legalization exposing the pattern
I interpret this as: We shall implement these three optimizations as IR combines and remove them from the code generation (as compared to duplicate the code as IR combine and leave it in codgen)?
It seems a bit silly to review and push this code if you are planning to remove it again. But I don't really mind.
Move all image optimizations to IR combines and add image_gather instructions to zero-bias optimization.
I like it.
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp | ||
---|---|---|
103 ↗ | (On Diff #395624) | I don't understand why this needs to be a template, if FuncT is always the same as you have documented. |
143 ↗ | (On Diff #395624) | Is it possible that more than one of these optimizations applies to a single intrinsic call, and if so do you handle that case correctly? (E.g. when you apply one optimization, does simplifyAMDGCNImageIntrinsic get called again to apply other optimizations to the new intrinsic?) |
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp | ||
---|---|---|
143 ↗ | (On Diff #395624) | Yes, it gets called again. (E.g. the combines for Intrinsic::amdgcn_fma_legacy also return early when one of them matches.) |
llvm/test/CodeGen/AMDGPU/image_ls_mipmap_zero.ll | ||
132 ↗ | (On Diff #395624) | I deleted them because they started failing for me. I guess the codegen tests don’t run the combines? (Anyway, this moved to D116116) |
The DAG version doesn't have the isNegative check?