[GVN] teach ConstantFolding correct handling of non-integral addrspace casts
authorJameson Nash <vtjnash@gmail.com>
Wed, 6 Nov 2019 17:01:57 +0000 (12:01 -0500)
committerJameson Nash <vtjnash@gmail.com>
Tue, 14 Jul 2020 01:44:17 +0000 (21:44 -0400)
commit2c7a07b59d5da54eba8e3e030e1cc040a88ecf58
treef7ef7f3fd13df766953f8365462e183c391b4fa4
parente244f86f4dfd9e8982940d09294af522d3809d7f
[GVN] teach ConstantFolding correct handling of non-integral addrspace casts

Here we teach the ConstantFolding analysis pass that it is not legal to
replace a load of a bitcast constant (having a non-integral addrspace)
with a bitcast of the value of that constant (with a different
non-integral addrspace).

But also teach it that certain bit patterns are always known and
convertable (a fact it already uses elsewhere). This required us to also
fix a globalopt test, since, after this change, LLVM is able to realize
that the test actually is a valid transform (NULL is always a known
bit-pattern) and so it doesn't need to emit the failure remarks for it.

Also simplify some of the negative tests for transforms by avoiding a
type change in their bitcast, and add positive versions of the same
tests, to show that they otherwise should work.

Differential Revision: https://reviews.llvm.org/D59730
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Transforms/Utils/VNCoercion.cpp
llvm/test/Transforms/GVN/non-integral-pointers.ll