[PATCH] D151977: [X86][NFC]Use ref instead copy in for loop for SDValue::op_values()

Wang, Xin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 23:09:02 PDT 2023


XinWang10 created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
XinWang10 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The for range loop in function LowerFMINIMUM_FMAXIMUM, it enumerate Op->op_values() with copy instead of ref, every element here is a SDUse which contains 3 pointers and a SDValue, it's better to use ref here as what the author did in SelectionDAGNodes.h.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151977

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -54615,7 +54615,7 @@
   SmallVector<SDValue, 8> Ops;
   EVT VT = V.getValueType();
   EVT EltVT = VT.getVectorElementType();
-  for (auto Op : V->op_values()) {
+  for (auto &Op : V->op_values()) {
     if (auto *Cst = dyn_cast<ConstantFPSDNode>(Op)) {
       Ops.push_back(DAG.getConstantFP(-Cst->getValueAPF(), SDLoc(Op), EltVT));
     } else {
@@ -54637,7 +54637,7 @@
   // prefer one of the values. We prefer a constant with a negative value on
   // the first place.
   // N.B. We need to skip undefs that may precede a value.
-  for (auto op : V->op_values()) {
+  for (auto &op : V->op_values()) {
     if (auto *Cst = dyn_cast<ConstantFPSDNode>(op)) {
       if (Cst->isNegative())
         return SDValue();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151977.527749.patch
Type: text/x-patch
Size: 923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230602/3658a7fb/attachment.bin>


More information about the llvm-commits mailing list