[SCEVExpand] do not hoist divisions by zero (PR30935)
authorSebastian Pop <sebpop@gmail.com>
Mon, 12 Dec 2016 02:52:51 +0000 (02:52 +0000)
committerSebastian Pop <sebpop@gmail.com>
Mon, 12 Dec 2016 02:52:51 +0000 (02:52 +0000)
commit8c9cc8c86be80abd4224341314725d03551460d6
tree233be3a765d7f5e2f181c5dd2ffaaf5085c473d9
parent7fc6d34ed1fce99505713c5b09b3701aaac9d60e
[SCEVExpand] do not hoist divisions by zero (PR30935)

SCEVExpand computes the insertion point for the components of a SCEV to be code
generated.  When it comes to generating code for a division, SCEVexpand would
not be able to check (at compilation time) all the conditions necessary to avoid
a division by zero.  The patch disables hoisting of expressions containing
divisions by anything other than non-zero constants in order to avoid hoisting
these expressions past conditions that should hold before doing the division.

The patch passes check-all on x86_64-linux.

Differential Revision: https://reviews.llvm.org/D27216

llvm-svn: 289412
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/test/Transforms/LoopIdiom/pr30935.ll [new file with mode: 0644]
llvm/unittests/Analysis/ScalarEvolutionTest.cpp