This is an archive of the discontinued LLVM Phabricator instance.

[SCEV][NFC] Introduce isBasicBlockEntryGuardedByCond
ClosedPublic

Authored by mkazantsev on Sep 17 2020, 5:41 AM.

Details

Summary

Currently, we have isLoopEntryGuardedByCond method in SCEV, which
checks that some fact is true if we enter the loop. In fact, this is just a
particular case of more general concept isBasicBlockEntryGuardedByCond
applied to given loop's header. In fact, the logic if this code is largely
independent on the given loop and only cares code above it.

This patch makes this generalization. Now we can query it for any block,
and isBasicBlockEntryGuardedByCond is just a particular case.

Diff Detail

Event Timeline

mkazantsev created this revision.Sep 17 2020, 5:41 AM
mkazantsev requested review of this revision.Sep 17 2020, 5:41 AM
fhahn added inline comments.Sep 18 2020, 3:56 AM
llvm/lib/Analysis/ScalarEvolution.cpp
9455

tab?

9518

I think it would be good to update the comment here, saying that we either start at the loop predecessor, if BB is the header of a loop or at the unique predecessor for other blocks.

mkazantsev added inline comments.Sep 20 2020, 9:05 PM
llvm/lib/Analysis/ScalarEvolution.cpp
9455

Eeek! It was supposed to be clang-formated...

9518

Thanks for pointing out, I'll checkthe other comments here, too.

mkazantsev marked 2 inline comments as done.

Fixed comment.

llvm/lib/Analysis/ScalarEvolution.cpp
9455

I'm not sure what it is, it's all whitespaces in my diff file. Display bug of phabricator?

fhahn accepted this revision.Sep 29 2020, 12:33 AM

LGTM, thanks!

llvm/include/llvm/Analysis/ScalarEvolution.h
682

nit: move to previous line?

llvm/lib/Analysis/ScalarEvolution.cpp
9455

Possibly :)

This revision is now accepted and ready to land.Sep 29 2020, 12:33 AM
This revision was automatically updated to reflect the committed changes.