[PATCH] D123109: [x86] improve select lowering for smin(x, 0) & smax(x, 0)
Wei Xiao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 01:06:28 PDT 2022
wxiao3 created this revision.
Herald added subscribers: armkevincheng, eric-k256, pengfei, hiraditya.
Herald added a reviewer: sjarus.
Herald added a project: All.
wxiao3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
smin(x, 0):
(select (x < 0), x, 0) -> ((x << (size_in_bits(x)-1))) & x
smax(x, 0):
(select (x > 0), x, 0) -> (~(x << (size_in_bits(x)-1))) & x
The comparison is testing for a positive value, we have to invert the sign
bit mask, so only do that transform if the target has a bitwise 'and not'
instruction (the invert is free).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123109
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/fpclamptosat_vec.ll
llvm/test/CodeGen/X86/sdiv_fix_sat.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123109.420400.patch
Type: text/x-patch
Size: 57883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220405/3ac2f505/attachment.bin>
More information about the llvm-commits
mailing list