[llvm-bugs] [Bug 36617] New: Missing float truncation rounding patterns
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 6 07:16:53 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36617
Bug ID: 36617
Summary: Missing float truncation rounding patterns
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: efriedma at codeaurora.org, hfinkel at anl.gov,
llvm-bugs at lists.llvm.org, scanon at apple.com,
spatel+llvm at rotateright.com
Rounding floats/doubles patterns could be converted to truncation rounding
instructions (roundss on x86/sse etc.). AFAICT these don't need to be
-ffast-math only.
float rnd(float x) {
return (float)((int)x);
}
__v4sf rnd(__v4sf x) {
return __builtin_convertvector(__builtin_convertvector(x, __v4si), __v4sf);
}
define dso_local float @_Z3rndf {
%2 = fptosi float %0 to i32
%3 = sitofp i32 %2 to float
ret float %3
}
define dso_local <4 x float> @_Z3rndDv4_f {
%2 = fptosi <4 x float> %0 to <4 x i32>
%3 = sitofp <4 x i32> %2 to <4 x float>
ret <4 x float> %3
}
_Z3rndf:
cvttss2si %xmm0, %eax
xorps %xmm0, %xmm0
cvtsi2ssl %eax, %xmm0
retq
_Z3rndDv4_f:
cvttps2dq %xmm0, %xmm0
cvtdq2ps %xmm0, %xmm0
retq
--
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/20180306/90e51b97/attachment-0001.html>
More information about the llvm-bugs
mailing list