[Bug tree-optimization/80874] New: gcc does not emit cmov for minmax
denis.campredon at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 24 14:33:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80874
Bug ID: 80874
Summary: gcc does not emit cmov for minmax
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: denis.campredon at gmail dot com
Target Milestone: ---
Hello,
Considering the following code:
------------------
struct pair {
int min, max;
};
pair minmax1(int x, int y) {
if (x > y)
return {y, x};
else
return {x, y};
}
#include <algorithm>
std::pair<int, int> minmax2(int x, int y) {
return std::minmax(x, y);
}
auto minmax3(int x, int y) {
return std::minmax(x, y);
}
-------------------
I've found that for minmax1 and minmax 2, gcc fails to emit cmov at -03.
Instead it produces the following:
minmax1(int, int):
cmp edi, esi
jle .L2
mov eax, edi
mov edi, esi
mov esi, eax
.L2:
mov eax, edi
sal rsi, 32
or rax, rsi
ret
------------
For minmax3, the asm should be the same (I think), but it produces a more
complex code.
More information about the Gcc-bugs
mailing list