llvm-project
llvm-project copied to clipboard
[X86] sitofp/uitofp i128 to half shouldn't emit libcalls
noticed from https://github.com/llvm/llvm-project/pull/235207 https://godbolt.org/z/Mx97Tfr14
f16 src (s128 a){
return a;
}
src:
push rax
call __floattihf@PLT
pop rax
ret
should be
f16 tgt (s128 a){
a = __builtin_elementwise_min(a,(s128)INT32_MAX);
a = __builtin_elementwise_max(a,(s128)INT32_MIN);
s32 x = a;
return x;
}
src:
push rax
call __floattihf@PLT
pop rax
ret
tgt:
mov rax, -2147483648
cmp rax, rdi
mov rcx, -1
sbb rdx, rcx, rsi
cmovl rcx, rsi
cmovl rax, rdi
cmp rax, 2147483647
sbb rcx, 0
mov ecx, 2147483647
cmovl ecx, eax
vcvtsi2sh xmm0, xmm31, ecx
ret
@llvm/issue-subscribers-backend-x86
Author: Andarwinux
noticed from https://github.com/llvm/llvm-project/pull/235207
https://godbolt.org/z/Mx97Tfr14
```c
f16 src (s128 a){
return a;
}
```
```asm
src:
push rax
call __floattihf@PLT
pop rax
ret
```
should be
```c
f16 tgt (s128 a){
a = __builtin_elementwise_min(a,(s128)INT32_MAX);
a = __builtin_elementwise_max(a,(s128)INT32_MIN);
s32 x = a;
return x;
}
```
```asm
src:
push rax
call __floattihf@PLT
pop rax
ret
tgt: mov rax, -2147483648 cmp rax, rdi mov rcx, -1 sbb rdx, rcx, rsi cmovl rcx, rsi cmovl rax, rdi cmp rax, 2147483647 sbb rcx, 0 mov ecx, 2147483647 cmovl ecx, eax vcvtsi2sh xmm0, xmm31, ecx ret
</details>
@Andarwinux can I work on this issue
sorry sir for commenting earlier I will wait for the parent issue to be merged