[PATCH] D145468: [X86] Optimize (and (srl X 30) 2)
Kazu Hirata via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 21:49:14 PST 2023
kazu created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch transforms (and (srl X 30) 2) into (add Y Y), where
Y = (srl X 31). In x86 assembly:
c1 e8 1e shr $0x1e,%eax
83 e0 fe and $0xfffffffe,%eax
is transformed into:
c1 e8 1f shr $0x1f,%eax
01 c0 add %eax,%eax
When the source and destination operand are different, we can emit
lea:
c1 ef 1f shr $0x1f,%edi
8d 04 3f lea (%rdi,%rdi,1),%eax
eliminating the need for a mov instruction.
This patch fixes:
https://github.com/llvm/llvm-project/issues/61073
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145468
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/and-shift.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145468.502917.patch
Type: text/x-patch
Size: 4357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230307/486aa5c0/attachment.bin>
More information about the llvm-commits
mailing list