[SCEVExpander] Prefer pointer expansion for overflow checks
authorPhilip Reames <listmail@philipreames.com>
Wed, 1 Sep 2021 20:07:32 +0000 (13:07 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 1 Sep 2021 20:11:25 +0000 (13:11 -0700)
commite735f2bf379285294c41748eec3e95e3e8bd1acd
treea3fb719dbed58a4e5e45028c555cb82dea78127b
parent0022426917e3cf5e6bb55ba691bea67094663114
[SCEVExpander] Prefer pointer expansion for overflow checks

We'd special cased this logic to use pointer types for non-integral pointers, but there's no reason we can't do that for all pointer types.   Doing it this was has a few advantages:
a) The code itself becomes more straight forward, and easier to test.
b) We avoid introducing ptrtoint into programs which didn't have them in the source.
c) The resulting codegen is easier to analyze and simplify (mostly due to lack of ptrtoint).

Note that there are some test diffs, but a) running them through instcombine helps a ton, and b) there's enough missing obvious transforms on both before and after IR that it's clear this isn't performance sensitive.

This is mostly motivated by cleaning up mentions of non-integrals to have a clearer idea of what we actually need to support.

Differential Revision: https://reviews.llvm.org/D104662
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll
llvm/test/Transforms/LoopVersioning/wrapping-pointer-versioning.ll