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: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs