This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Refactor visitSCALAR_TO_VECTOR. NFC.
ClosedPublic

Authored by HanKuanChen on Nov 8 2022, 7:27 PM.

Diff Detail

Event Timeline

HanKuanChen created this revision.Nov 8 2022, 7:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 7:27 PM
HanKuanChen requested review of this revision.Nov 8 2022, 7:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 7:27 PM
spatel accepted this revision.Nov 14 2022, 6:18 AM

Less readable to me, but shorter, so I'll say LGTM - see inline for some possible minor improvements.

Note that there is potentially a real cost to writing code like this:
https://github.com/llvm/llvm-project/issues/58982

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
23551–23558

I find it easier to notice pseudo-loops like this if we write it this way:

for (int i : {0, 1}) {
23554–23558

Reduce levels of indents:

SDValue EE = Scalar.getOperand(i);
auto *C = dyn_cast<ConstantSDNode>(Scalar.getOperand(i ? 0 : 1));
if (C && EE.getOpcode() == ...)

Also, a "i ? 0 : 1" pattern seems more obvious to me than "1 - i".

This revision is now accepted and ready to land.Nov 14 2022, 6:18 AM

Apply spatel's comment.

This revision was landed with ongoing or failed builds.Nov 22 2022, 1:29 AM
This revision was automatically updated to reflect the committed changes.