This sequence of instructions can be simplified if they are single use and
some operands are constants. Additional combines may be applied afterwards.
Details
Diff Detail
Event Timeline
This patch is basically a global-isel version of combineShiftOfShiftedLogic() from DAGCombiner.
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-shift-of-shifted-logic.ll | ||
---|---|---|
8–9 | This can be simplified to a single instruction: Same goes for a few more cases below. |
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h | ||
---|---|---|
244–245 | I know you copied this comment from SelectionDAG but I think it really improves latency, not throughput, because the new shifts are independent. Also you don't mention the other reason for doing this, which is that one of the new shifts might constant-fold away. | |
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
1622 | Also handle G_USHLSAT and G_SSHLSAT? | |
1666–1669 | I don't see why this check is necessary. All we care about is the shift amount, as a uint64_t. | |
1677–1679 | First, it would be simpler to check this by line 1690 where you're already computing the sum. Second, I would expect the > to be >=. Third, you're comparing against BitWidth which is the width of the shift amount, not the value being shifted. | |
1713 | Don't create this. CombinerHelper already has a MIRBuilder. | |
1720 | ShlType is wrong here and below. You want the type of the result, not the type of the shift amount. | |
1730–1732 | It's probably not worth doing this. I think you can rely on dead code elimination. |
- Supported G_SSHLSAT and G_USHLSAT and addressed other comments.
- Added .mir test for G_SSHLSAT and G_USHLSAT.
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | ||
---|---|---|
1622 | Comment still needs updating. |
I know you copied this comment from SelectionDAG but I think it really improves latency, not throughput, because the new shifts are independent.
Also you don't mention the other reason for doing this, which is that one of the new shifts might constant-fold away.