HomePhabricator

Explicitly pass type to cast load constant folding result

Authored by aeubanks on Apr 18 2021, 1:35 AM.

Description

Explicitly pass type to cast load constant folding result

Previously we would use the type of the pointee to determine what to
cast the result of constant folding a load. To aid with opaque pointer
types, we should explicitly pass the type of the load rather than
looking at pointee types.

ConstantFoldLoadThroughBitcast() converts the const prop'd value to the
proper load type (e.g. [1 x i32] -> i32). Instead of calling this in
every intermediate step like bitcasts, we only call this when we
actually see the global initializer value.

In some existing uses of this API, we don't know the exact type we're
loading from immediately (e.g. first we visit a bitcast, then we visit
the load using the bitcast). In those cases we have to manually call
ConstantFoldLoadThroughBitcast() when simplifying the load to make sure
that we cast to the proper type.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D100718

Details

Committed
aeubanksApr 20 2021, 12:53 AM
Reviewer
dblaikie
Differential Revision
D100718: Explicitly pass type to cast load constant folding result
Parents
rGb8203397522f: [PowerPC] Support f128 under VSX
Branches
Unknown
Tags
Unknown