[SCEV] Search operand tree for scope bound when inferring flags from IR
authorPhilip Reames <listmail@philipreames.com>
Wed, 6 Oct 2021 22:07:10 +0000 (15:07 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 6 Oct 2021 22:10:02 +0000 (15:10 -0700)
commit1183d65b4d85de7065070176e6ac5caff13978b6
treebee1ea8dd36d65aaefb7cde49f834ebc600e0dbf
parenta625fd26cea579853bfe6c00f8fd8e6e88388630
[SCEV] Search operand tree for scope bound when inferring flags from IR

When checking to see if we can apply IR flags to a SCEV, we need to identify a bound on the defining scope of the SCEV to be produced.  We'd previously added support for a couple SCEVExpr types which trivially imply bounds, but hadn't handled types such as umax where the bounds come from the bounds of the operands.  This does the obvious thing, and recurses through operands searching for a tighter bound on the defining scope.

I'm honestly surprised by how little this seems to mater on existing tests, but it's worth doing for completeness sake alone.

Differential Revision: https://reviews.llvm.org/D111191
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/LoopAccessAnalysis/memcheck-wrapping-pointers.ll
llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll