Trevor Gross 00c4be3c9e
[Test] Add and update tests for lrint/llrint (NFC) (#152662)
Many backends are missing either all tests for lrint, or specifically
those for f16, which currently crashes for `softPromoteHalf` targets.
For a number of popular backends, do the following:

* Ensure f16, f32, f64, and f128 are all covered
* Ensure both a 32- and 64-bit target are tested, if relevant
* Add `nounwind` to clean up CFI output
* Add a test covering the above if one did not exist
* Always specify the integer type in intrinsic calls

There are quite a few FIXMEs here, especially for `f16`, but much of
this will be resolved in the near future.
2025-08-12 09:56:51 +09:00

69 lines
2.0 KiB
LLVM

; Tests for lrint and llrint, with both i32 and i64 checked.
; RUN: sed 's/ITy/i32/g' %s | llc -mtriple=sparc | FileCheck %s --check-prefixes=SPARC32
; RUN: sed 's/ITy/i64/g' %s | llc -mtriple=sparc | FileCheck %s --check-prefixes=SPARC32
; RUN: sed 's/ITy/i32/g' %s | llc -mtriple=sparc64 | FileCheck %s --check-prefixes=SPARC64
; RUN: sed 's/ITy/i64/g' %s | llc -mtriple=sparc64 | FileCheck %s --check-prefixes=SPARC64
; FIXME: crash "Input type needs to be promoted!"
; define ITy @test_lrint_ixx_f16(half %x) nounwind {
; %res = tail call ITy @llvm.lrint.ITy.f16(half %x)
; ret ITy %res
; }
; define ITy @test_llrint_ixx_f16(half %x) nounwind {
; %res = tail call ITy @llvm.llrint.ITy.f16(half %x)
; ret ITy %res
; }
define ITy @test_lrint_ixx_f32(float %x) nounwind {
; SPARC32-LABEL: test_lrint_ixx_f32:
; SPARC32: call lrintf
;
; SPARC64-LABEL: test_lrint_ixx_f32:
; SPARC64: call lrintf
%res = tail call ITy @llvm.lrint.ITy.f32(float %x)
ret ITy %res
}
define ITy @test_llrint_ixx_f32(float %x) nounwind {
; SPARC32-LABEL: test_llrint_ixx_f32:
; SPARC32: call llrintf
;
; SPARC64-LABEL: test_llrint_ixx_f32:
; SPARC64: call llrintf
%res = tail call ITy @llvm.llrint.ITy.f32(float %x)
ret ITy %res
}
define ITy @test_lrint_ixx_f64(double %x) nounwind {
; SPARC32-LABEL: test_lrint_ixx_f64:
; SPARC32: call lrint
;
; SPARC64-LABEL: test_lrint_ixx_f64:
; SPARC64: call lrint
%res = tail call ITy @llvm.lrint.ITy.f64(double %x)
ret ITy %res
}
define ITy @test_llrint_ixx_f64(double %x) nounwind {
; SPARC32-LABEL: test_llrint_ixx_f64:
; SPARC32: call llrint
;
; SPARC64-LABEL: test_llrint_ixx_f64:
; SPARC64: call llrint
%res = tail call ITy @llvm.llrint.ITy.f64(double %x)
ret ITy %res
}
; FIXME(#41838): unsupported type
; define ITy @test_lrint_ixx_f128(fp128 %x) nounwind {
; %res = tail call ITy @llvm.lrint.ITy.f128(fp128 %x)
; ret ITy %res
; }
; define ITy @test_llrint_ixx_f128(fp128 %x) nounwind {
; %res = tail call ITy @llvm.llrint.ITy.f128(fp128 %x)
; ret ITy %res
; }