The hardware spec require src0 of s_cmpk should be a register. So, we
should not optimize s_cmp to s_cmpk if src0 is not register.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | ||
---|---|---|
6 | positive checks are more useful. Also you can just generate these checks. Can you reproduce this with an IR test too? |
llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | ||
---|---|---|
6 | will try positive check, how to generate the checks? could you give a little bit more info? The original test case that hit the issue is over-complex I think. Normally, a constant expression at IR level is easy to be optimized off by the middle-end. so I think a .mir test is enough for this issue. |
llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | ||
---|---|---|
6 | So what is the context this appears? Why wasn't it optimized out? |
llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | ||
---|---|---|
6 | well I didn't carefully check the program yet to understand why the optimization algorithms in llvm fails to optimize the program. but I think that is another problem that worth a careful investigation. I will investigate and try to optimize it off later. But I think this patch can be merged, right? can anyone help to merge? I don't have commit access. |
llvm/test/CodeGen/AMDGPU/cmp_shrink.mir | ||
---|---|---|
6 | @arsenm The issue occurs when running vulkancts again AMD open-source vulkan driver. I did a little more check, the test-case has ~40 BBs and lots of phi instructions which is later simplified and proved to be constant. And the problem may be because LLPC choose a subset of llvm optimization passes considering compilation time (https://github.com/GPUOpen-Drivers/llpc/blob/dev/lgc/patch/Patch.cpp#L223). I tried use LLVM standard set of passes, the constant was optimized off. I think the optimization passes for vulkan may need further tuning to reach a better trade-off between compile-time and quality of generated code. |
Do you have commit access? If not, I can commit this. See https://llvm.org/docs/DeveloperPolicy.html#id16 if you want to request access.
@foad I don't have commit access, please go help push the patch if you think this is ok. I will apply commit access after some patches accepted. Thanks for pointing the useful link:)
Committed in 1658b8d7ddb65eb78e1304b009f1043ab6d9463f (sorry I forgot to put a link to this review in the commit message).
positive checks are more useful. Also you can just generate these checks. Can you reproduce this with an IR test too?