[PATCH] D147264: [DAG] Add SelectionDAG::SplitScalar helper

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 31 03:01:48 PDT 2023


barannikov88 added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7431-7432
     // Split the quotient into low and high parts.
-    SDValue QuotL = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HiLoVT, Quotient,
-                                DAG.getIntPtrConstant(0, dl));
-    SDValue QuotH = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HiLoVT, Quotient,
-                                DAG.getIntPtrConstant(1, dl));
+    SDValue QuotL, QuotH;
+    std::tie(QuotL, QuotH) = DAG.SplitScalar(Quotient, dl, HiLoVT, HiLoVT);
     Result.push_back(QuotL);
----------------
RKSimon wrote:
> barannikov88 wrote:
> > (optional) It would be one line less with structured bindings.
> 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
> 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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147264/new/

https://reviews.llvm.org/D147264



More information about the llvm-commits mailing list