That is pretty common for clang to produce code like
(shl %x, (and %amt, 31)). In this situation we can still perform
trunc (shl) into shl (trunc) conversion given the known value
range of shift amount.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/AMDGPU/AMDGPUISelLowering.cpp | ||
---|---|---|
2761–2762 ↗ | (On Diff #104306) | This exact combine is already done in DAGCombiner: // trunc (shl x, K) -> shl (trunc x), K => K < VT.getScalarSizeInBits() Why isn't it triggering? Is the other combine you added missing an AddToWorklist or something? |
lib/Target/AMDGPU/AMDGPUISelLowering.cpp | ||
---|---|---|
2761–2762 ↗ | (On Diff #104306) | Ah. That one only works with constants. |
lib/Target/AMDGPU/AMDGPUISelLowering.cpp | ||
---|---|---|
2761–2762 ↗ | (On Diff #104306) | Do you want me to transfer it there? |
lib/Target/AMDGPU/AMDGPUISelLowering.cpp | ||
---|---|---|
2761–2762 ↗ | (On Diff #104306) | Yes, it would be better if it was all in one place |
Comment Actions
Moved implementation into DAGCombiner and replaced existing DAGCombiner's optimization which was only capable of dealing with constant shift amounts.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8215 ↗ | (On Diff #104329) | Will this regress the constant vector case? |
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8215 ↗ | (On Diff #104329) | No. |
Comment Actions
The vector case won't matter for us, but maybe for other targets with legal vector operations