[llvm-dev] [RFC] Add TargetTransformInfo::isAllocaPtrValueNonZero and let ValueTracking depend on TargetTransformInfo

Liu, Yaxun (Sam) via llvm-dev
Thu, 14 Dec 2017 20:32:45 -0000

Some optimizations depend on whether alloca instruction always has non-zero
value. Currently, this checking is done by isKnownNonZero() in ValueTracking,
and it assumes alloca in address space 0 always has non-zero value but alloca in
non-zero address spaces does not always have non-zero value.

However, this assumption is incorrect for certain targets. For example,
amdgcn---amdgiz target has alloca in address space 5, and its alloca always has
non-zero value. This assumption causes some optimizations disabled for
amdgcn---amdgiz target.

After discussions at https://reviews.llvm.org/D40670, I propose to introduce
TargetTransformInfo::isAllocaPtrValueNonZero for representing whether alloca
instruction always has non-zero value, and add a TargetTransformInfo argument to
ValueTracking functions e.g. isKnownNonZero().

As a result, passes using ValueTracking will require TargetTransformInfo.

Comments are welcome.

Thanks.

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20171214/00763b7a/attachment.html>