[PATCH] D31906: [LV] Model if-converted phi node cost

Michael Kuperstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 15:10:53 PDT 2017


mkuper accepted this revision.
mkuper added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:7280
+    if (VF > 1 && Phi->getParent() != TheLoop->getHeader())
+      return (Phi->getNumIncomingValues() - 1) *
+             TTI.getCmpSelInstrCost(
----------------
We don't need to handle Phi->getNumIncomingValues() == 0 - it doesn't pass the verifier, right?


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:7285
+
+    return TTI.getCFInstrCost(Instruction::PHI);
   }
----------------
This returns 1 by default, right? I'm not entirely sure that's the right thing to do here, but it's probably no worse than the current state.


================
Comment at: test/Transforms/LoopVectorize/phi-cost.ll:7
+; CHECK-LABEL: phi_two_incoming_values
+; CHECK:       LV: Found an estimated cost of 1 for VF 2 For instruction: %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ]
+; CHECK:       vector.body:
----------------
Please also add a CHECK for the induction phi.


https://reviews.llvm.org/D31906





More information about the llvm-commits mailing list