visitAND attempts to narrow the width of extending loads that are then masked off. ReduceLoadWidth already exists for a similar purpose and handles shifts, so I've moved the code to handle AND nodes there.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Removing the unneeded LoadedVT seems like a straight-forward NFC and I think it would be worth to submit it for review as an isolated change, as it does not seem related to moving some code to ReduceLoadWidth.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
7969 ↗ | (On Diff #121466) | If we support extension using AND, I think we should also update the comment here. |
7999 ↗ | (On Diff #121466) | I am probably missing something, but I am not sure if I see the real benefit of moving this code here. It seems the visitAND was the right place to do it, without requiring additional checks. However, it seems like there is potential to simplify the code in visitAND |
Hi Florian,
Thanks for the comments, I will revert the LoadedVT change.
cheers,
sam
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
7999 ↗ | (On Diff #121466) | Both visitAND and ReduceLoadWidth contained essentially the same code to generate the new load, so it seems reasonable to me to contain this logic within the sensibly named function. In D39604 I also wish to directly use this function to combine ANDs and hopefully it can more helpful when anyone else wants to do similar. |
Looks like a reasonable refactor to me helping with D39604. Adding Simon & Eli as reviewers as I think they know the area better then myself.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
7999 ↗ | (On Diff #121466) | Ah yes, there is some shared code to generated the new load, I missed initially! ReduceLoadWidth also contains a few more legality checks. |
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8026 ↗ | (On Diff #121703) | Could this block of code be simplified? As long as you set ExtType and ExtVT correctly, I think the rest of the checks already exist in some form, by analogy to the transforms for ISD::SIGN_EXTEND_IN_REG. |
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8026 ↗ | (On Diff #121703) | Thanks Eli, indeed most of the checks that performed again. |
Thanks Sam, looks good to me. Please wait a day or two with committing, to give others a chance to raise additional concerns.
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8034 ↗ | (On Diff #123311) | IIRC your first version of the patch removed to unneeded LoadedVT argument. I think this would be a worthwhile simplification to get in as NFC independently. |
Very minor comment
lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
8031 ↗ | (On Diff #123311) | use bool here - we typically only use auto for casts |
@fhahn @RKSimon @eli.friedman I made some small changes before committing, could someone please check them out? My development branch only had x86, Arm and Aarch64 targets built and so when I went to run my pre-commit tests, some were failing for AMDGPU and NVPTX. The issues were that even though some checks are duplicated, I have an early return in the new block which still requires those checks. Also I had missed how any_extend nodes are combined, so I re-added some code that was lost during the refactor.
I'm still kind of concerned that this is messier than it needs to be. I guess I'll try experimenting a bit.