Add logic for tracking lowbit of (and/xor/or X, (add/sub X, Odd))
authorNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 26 Jan 2023 17:35:51 +0000 (11:35 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Fri, 24 Feb 2023 01:52:17 +0000 (19:52 -0600)
commit196d3e39653c66b6809680e2ae725f7a688f672f
treecf6d4dcf004f4c53e18467113c04fda7996a5df1
parent6ad6f9c57911a9e6279e4b6ef212d25e58dac112
Add logic for tracking lowbit of (and/xor/or X, (add/sub X, Odd))

Any case of logicop + add/sub(Odd) we can prove the low bit is either
zero/non-zero.

Alive2 Links:
    xor:
        sub x, C: https://alive2.llvm.org/ce/z/aaABdS
        sub C, x: https://alive2.llvm.org/ce/z/2W-ZJ7
        add C, x: https://alive2.llvm.org/ce/z/pzDkte
    or:
        sub x, C: https://alive2.llvm.org/ce/z/xd-bcP
        sub C, x: https://alive2.llvm.org/ce/z/p8hXJF
        add C, x: https://alive2.llvm.org/ce/z/osmkB6
    and:
        sub x, C: https://alive2.llvm.org/ce/z/D_NNxR
        sub C, x: https://alive2.llvm.org/ce/z/N_5C62
        add C, x: https://alive2.llvm.org/ce/z/4cy7a4

Differential Revision: https://reviews.llvm.org/D142427
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Analysis/ValueTracking/knownbits-and-or-xor-lowbit.ll