[llvm] Scalarizer: add negative test for lrint, llrint (PR #70203)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 05:40:15 PDT 2023


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/70203

With the recent change 98c90a13 (ISel: introduce vector ISD::LRINT, ISD::LLRINT; custom RISCV lowering), it is now possible to scalarize llvm.lrint and llvm.llrint with a trivial change to VectorUtils. In preparation for this change, and the corresponding test update, add a negative test for lrint and llrint.

>From 33fde3474b8aa3af79c4bbb595231239b0c61d23 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <Ramkumar.Ramachandra at imgtec.com>
Date: Wed, 25 Oct 2023 13:01:31 +0100
Subject: [PATCH] Scalarizer: add negative test for lrint, llrint

With the recent change 98c90a13 (ISel: introduce vector ISD::LRINT,
ISD::LLRINT; custom RISCV lowering), it is now possible to scalarize
llvm.lrint and llvm.llrint with a trivial change to VectorUtils. In
preparation for this change, and the corresponding test update, add a
negative test for lrint and llrint.
---
 llvm/test/Transforms/Scalarizer/intrinsics.ll | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/llvm/test/Transforms/Scalarizer/intrinsics.ll b/llvm/test/Transforms/Scalarizer/intrinsics.ll
index f58e50e40df2f70..f5e5be1f5998e00 100644
--- a/llvm/test/Transforms/Scalarizer/intrinsics.ll
+++ b/llvm/test/Transforms/Scalarizer/intrinsics.ll
@@ -25,9 +25,14 @@ declare <2 x float> @llvm.powi.v2f32.i32(<2 x float>, i32)
 declare <2 x i32> @llvm.smul.fix.sat.v2i32(<2 x i32>, <2 x i32>, i32)
 declare <2 x i32> @llvm.umul.fix.sat.v2i32(<2 x i32>, <2 x i32>, i32)
 
+; Unary fp operand, int return type
 declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float>)
 declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float>)
 
+; Unary fp operand, int return type
+declare <2 x i32> @llvm.lrint.v2i32.v2f32(<2 x float>)
+declare <2 x i32> @llvm.llrint.v2i32.v2f32(<2 x float>)
+
 ; Bool return type, overloaded on fp operand type
 declare <2 x i1> @llvm.is.fpclass(<2 x float>, i32)
 
@@ -210,6 +215,24 @@ define <2 x i32> @scalarize_fptoui_sat(<2 x float> %x) #0 {
   ret <2 x i32> %sat
 }
 
+define <2 x i32> @scalarize_lrint(<2 x float> %x) #0 {
+; CHECK-LABEL: @scalarize_lrint(
+; CHECK-NEXT:    [[RND:%.*]] = call <2 x i32> @llvm.lrint.v2i32.v2f32(<2 x float> [[X:%.*]])
+; CHECK-NEXT:    ret <2 x i32> [[RND]]
+;
+  %rnd = call <2 x i32> @llvm.lrint.v2i32.v2f32(<2 x float> %x)
+  ret <2 x i32> %rnd
+}
+
+define <2 x i32> @scalarize_llrint(<2 x float> %x) #0 {
+; CHECK-LABEL: @scalarize_llrint(
+; CHECK-NEXT:    [[RND:%.*]] = call <2 x i32> @llvm.llrint.v2i32.v2f32(<2 x float> [[X:%.*]])
+; CHECK-NEXT:    ret <2 x i32> [[RND]]
+;
+  %rnd = call <2 x i32> @llvm.llrint.v2i32.v2f32(<2 x float> %x)
+  ret <2 x i32> %rnd
+}
+
 define <2 x i1> @scalarize_is_fpclass(<2 x float> %x) #0 {
 ; CHECK-LABEL: @scalarize_is_fpclass(
 ; CHECK-NEXT:    [[X_I0:%.*]] = extractelement <2 x float> [[X:%.*]], i64 0



More information about the llvm-commits mailing list