[all-commits] [llvm/llvm-project] 842d0b: [x86] Improve select lowering for smin(x, 0) & sma...
Wei Xiao via All-commits
all-commits at lists.llvm.org
Thu Apr 7 00:53:57 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 842d0bf93176b9cb1e0d6894a2bbfb32ad33ebb8
https://github.com/llvm/llvm-project/commit/842d0bf93176b9cb1e0d6894a2bbfb32ad33ebb8
Author: Wei Xiao <wei3.xiao at intel.com>
Date: 2022-04-07 (Thu, 07 Apr 2022)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/select-smin-smax.ll
Log Message:
-----------
[x86] Improve select lowering for smin(x, 0) & smax(x, 0)
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).
The transform is performed only when CMP has a single user to avoid
increasing total instruction number.
https://alive2.llvm.org/ce/z/euUnNm
https://alive2.llvm.org/ce/z/37339J
Differential Revision: https://reviews.llvm.org/D123109
More information about the All-commits
mailing list