]> granicus.if.org Git - llvm/commit
[LSR] Check SCEV on isZero() after extend. PR40514
authorMax Kazantsev <max.kazantsev@azul.com>
Tue, 5 Feb 2019 04:30:37 +0000 (04:30 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Tue, 5 Feb 2019 04:30:37 +0000 (04:30 +0000)
commit2e5e5e656a1aecb11c131ba58edd5993b9bb629c
tree1673d2bb603604889c9bee7b334f62eaae3d6f48
parent2ba6898176e40bad620b5c4882cd2e7edadf7c07
[LSR] Check SCEV on isZero() after extend. PR40514

When LSR first adds SCEVs to BaseRegs, it only does it if `isZero()` has
returned false. In the end, in invocation of `InsertFormula`, it asserts that
all values there are still not zero constants. However between these two
points, it makes some transformations, in particular extends them to wider
type.

SCEV does not give us guarantee that if `S` is not a constant zero, then
`sext(S)` is also not a constant zero. It might have missed some optimizing
transforms when it was calculating `S` and then made them when it took `sext`.
For example, it may happen if previously optimizing transforms were limited
by depth or somehow else.

This patch adds a bailout when we may end up with a zero SCEV after extension.

Differential Revision: https://reviews.llvm.org/D57565
Reviewed By: samparker

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353136 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/Transforms/LoopStrengthReduce/X86/pr40514.ll [new file with mode: 0644]