[all-commits] [llvm/llvm-project] 451bc7: [SDAG] Handle truncated not in haveNoCommonBitsSet()

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed May 4 06:32:17 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 451bc723aef072be78d67055906b9073762494c7
      https://github.com/llvm/llvm-project/commit/451bc723aef072be78d67055906b9073762494c7
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-05-04 (Wed, 04 May 2022)

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

  Log Message:
  -----------
  [SDAG] Handle truncated not in haveNoCommonBitsSet()

Demanded bits analysis may replace a full-width not with a
any_extend (not (truncate X)) pattern. This patch looks through
this kind of pattern in haveNoCommonBitsSet(). Of course, we can
only do this if we only need negated bits in the non-extended part,
as the other bits may now be arbitrary. For example, if we have
haveNoCommonBitsSet(~X & Y, X) then ~X only needs to actually
negate bits set in Y.

This is only a partial solution to the problem in that it allows
add -> or conversion, but the resulting or doesn't get folded yet.
(I guess that will involve exposing getBitwiseNotOperand() as a
more general helper and using that in the relevant transform.)

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




More information about the All-commits mailing list