[llvm-bugs] [Bug 43310] New: Failed to combine -smax(-x, -y) to smin(x, y)
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 13 09:56:26 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43310
Bug ID: 43310
Summary: Failed to combine -smax(-x,-y) to smin(x,y)
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
spatel+llvm at rotateright.com
Noticed while investigating [Bug #42863] - its a rare case where we do better
on float than integer!
Current codegen: https://gcc.godbolt.org/z/epgWrG
auto min_f32(float x, float y) {
return std::min(x, y);
}
auto neg_max_f32(float x, float y) {
return -std::max(-x, -y);
}
auto min_s32(int x, int y) {
return std::min(x, y);
}
auto neg_max_s32(int x, int y) {
return -std::max(-x, -y);
}
min_f32(float, float):
vminss %xmm0, %xmm1, %xmm0
retq
neg_max_f32(float, float):
vminss %xmm0, %xmm1, %xmm0
retq
min_s32(int, int):
movl %edi, %eax
cmpl %edi, %esi
cmovlel %esi, %eax
retq
neg_max_s32(int, int):
movl %esi, %eax
negl %edi
negl %eax
cmpl %eax, %edi
cmovgel %edi, %eax
negl %eax
retq
vs gcc:
min_f32(float, float):
vminss %xmm0, %xmm1, %xmm0
ret
neg_max_f32(float, float):
vminss %xmm0, %xmm1, %xmm0
ret
min_s32(int, int):
cmpl %edi, %esi
movl %edi, %eax
cmovle %esi, %eax
ret
neg_max_s32(int, int):
cmpl %esi, %edi
movl %esi, %eax
cmovle %edi, %eax
ret
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190913/9c26274e/attachment.html>
More information about the llvm-bugs
mailing list