[PATCH] D44043: [DAGCombine] Remove AND in SETCC if we can prove they are unneeded

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 12:53:04 PST 2018


dmgreen created this revision.
dmgreen added reviewers: efriedma, spatel, john.brawn, samparker.
Herald added subscribers: fedor.sergeev, kbarton, javed.absar, nhaehnle, nemanjai, jyknight, arsenm.

This is a possible solution for the remainder of https://reviews.llvm.org/D35875. The idea is that if
we have a SETCC of two ANDs with the same mask, and we can calculate
that the non-mask bits of the operands of the AND are the same, we can
drop the ANDs from the SETCC.
i.e (x&C < y&C) => x<y for any s/u </>/=/etc.

Here is an attempt to prove such a thing at the IR level:
https://rise4fun.com/Alive/ha2

So that seems to be fine. Except that the code in question, the ANDs come
from type legalising a SETCC node, with values that come from anyext loads.
These don't provide upper known bits, even though they are likely to become
zext loads.

Hence all this plumbing to find and return anyext loads, treating them as
zeroext loads during computeKnownBits and adjusting the loads to zeroext
if that is useful for this case.

The left hand side of these tests are not yet checked in. As you can hopefully
see, it helps out quite a bit here. If there are better ways to solve this
problem, I'm all ears.


https://reviews.llvm.org/D44043

Files:
  include/llvm/CodeGen/SelectionDAG.h
  include/llvm/CodeGen/TargetLowering.h
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SelectionDAG/TargetLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/AArch64/AArch64ISelLowering.h
  lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  lib/Target/AMDGPU/AMDGPUISelLowering.h
  lib/Target/ARM/ARMISelLowering.cpp
  lib/Target/ARM/ARMISelLowering.h
  lib/Target/Lanai/LanaiISelLowering.cpp
  lib/Target/Lanai/LanaiISelLowering.h
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCISelLowering.h
  lib/Target/Sparc/SparcISelLowering.cpp
  lib/Target/Sparc/SparcISelLowering.h
  lib/Target/SystemZ/SystemZISelLowering.cpp
  lib/Target/SystemZ/SystemZISelLowering.h
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.h
  lib/Target/X86/X86InstrCompiler.td
  lib/Target/XCore/XCoreISelLowering.cpp
  lib/Target/XCore/XCoreISelLowering.h
  test/CodeGen/Thumb/setcc_xor.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44043.136826.patch
Type: text/x-patch
Size: 65389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/57e0c579/attachment-0001.bin>


More information about the llvm-commits mailing list