This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Only verify BECounts for reachable loops (PR50523)
ClosedPublic

Authored by nikic on Feb 28 2022, 2:16 AM.

Details

Summary

For unreachable loops, any BECount is legal, and since D98706 SCEV can make use of this for loops that are unreachable due to constant branches. To avoid false positives, adjust SCEV verification to only check BECounts in reachable loops.

Fixes https://github.com/llvm/llvm-project/issues/50523.

Diff Detail

Event Timeline

nikic created this revision.Feb 28 2022, 2:16 AM
nikic requested review of this revision.Feb 28 2022, 2:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2022, 2:16 AM
mkazantsev added inline comments.Mar 1 2022, 1:07 AM
llvm/lib/Analysis/ScalarEvolution.cpp
13465

Why not just use DT->isReachableFromEntry(L->getHeader())?

nikic added inline comments.Mar 1 2022, 1:15 AM
llvm/lib/Analysis/ScalarEvolution.cpp
13465

The problematic case is br i1 false style branches, for which you added special handling in isImpliedCond(). The blocks are reachable in the DT, which does not special-case constant branch conditions.

mkazantsev added inline comments.Mar 1 2022, 1:23 AM
llvm/test/Transforms/IndVarSimplify/X86/pr35406.ll
2

Can we do both command lines for old & new PM?

nikic added inline comments.Mar 1 2022, 1:28 AM
llvm/test/Transforms/IndVarSimplify/X86/pr35406.ll
2

Maybe makes sense to land D120551 first, in which case this could be -indvars -verify-scev? I only wrote it this way because currently -verify-scev is effectively ignored.

mkazantsev accepted this revision.Mar 1 2022, 1:37 AM

LGTM

llvm/lib/Analysis/ScalarEvolution.cpp
13465

Got it, thanks

This revision is now accepted and ready to land.Mar 1 2022, 1:37 AM
This revision was landed with ongoing or failed builds.Mar 1 2022, 2:52 AM
This revision was automatically updated to reflect the committed changes.