[all-commits] [llvm/llvm-project] 2171a8: [SDAG] Handle A and B&~A in haveNoCommonBitsSet()

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue May 3 06:47:19 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2171a896ed0059e3576fd9c36d0021a3de11d31a
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-05-03 (Tue, 03 May 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/X86/add-and-not.ll

  Log Message:
  [SDAG] Handle A and B&~A in haveNoCommonBitsSet()

This is the DAG variant of D124763. The code already handles the
general pattern, but not this degenerate case.

This allows folding A + (B&~A) to A | (B&~A) which further holds
to A | B.

Handling on the SDAG level is needed because in the motivating
case the add is actually a getelementptr, which only gets converted
into an add on the SDAG level. However, this patch is not quite
sufficient to handle the getelementptr case yet, because of an
interfering demanded bits simplification.

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

More information about the All-commits mailing list