[ConstraintElimination] Improve index handing during constraint building.
authorFlorian Hahn <flo@fhahn.com>
Mon, 8 Feb 2021 12:28:52 +0000 (12:28 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 8 Feb 2021 13:05:13 +0000 (13:05 +0000)
commit1f1f037ed3101d3074f65faceca81218c88a505c
treed311c8fa8e209fb88c2d2d8b435f8800d482368a
parentd8323b1a86ddeaa11a476e2d852736997b81a7b6
[ConstraintElimination] Improve index handing during constraint building.

This patch improves the index management during constraint building.
Previously, the code rejected constraints which used values that were not
part of Value2Index, but after combining the coefficients of the new
indices were 0 (if ShouldAdd was 0).

In those cases, no new indices need to be added. Instead of adding to
Value2Index directly, add new indices to the NewIndices map. The caller
can then check if it needs to add any new indices.

This enables checking constraints like `a + x <= a + n` to `x <= n`,
even if there is no constraint for `a` directly.
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/decompose-with-temporary-indices.ll
llvm/test/Transforms/ConstraintElimination/loops-header-tested-pointer-cmps.ll