[ValueTracking] Directly use KnownBits shift functions
authorNikita Popov <npopov@redhat.com>
Tue, 16 May 2023 08:55:44 +0000 (10:55 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 1 Jun 2023 07:46:16 +0000 (09:46 +0200)
commitdfb369399d2a54c8dd8752c47ecbf7a8c3c11421
treecc57457a7c2fef38895c4363bf46376c117c8dac
parent34cf67aef5a3655b57e52842a1bb4913295076e4
[ValueTracking] Directly use KnownBits shift functions

Make ValueTracking directly call the KnownBits shift helpers, which
provides more precise results.

Unfortunately, ValueTracking has a special case where sometimes we
determine non-zero shift amounts using isKnownNonZero(). I have my
doubts about the usefulness of that special-case (it is only tested
in a single unit test), but I've reproduced the special-case via an
extra parameter to the KnownBits methods.

Differential Revision: https://reviews.llvm.org/D151816
compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp
llvm/include/llvm/Support/KnownBits.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Support/KnownBits.cpp
llvm/test/Analysis/ScalarEvolution/extract-highbits-variablemask.ll
llvm/test/Analysis/ScalarEvolution/extract-lowbits-variablemask.ll
llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
llvm/test/Transforms/IndVarSimplify/shift-range-checks.ll
llvm/test/Transforms/InstCombine/zext-or-icmp.ll