[PATCH] D28490: [LV] Don't panic when encountering the IV of an outer loop.

Matthew Simpson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 11:07:19 PST 2017


mssimpso added inline comments.


================
Comment at: test/Transforms/LoopVectorize/pr31190.ll:8
+
+; CHECK: LV: PHI is a recurrence with respect to an outer loop.
+; CHECK: LV: Not vectorizing: Cannot prove legality.
----------------
mkuper wrote:
> mssimpso wrote:
> > mkuper wrote:
> > > delena wrote:
> > > > Can you add the source code to the comments? You try to vectorize the "for.body3" loop, right? What PHI belongs to the outer loop?
> > > Yes, it's trying to vectorize the inner loop (for.body3).
> > > The problematic PHI is: 
> > > %0 = phi i32 [ undef, %for.cond1.preheader ], [ %inc54, %for.body3 ]
> > > 
> > > This phi is in the inner loop, but %inc54 is an IV phi in the outer loop:
> > > %inc54 = phi i32 [ %inc5, %for.cond1.for.inc4_crit_edge ], [ %c.promoted, %entry ]
> > > So SCEV recognizes %0 as an AddRec, but with respect to the outer loop.
> > > 
> > > I'll add the above explanation in a comment.
> > > Not sure about the source, though - the IR was, I think, hand-reduced by @davide from the source in PR31190, so I'm not sure having the "original" source he makes a lot of sense.
> > > 
> > > So SCEV recognizes %0 as an AddRec, but with respect to the outer loop.
> > 
> > I haven't tried this so I'm not really sure, but would SE->getSCEVAtScope(Phi, TheLoop) be useful here?
> I think it will work, but that doesn't really help. We'll just end up with an unidentified phi, so we won't vectorize regardless.
> I'd prefer to leave this explicit, but I don't mind trying getSCEVatScope if you think that's better.
Ah, yes you're right, the phi would just be unknown. Leaving the check explicit is probably better. This looks good to me!


https://reviews.llvm.org/D28490





More information about the llvm-commits mailing list