This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Add SelectionDAG::SplitScalar helper
ClosedPublic

Authored by RKSimon on Mar 30 2023, 1:38 PM.

Details

Summary

Similar to the existing SelectionDAG::SplitVector helper, this helper creates the EXTRACT_ELEMENT nodes for the LO/HI halves of the scalar source.

There's still additional targets that can be converted to use this - my only concern is if its an issue that we mix it with cases where we call getNode(ISD::EXTRACT_ELEMENT) just for the HI half?

Diff Detail

Event Timeline

RKSimon created this revision.Mar 30 2023, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 1:38 PM
RKSimon requested review of this revision.Mar 30 2023, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 1:38 PM
This revision is now accepted and ready to land.Mar 30 2023, 9:50 PM
barannikov88 added inline comments.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7431–7433

(optional) It would be one line less with structured bindings.

pengfei added inline comments.Mar 30 2023, 10:10 PM
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1944–1947

Missing here?

1957–1960

here.

1971–1973

And here. Found the problem when I tried to check if One used elsewhere.

RKSimon added inline comments.Mar 31 2023, 2:05 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7431–7433

Does the coding standards encourage these yet? We tend to avoid auto etc. in most cases unless the type is already explicit/obvious - casts etc.

https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
1944–1947

Thanks - there's probably more but I'll try to deal with all of the remaining cases in the targets that I've already touched (note: AMDGPU is a target that often only extracts the upper half so we have single EXTRACT_ELEMENT nodes).

barannikov88 added inline comments.Mar 31 2023, 3:01 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7431–7433

Does the coding standards encourage these yet?

I don't think so. The only change since the switch was D132232.

We tend to avoid auto etc. in most cases unless the type is already explicit/obvious - casts etc.

I myself not an AAA person and very happy that LLVM prefers explicit types. Still, structured bindings are convenient in some cases, so it would not hurt me too much if they were encouraged.

The next time I'm tempted to use them, I'll create a discourse topic.

This revision was automatically updated to reflect the committed changes.