[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`
authorNoah Goldstein <goldstein.w.n@gmail.com>
Sun, 30 Apr 2023 14:32:57 +0000 (09:32 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Sun, 30 Apr 2023 15:06:45 +0000 (10:06 -0500)
commitea5a0d4b909fb71376686a3c34bbaf05ed47fb3f
treee19020f1fe7b42ec7e66f01d240adf06cfc2df9d
parentc7f7f601f2c86203f8659e0a765549853f3c2a85
[ValueTracking] Add logic for `isKnownNonZero(ctlz/cttz X)`

for `cttz` if `X[0]` is non-zero, then the expression is non-zero.
for `ctlz` if `X[SignBit]` is non-zero, then the expression in
non-zero.

Alive2 Links:
    cttz (false): https://alive2.llvm.org/ce/z/ySQzbg
    cttz (true): https://alive2.llvm.org/ce/z/auiTCJ
    ctlz (false): https://alive2.llvm.org/ce/z/yk3sTJ
    ctlz (true): https://alive2.llvm.org/ce/z/-JuDty

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D149410
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/known-non-zero.ll