[ConstraintElimination] Allow adding pre-conditions for constraints.
authorFlorian Hahn <flo@fhahn.com>
Fri, 4 Feb 2022 11:45:07 +0000 (11:45 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 4 Feb 2022 11:45:07 +0000 (11:45 +0000)
commit06f3ef66266f9a266c9979ef7686d085ac2a4df8
tree17f6ceb1d5ed6746d9f65d4559a25881fa109f12
parentcc8ed7b5aaa4ab9d11cb8a5bc97222df966e0f58
[ConstraintElimination] Allow adding pre-conditions for constraints.

With this patch pre-conditions can be added to a list of constraints.
Constraints with pre-conditions can only be used if all pre-conditions
are satisfied when the constraint is used.

The pre-conditions at the moment are specified as a list of
(Predicate, Value *,Value *) tuples. This allow easily checking them
like any other condition, using the existing infrastructure.

This then is used to limit GEP decomposition to cases where we can
prove that offsets are signed positive.

This fixes a couple of incorrect transforms where GEP offsets where
assumed to be signed positive, but they were not.

Note that this effectively disables GEP decomposition, as there's no
support for reasoning about signed predicates. D118806 adds initial
signed support.

Fixes PR49624.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D118799
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/gep-arithmetic.ll
llvm/test/Transforms/ConstraintElimination/geps-unsigned-predicates.ll
llvm/test/Transforms/ConstraintElimination/large-system-growth.ll
llvm/test/Transforms/ConstraintElimination/loops-bottom-tested-pointer-cmps.ll
llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll