[llvm] [LoongArch] Fix fp_to_uint/fp_to_sint conversion errors for lasx (PR #137129)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 20:35:50 PDT 2025
================
@@ -31,9 +31,9 @@ define void @fptosi_v4f64_v4i32(ptr %res, ptr %in){
; CHECK-LABEL: fptosi_v4f64_v4i32:
; CHECK: # %bb.0:
; CHECK-NEXT: xvld $xr0, $a1, 0
+; CHECK-NEXT: xvftintrz.l.d $xr0, $xr0
; CHECK-NEXT: xvpermi.d $xr1, $xr0, 238
-; CHECK-NEXT: xvfcvt.s.d $xr0, $xr1, $xr0
-; CHECK-NEXT: xvftintrz.w.s $xr0, $xr0
+; CHECK-NEXT: xvpickev.w $xr0, $xr1, $xr0
; CHECK-NEXT: vst $vr0, $a0, 0
----------------
heiher wrote:
It's important to make sure the logic is correct before we focus on performance. -:) Casting from `f64` to `f32` might introduce subtle precision issues, potentially causing incorrect results even for values that are well within the valid `i32` range. For example, `f32` cannot precisely represent some integers starting from `16777217`, so values in this range my get silently rounded.
https://github.com/llvm/llvm-project/pull/137129
More information about the llvm-commits
mailing list