https://bugs.llvm.org/show_bug.cgi?id=39898
Bug ID: 39898
Summary: Missed min max optimization
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: llvm-bugs@lists.llvm.org
int minmax(int num) {
int t = std::max(15, num);
return std::min(1, t);
}
Current codegen -O3, x86-64:
minmax(int): # @minmax(int)
cmp edi, 14
mov ecx, 15
cmovg ecx, edi
cmp ecx, 2
mov eax, 1
cmovl eax, ecx
ret
We can fold it to 1 (GCC does it).
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs