llvm / llvm/llvm-project

[X86] failed to lower llround llroundf lround lroundf to native instruction

Open
#202,035 1 comment 0 reactions 0 assignees View on GitHub
backend:X86 missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/aKc9xTqdE

-O3 -march=novalake -fno-trapping-math -fno-math-errno
```c
long _lroundf (float x){return __builtin_lroundf(x);}

long _lround (double x){return __builtin_lround(x);}

long long _llroundf (float x){return __builtin_llroundf(x);}

long long _llround (double x){return __builtin_llround(x);}
```
gcc
```asm
"_lroundf":
vmovss xmm1, DWORD PTR .LC2[rip]
vmovaps xmm2, xmm0
vmovss xmm0, DWORD PTR .LC0[rip]
vandps xmm1, xmm1, xmm2
vorps xmm0, xmm0, xmm1
vaddss xmm0, xmm0, xmm2
vcvttss2si rax, xmm0
ret
"_lround":
vmovsd xmm1, QWORD PTR .LC5[rip]
vmovapd xmm2, xmm0
vmovsd xmm0, QWORD PTR .LC3[rip]
vandpd xmm1, xmm1, xmm2
vorpd xmm0, xmm0, xmm1
vaddsd xmm0, xmm0, xmm2
vcvttsd2si rax, xmm0
ret
"_llroundf":
vmovss xmm1, DWORD PTR .LC2[rip]
vmovaps xmm2, xmm0
vmovss xmm0, DWORD PTR .LC0[rip]
vandps xmm1, xmm1, xmm2
vorps xmm0, xmm0, xmm1
vaddss xmm0, xmm0, xmm2
vcvttss2si rax, xmm0
ret
"_llround":
vmovsd xmm1, QWORD PTR .LC5[rip]
vmovapd xmm2, xmm0
vmovsd xmm0, QWORD PTR .LC3[rip]
vandpd xmm1, xmm1, xmm2
vorpd xmm0, xmm0, xmm1
vaddsd xmm0, xmm0, xmm2
vcvttsd2si rax, xmm0
ret
.LC0:
.long 1056964607
.LC3:
.long -1
.long 1071644671
.LC5:
.long 0
.long -2147483648
```
clang
```asm
_lroundf:
jmp lroundf@PLT

_lround:
jmp lround@PLT

_llroundf:
jmp llroundf@PLT

_llround:
jmp llround@PLT
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.