This is an archive of the discontinued LLVM Phabricator instance.

[LV] Factor the creation of the loop induction variable out of createEmptyLoop()
ClosedPublic

Authored by jmolloy on Aug 30 2015, 4:04 AM.

Details

Summary

It makes things easier to understand if this is in a helper method. This is part of my ongoing spaghetti-removal operation on createEmptyLoop.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 33526.Aug 30 2015, 4:04 AM
jmolloy retitled this revision from to [LV] Factor the creation of the loop induction variable out of createEmptyLoop().
jmolloy updated this object.
jmolloy added reviewers: anemet, hfinkel, mzolotukhin.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: llvm-commits.
mzolotukhin edited edge metadata.Aug 30 2015, 1:31 PM

Hi James,

Thanks for your efforts in cleaning this up. In general, LGTM, with a few remarks inline:

lib/Transforms/Vectorize/LoopVectorize.cpp
2572

DL seems to be unused. And it's not clear from the name, what it stands for. Should it be used instead of OldInduction in setDebugLocFromInst?

2589

Should Latch be used instead of Header here?

Hi Michael,

Thankyou so much for reviewing my mountain of code reviews :)

Patch updated. I've also taken your advice on other commits and checked all code changes for each commit - there's nothing unexpected in any of them.

Cheers,

James

lib/Transforms/Vectorize/LoopVectorize.cpp
2572

Good catch, thanks! Updated.

2589

I don't think so - Induction is in the latch and needs to branch back to the header.

jmolloy updated this revision to Diff 33590.Aug 31 2015, 10:16 AM
jmolloy edited edge metadata.
mzolotukhin added inline comments.Sep 1 2015, 11:21 AM
lib/Transforms/Vectorize/LoopVectorize.cpp
2589

AFAIU, we have a following CFG:

(PreHeader)
    |
    |
    v
(Header)<-
    |     |
    |     |
    v     /
(Latch) --
    |
    |
    v
(Exit)

(If my graphics isn't rendered well, the edges in CFG are: PreHeader-->Header, Header-->Latch, Latch-->Header, Latch-->Exit)

Now, we're building Induction in Header. It is a PHI, and should have two incoming values: one from the preheader (L->getLoopPreheader), and one from the latch (but you use Header instead).

Am I wrong somewhere?

mzolotukhin accepted this revision.Sep 1 2015, 12:16 PM
mzolotukhin edited edge metadata.

Hi James,

With this fix the patch LGTM.

Thanks,
Michael

This revision is now accepted and ready to land.Sep 1 2015, 12:16 PM
jmolloy closed this revision.Sep 2 2015, 4:57 AM

Thanks! r246632