[PATCH] D121320: X86ISelDAGToDAG: Transform TEST + MOV64ri to SHR + TEST

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 11:35:24 PST 2022


MatzeB created this revision.
MatzeB added reviewers: craig.topper, RKSimon, wenlei, modimo, zino.
Herald added subscribers: pengfei, hiraditya, mcrosier.
Herald added a project: All.
MatzeB requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Optimize a pattern where a sequence of 8/16 or 32 bits is tested for zero: LLVM normalizes this towards and `AND` with mask which is usually good, but does not work well on X86 when the mask does not fit into a 64bit register. This DagToDAG peephole transforms sequences like:

  movabsq $562941363486720, %rax # imm = 0x1FFFE00000000
  testq %rax, %rdi

to

  shrq $33, %rdi
  testw %di, %di

the result has a shorter encoding and saves a register if the tested value isn't used otherwise.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121320

Files:
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/test/CodeGen/X86/dag-test-mov64ri.ll
  llvm/test/CodeGen/X86/hoist-and-by-const-from-lshr-in-eqcmp-zero.ll
  llvm/test/CodeGen/X86/hoist-and-by-const-from-shl-in-eqcmp-zero.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121320.414172.patch
Type: text/x-patch
Size: 6853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220309/ed488985/attachment.bin>


More information about the llvm-commits mailing list