[all-commits] [llvm/llvm-project] 5afbfe: [ConstantFold] Make icmp of gep fold offset based
Nikita Popov via All-commits
all-commits at lists.llvm.org
Mon Jan 3 00:45:22 PST 2022
Author: Nikita Popov <npopov at redhat.com>
Date: 2022-01-03 (Mon, 03 Jan 2022)
[ConstantFold] Make icmp of gep fold offset based
We can fold an equality or unsigned icmp between base+offset1 and
base+offset2 with inbounds offsets by comparing the offsets directly.
This replaces a pair of specialized folds that tried to reason
based on the GEP structure instead. One of those folds was plain
wrong (because it does not account for negative offsets), while
the other is unnecessarily complicated and limited (e.g. it will
fail with bitcasts involved).
The disadvantage of this change is that it requires data layout,
so the fold is no longer performed by datalayout-independent
constant folding. I don't think this is a loss in practice, but
it does regress the ConstantExprFold.ll test, which checks folding
without running any passes.
Differential Revision: https://reviews.llvm.org/D116332
More information about the All-commits