[SCEV] Handle unreachable binop when matching shift recurrence
authorPhilip Reames <listmail@philipreames.com>
Wed, 31 Mar 2021 17:29:21 +0000 (10:29 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 31 Mar 2021 17:33:34 +0000 (10:33 -0700)
commitae7b1e8823a51068cfa64875fc5222e5b1d16760
tree1d512b2fbef7f05e148970feaaa3d7cbc5a406b4
parent437958d9fdb63779c10499befd7fb6ef67418a5f
[SCEV] Handle unreachable binop when matching shift recurrence

This fixes an issue introduced with my change d4648e, and reported in pr49768.

The root problem is that dominance collapses in unreachable code, and that LoopInfo explicitly only models reachable code.  Since the recurrence matcher doesn't filter by reachability (and can't easily because not all consumers have domtree), we need to bailout before assuming that finding a recurrence implies we found a loop.
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll