[llvm-branch-commits] [llvm-branch] r322673 - Merging r322473:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 17 07:57:43 PST 2018


Author: hans
Date: Wed Jan 17 07:57:43 2018
New Revision: 322673

URL: http://llvm.org/viewvc/llvm-project?rev=322673&view=rev
Log:
Merging r322473:
------------------------------------------------------------------------
r322473 | a.elovikov | 2018-01-15 02:56:07 -0800 (Mon, 15 Jan 2018) | 23 lines

[LV] Don't call recordVectorLoopValueForInductionCast for newly-created IV from a trunc.

Summary:
This method is supposed to be called for IVs that have casts in their use-def
chains that are completely ignored after vectorization under PSE. However, for
truncates of such IVs the same InductionDescriptor is used during
creation/widening of both original IV based on PHINode and new IV based on
TruncInst.

This leads to unintended second call to recordVectorLoopValueForInductionCast
with a VectorLoopVal set to the newly created IV for a trunc and causes an
assert due to attempt to store new information for already existing entry in the
map. This is wrong and should not be done.

Fixes PR35773.

Reviewers: dorit, Ayal, mssimpso

Reviewed By: dorit

Subscribers: RKSimon, dim, dcaballe, hsaito, llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D41913
------------------------------------------------------------------------

Added:
    llvm/branches/release_60/test/Transforms/LoopVectorize/pr35773.ll
      - copied unchanged from r322473, llvm/trunk/test/Transforms/LoopVectorize/pr35773.ll
Modified:
    llvm/branches/release_60/   (props changed)
    llvm/branches/release_60/lib/Transforms/Vectorize/LoopVectorize.cpp

Propchange: llvm/branches/release_60/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 17 07:57:43 2018
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,321789,321791,321862,321980,321991,321993,322056,322103,322623
+/llvm/trunk:155241,321789,321791,321862,321980,321991,321993,322056,322103,322473,322623

Modified: llvm/branches/release_60/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_60/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=322673&r1=322672&r2=322673&view=diff
==============================================================================
--- llvm/branches/release_60/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/branches/release_60/lib/Transforms/Vectorize/LoopVectorize.cpp Wed Jan 17 07:57:43 2018
@@ -2630,9 +2630,12 @@ void InnerLoopVectorizer::createVectorIn
   Instruction *LastInduction = VecInd;
   for (unsigned Part = 0; Part < UF; ++Part) {
     VectorLoopValueMap.setVectorValue(EntryVal, Part, LastInduction);
-    recordVectorLoopValueForInductionCast(II, LastInduction, Part);
+
     if (isa<TruncInst>(EntryVal))
       addMetadata(LastInduction, EntryVal);
+    else
+      recordVectorLoopValueForInductionCast(II, LastInduction, Part);
+
     LastInduction = cast<Instruction>(addFastMathFlag(
         Builder.CreateBinOp(AddOp, LastInduction, SplatVF, "step.add")));
   }
@@ -2754,15 +2757,17 @@ void InnerLoopVectorizer::widenIntOrFpIn
 
   // If we haven't yet vectorized the induction variable, splat the scalar
   // induction variable, and build the necessary step vectors.
+  // TODO: Don't do it unless the vectorized IV is really required.
   if (!VectorizedIV) {
     Value *Broadcasted = getBroadcastInstrs(ScalarIV);
     for (unsigned Part = 0; Part < UF; ++Part) {
       Value *EntryPart =
           getStepVector(Broadcasted, VF * Part, Step, ID.getInductionOpcode());
       VectorLoopValueMap.setVectorValue(EntryVal, Part, EntryPart);
-      recordVectorLoopValueForInductionCast(ID, EntryPart, Part);
       if (Trunc)
         addMetadata(EntryPart, Trunc);
+      else
+        recordVectorLoopValueForInductionCast(ID, EntryPart, Part);
     }
   }
 




More information about the llvm-branch-commits mailing list