[llvm-bugs] [Bug 46967] New: Use less constants in clamp codegen
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 3 07:23:37 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46967
Bug ID: 46967
Summary: Use less constants in clamp codegen
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
int fast_min(int x, int y) {
return (x < y) ? x : y;
}
int fast_max(int x, int y) {
return (x > y) ? x : y;
}
int fast_clamp(int x, int min, int max) {
return fast_max(fast_min(x, max), min);
}
int use_fast_clamp(int x) {
return fast_clamp(x, 128, 255);
}
Clang:
use_fast_clamp: # @use_fast_clamp
cmp edi, 256
mov ecx, 255
cmovl ecx, edi
cmp ecx, 127
mov eax, 128
cmovg eax, ecx
ret
GCC:
use_fast_clamp:
mov eax, 255
mov edx, 128
cmp edi, eax
cmovle eax, edi
cmp eax, edx
cmovl eax, edx
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/20200803/a1e5eb5d/attachment.html>
More information about the llvm-bugs
mailing list