1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/CodeGen/Mips/uitofp.ll
Craig Topper ee6566c72b [LegalizeDAG][Mips] Add an assert to protect a uint_to_fp implementation from double rounding. Add a i32->f32 uint_to_fp implementation that avoids this code.
The algorithm here only works if the sint_to_fp doesn't do any
rounding. Otherwise it can round before the offset fixup is
applied. Add an assert to protect this.

To avoid breaking the one test in tree that tested this code
with a set of types that fail the assert, I've enabled i32->f32
to use the i64->f32 algorithm. This only occurs when f64 isn't
a legal type. If f64 is legal then we do i32->f64->f32 instead.

Differential Revision: https://reviews.llvm.org/D72794
2020-01-16 11:08:16 -08:00

33 lines
1012 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -march=mips -mattr=+single-float < %s | FileCheck %s
define void @f0() nounwind {
; CHECK-LABEL: f0:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addiu $sp, $sp, -8
; CHECK-NEXT: addiu $1, $zero, 1
; CHECK-NEXT: sw $1, 4($sp)
; CHECK-NEXT: lw $1, 4($sp)
; CHECK-NEXT: srl $2, $1, 1
; CHECK-NEXT: andi $3, $1, 1
; CHECK-NEXT: or $2, $3, $2
; CHECK-NEXT: mtc1 $2, $f0
; CHECK-NEXT: cvt.s.w $f0, $f0
; CHECK-NEXT: add.s $f0, $f0, $f0
; CHECK-NEXT: mtc1 $1, $f1
; CHECK-NEXT: cvt.s.w $f1, $f1
; CHECK-NEXT: slti $1, $1, 0
; CHECK-NEXT: movn.s $f1, $f0, $1
; CHECK-NEXT: swc1 $f1, 0($sp)
; CHECK-NEXT: jr $ra
; CHECK-NEXT: addiu $sp, $sp, 8
entry:
%b = alloca i32, align 4
%a = alloca float, align 4
store volatile i32 1, i32* %b, align 4
%0 = load volatile i32, i32* %b, align 4
%conv = uitofp i32 %0 to float
store float %conv, float* %a, align 4
ret void
}