[PATCH] D43812: [LV] Let recordVectorLoopValueForInductionCast to check if IV was created from the cast.

Andrei Elovikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 06:10:35 PDT 2018


a.elovikov added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:573
   /// \p EntryVal is the value from the original loop that maps to the steps.
-  /// Note that \p EntryVal doesn't have to be an induction variable (e.g., it
-  /// can be a truncate instruction).
-  void buildScalarSteps(Value *ScalarIV, Value *Step, Value *EntryVal,
+  /// Note that \p EntryVal doesn't have to be an induction variable - it
+  /// can also be a truncate instruction).
----------------
dcaballe wrote:
> The previous documentation seems clearer to me but I could be missing some subtle detail.
> Typo: remove ')'?
The reason I made this change is because all the code I've seen expects EntryVal to be either PHI or TruncInst without any other possibilities. It is also true in the places where the parameters to the calls to this routine are formed. I've added an assert to ensure this property won't break - but that also required this small correction to the doc string.

So the change in a few words: before - phi/trunc/anything else is possible, after: only phi/trunc are expected.

Thanks for noticing ")"!


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:605
+  /// phi node and is used to distinguish what is the IV currently being
+  /// processed - original one or the "newly-created" one based on the proof
+  /// mentioned above. We must not record anything for the latter case, but it's
----------------
dcaballe wrote:
> It seems there is some given assumption that is not totally clear. The previous comments don't explicitly say anything about newly-created IVs. However, it seems that depending on the kind of EntryVal, we are able to know if the IV is an original or a newly-created one. Could you, please, elaborate the documentation a bit more in this regard and explain which kinds (Trunc) mean newly-created IV and why?
These assumptions come from the callers of this routine, namely buildScalarSteps/createVectorIntOrFPInductionPHI.

This routine only makes sense in that context (and that was before my change), so I don't think we need to document the real meaning of the EntryVal here - only how it affects the processing being done in this routine.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2501
+
+  // This induction variable is not the phi from the original loop but the
+  // newly-created IV based on the proof that casted Phi is equal to the
----------------
dcaballe wrote:
> Move comment inside the 'if'?
I briefly looked through this file, it seems more common to have the comment the way it is now. See line 2610 as an example (one-line if condition with the preceding comment).


================
Comment at: llvm/test/Transforms/LoopVectorize/X86/pr36524.ll:7
+; CHECK-LABEL: @foo(
+; CHECK:       vector.body:
+; CHECK-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY:%.*]] ]
----------------
dcaballe wrote:
> Is it necessary to check all the instructions in the loop body? Maybe we could remove some of them (e.g., icmp, br, ...) and strictly check whether the loop has been vectorized (vector.body) and the IV related instructions? Otherwise, this test might fail in the future due to changes unrelated to this fix.
This is the output of the update_test_checks.py limited to a vector BB only that's why I'd prefer to leave it as-is. I also think that it's small enough and won't change frequently (and all the changes, if any, would lead to a simplification that would be obviously good).


https://reviews.llvm.org/D43812





More information about the llvm-commits mailing list