This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplify] don't separate nested loops with convergent calls
ClosedPublic

Authored by sameerds on May 17 2020, 4:46 AM.

Details

Summary

When a loop has multiple backedges, loop simplification attempts to
separate them out into nested loops. This results in incorrect control
flow in the presence of some functions like a GPU barrier. This change
skips the transformation when such "convergent" function calls are
present in the loop body.

Diff Detail

Event Timeline

sameerds created this revision.May 17 2020, 4:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2020, 4:46 AM
sameerds updated this revision to Diff 264499.May 17 2020, 8:49 AM

Test update: Moved the convergent call to where it is actually relevant.

nhaehnle accepted this revision.May 18 2020, 1:36 AM

Looks good to me.

This revision is now accepted and ready to land.May 18 2020, 1:36 AM
arsenm added inline comments.May 18 2020, 8:57 AM
llvm/lib/Transforms/Utils/LoopSimplify.cpp
244

I thought we had a hasConvergentOp on loops that would avoid scanning through all the blocks again

sameerds marked an inline comment as done.May 18 2020, 7:26 PM
sameerds added inline comments.
llvm/lib/Transforms/Utils/LoopSimplify.cpp
244

That is available when LoopAccessAnalysis is used. But LoopSimplify does not already use it, and it seems a bit expensive for just this one use.

This revision was automatically updated to reflect the committed changes.