326 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-simplifylib %s | FileCheck %s3 4declare float @_Z5floorf(float)5declare <2 x float> @_Z5floorDv2_f(<2 x float>)6declare <3 x float> @_Z5floorDv3_f(<3 x float>)7declare <4 x float> @_Z5floorDv4_f(<4 x float>)8declare <8 x float> @_Z5floorDv8_f(<8 x float>)9declare <16 x float> @_Z5floorDv16_f(<16 x float>)10 11declare double @_Z5floord(double)12declare <2 x double> @_Z5floorDv2_d(<2 x double>)13declare <3 x double> @_Z5floorDv3_d(<3 x double>)14declare <4 x double> @_Z5floorDv4_d(<4 x double>)15declare <8 x double> @_Z5floorDv8_d(<8 x double>)16declare <16 x double> @_Z5floorDv16_d(<16 x double>)17 18declare half @_Z5floorDh(half)19declare <2 x half> @_Z5floorDv2_Dh(<2 x half>)20declare <3 x half> @_Z5floorDv3_Dh(<3 x half>)21declare <4 x half> @_Z5floorDv4_Dh(<4 x half>)22declare <8 x half> @_Z5floorDv8_Dh(<8 x half>)23declare <16 x half> @_Z5floorDv16_Dh(<16 x half>)24 25define float @test_rint_f32(float %arg) {26; CHECK-LABEL: define float @test_rint_f3227; CHECK-SAME: (float [[ARG:%.*]]) {28; CHECK-NEXT: [[RINT:%.*]] = tail call float @llvm.floor.f32(float [[ARG]])29; CHECK-NEXT: ret float [[RINT]]30;31 %rint = tail call float @_Z5floorf(float %arg)32 ret float %rint33}34 35define <2 x float> @test_rint_v2f32(<2 x float> %arg) {36; CHECK-LABEL: define <2 x float> @test_rint_v2f3237; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {38; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]])39; CHECK-NEXT: ret <2 x float> [[RINT]]40;41 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg)42 ret <2 x float> %rint43}44 45define <3 x float> @test_rint_v3f32(<3 x float> %arg) {46; CHECK-LABEL: define <3 x float> @test_rint_v3f3247; CHECK-SAME: (<3 x float> [[ARG:%.*]]) {48; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x float> @llvm.floor.v3f32(<3 x float> [[ARG]])49; CHECK-NEXT: ret <3 x float> [[RINT]]50;51 %rint = tail call <3 x float> @_Z5floorDv3_f(<3 x float> %arg)52 ret <3 x float> %rint53}54 55define <4 x float> @test_rint_v4f32(<4 x float> %arg) {56; CHECK-LABEL: define <4 x float> @test_rint_v4f3257; CHECK-SAME: (<4 x float> [[ARG:%.*]]) {58; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x float> @llvm.floor.v4f32(<4 x float> [[ARG]])59; CHECK-NEXT: ret <4 x float> [[RINT]]60;61 %rint = tail call <4 x float> @_Z5floorDv4_f(<4 x float> %arg)62 ret <4 x float> %rint63}64 65define <8 x float> @test_rint_v8f32(<8 x float> %arg) {66; CHECK-LABEL: define <8 x float> @test_rint_v8f3267; CHECK-SAME: (<8 x float> [[ARG:%.*]]) {68; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x float> @llvm.floor.v8f32(<8 x float> [[ARG]])69; CHECK-NEXT: ret <8 x float> [[RINT]]70;71 %rint = tail call <8 x float> @_Z5floorDv8_f(<8 x float> %arg)72 ret <8 x float> %rint73}74 75define <16 x float> @test_rint_v16f32(<16 x float> %arg) {76; CHECK-LABEL: define <16 x float> @test_rint_v16f3277; CHECK-SAME: (<16 x float> [[ARG:%.*]]) {78; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x float> @llvm.floor.v16f32(<16 x float> [[ARG]])79; CHECK-NEXT: ret <16 x float> [[RINT]]80;81 %rint = tail call <16 x float> @_Z5floorDv16_f(<16 x float> %arg)82 ret <16 x float> %rint83}84 85define double @test_rint_f64(double %arg) {86; CHECK-LABEL: define double @test_rint_f6487; CHECK-SAME: (double [[ARG:%.*]]) {88; CHECK-NEXT: [[RINT:%.*]] = tail call double @llvm.floor.f64(double [[ARG]])89; CHECK-NEXT: ret double [[RINT]]90;91 %rint = tail call double @_Z5floord(double %arg)92 ret double %rint93}94 95define <2 x double> @test_rint_v2f64(<2 x double> %arg) {96; CHECK-LABEL: define <2 x double> @test_rint_v2f6497; CHECK-SAME: (<2 x double> [[ARG:%.*]]) {98; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x double> @llvm.floor.v2f64(<2 x double> [[ARG]])99; CHECK-NEXT: ret <2 x double> [[RINT]]100;101 %rint = tail call <2 x double> @_Z5floorDv2_d(<2 x double> %arg)102 ret <2 x double> %rint103}104 105define <3 x double> @test_rint_v3f64(<3 x double> %arg) {106; CHECK-LABEL: define <3 x double> @test_rint_v3f64107; CHECK-SAME: (<3 x double> [[ARG:%.*]]) {108; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x double> @llvm.floor.v3f64(<3 x double> [[ARG]])109; CHECK-NEXT: ret <3 x double> [[RINT]]110;111 %rint = tail call <3 x double> @_Z5floorDv3_d(<3 x double> %arg)112 ret <3 x double> %rint113}114 115define <4 x double> @test_rint_v4f64(<4 x double> %arg) {116; CHECK-LABEL: define <4 x double> @test_rint_v4f64117; CHECK-SAME: (<4 x double> [[ARG:%.*]]) {118; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x double> @llvm.floor.v4f64(<4 x double> [[ARG]])119; CHECK-NEXT: ret <4 x double> [[RINT]]120;121 %rint = tail call <4 x double> @_Z5floorDv4_d(<4 x double> %arg)122 ret <4 x double> %rint123}124 125define <8 x double> @test_rint_v8f64(<8 x double> %arg) {126; CHECK-LABEL: define <8 x double> @test_rint_v8f64127; CHECK-SAME: (<8 x double> [[ARG:%.*]]) {128; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x double> @llvm.floor.v8f64(<8 x double> [[ARG]])129; CHECK-NEXT: ret <8 x double> [[RINT]]130;131 %rint = tail call <8 x double> @_Z5floorDv8_d(<8 x double> %arg)132 ret <8 x double> %rint133}134 135define <16 x double> @test_rint_v16f64(<16 x double> %arg) {136; CHECK-LABEL: define <16 x double> @test_rint_v16f64137; CHECK-SAME: (<16 x double> [[ARG:%.*]]) {138; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x double> @llvm.floor.v16f64(<16 x double> [[ARG]])139; CHECK-NEXT: ret <16 x double> [[RINT]]140;141 %rint = tail call <16 x double> @_Z5floorDv16_d(<16 x double> %arg)142 ret <16 x double> %rint143}144 145define half @test_rint_f16(half %arg) {146; CHECK-LABEL: define half @test_rint_f16147; CHECK-SAME: (half [[ARG:%.*]]) {148; CHECK-NEXT: [[RINT:%.*]] = tail call half @llvm.floor.f16(half [[ARG]])149; CHECK-NEXT: ret half [[RINT]]150;151 %rint = tail call half @_Z5floorDh(half %arg)152 ret half %rint153}154 155define <2 x half> @test_rint_v2f16(<2 x half> %arg) {156; CHECK-LABEL: define <2 x half> @test_rint_v2f16157; CHECK-SAME: (<2 x half> [[ARG:%.*]]) {158; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x half> @llvm.floor.v2f16(<2 x half> [[ARG]])159; CHECK-NEXT: ret <2 x half> [[RINT]]160;161 %rint = tail call <2 x half> @_Z5floorDv2_Dh(<2 x half> %arg)162 ret <2 x half> %rint163}164 165define <3 x half> @test_rint_v3f16(<3 x half> %arg) {166; CHECK-LABEL: define <3 x half> @test_rint_v3f16167; CHECK-SAME: (<3 x half> [[ARG:%.*]]) {168; CHECK-NEXT: [[RINT:%.*]] = tail call <3 x half> @llvm.floor.v3f16(<3 x half> [[ARG]])169; CHECK-NEXT: ret <3 x half> [[RINT]]170;171 %rint = tail call <3 x half> @_Z5floorDv3_Dh(<3 x half> %arg)172 ret <3 x half> %rint173}174 175define <4 x half> @test_rint_v4f16(<4 x half> %arg) {176; CHECK-LABEL: define <4 x half> @test_rint_v4f16177; CHECK-SAME: (<4 x half> [[ARG:%.*]]) {178; CHECK-NEXT: [[RINT:%.*]] = tail call <4 x half> @llvm.floor.v4f16(<4 x half> [[ARG]])179; CHECK-NEXT: ret <4 x half> [[RINT]]180;181 %rint = tail call <4 x half> @_Z5floorDv4_Dh(<4 x half> %arg)182 ret <4 x half> %rint183}184 185define <8 x half> @test_rint_v8f16(<8 x half> %arg) {186; CHECK-LABEL: define <8 x half> @test_rint_v8f16187; CHECK-SAME: (<8 x half> [[ARG:%.*]]) {188; CHECK-NEXT: [[RINT:%.*]] = tail call <8 x half> @llvm.floor.v8f16(<8 x half> [[ARG]])189; CHECK-NEXT: ret <8 x half> [[RINT]]190;191 %rint = tail call <8 x half> @_Z5floorDv8_Dh(<8 x half> %arg)192 ret <8 x half> %rint193}194 195define <16 x half> @test_rint_v16f16(<16 x half> %arg) {196; CHECK-LABEL: define <16 x half> @test_rint_v16f16197; CHECK-SAME: (<16 x half> [[ARG:%.*]]) {198; CHECK-NEXT: [[RINT:%.*]] = tail call <16 x half> @llvm.floor.v16f16(<16 x half> [[ARG]])199; CHECK-NEXT: ret <16 x half> [[RINT]]200;201 %rint = tail call <16 x half> @_Z5floorDv16_Dh(<16 x half> %arg)202 ret <16 x half> %rint203}204 205define float @test_rint_f32_nobuiltin_callsite(float %arg) {206; CHECK-LABEL: define float @test_rint_f32_nobuiltin_callsite207; CHECK-SAME: (float [[ARG:%.*]]) {208; CHECK-NEXT: [[RINT:%.*]] = tail call float @_Z5floorf(float [[ARG]]) #[[ATTR4:[0-9]+]]209; CHECK-NEXT: ret float [[RINT]]210;211 %rint = tail call float @_Z5floorf(float %arg) #0212 ret float %rint213}214 215define <2 x float> @test_rint_v2f32_nobuiltin_callsite(<2 x float> %arg) {216; CHECK-LABEL: define <2 x float> @test_rint_v2f32_nobuiltin_callsite217; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {218; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @_Z5floorDv2_f(<2 x float> [[ARG]]) #[[ATTR4]]219; CHECK-NEXT: ret <2 x float> [[RINT]]220;221 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg) #0222 ret <2 x float> %rint223}224 225; "no-builtins" should be ignored226define float @test_rint_f32_nobuiltins(float %arg) #1 {227; CHECK-LABEL: define float @test_rint_f32_nobuiltins228; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {229; CHECK-NEXT: [[RINT:%.*]] = tail call float @_Z5floorf(float [[ARG]]) #[[ATTR4]]230; CHECK-NEXT: ret float [[RINT]]231;232 %rint = tail call float @_Z5floorf(float %arg) #0233 ret float %rint234}235 236define <2 x float> @test_rint_v2f32_nobuiltins(<2 x float> %arg) #1 {237; CHECK-LABEL: define <2 x float> @test_rint_v2f32_nobuiltins238; CHECK-SAME: (<2 x float> [[ARG:%.*]]) #[[ATTR0]] {239; CHECK-NEXT: [[RINT:%.*]] = tail call <2 x float> @_Z5floorDv2_f(<2 x float> [[ARG]]) #[[ATTR4]]240; CHECK-NEXT: ret <2 x float> [[RINT]]241;242 %rint = tail call <2 x float> @_Z5floorDv2_f(<2 x float> %arg) #0243 ret <2 x float> %rint244}245 246define float @test_rint_f32_preserve_flags(float %arg) {247; CHECK-LABEL: define float @test_rint_f32_preserve_flags248; CHECK-SAME: (float [[ARG:%.*]]) {249; CHECK-NEXT: [[RINT:%.*]] = tail call nnan ninf float @llvm.floor.f32(float [[ARG]])250; CHECK-NEXT: ret float [[RINT]]251;252 %rint = tail call nnan ninf float @_Z5floorf(float %arg)253 ret float %rint254}255 256define <2 x float> @test_rint_v2f32_preserve_flags(<2 x float> %arg) {257; CHECK-LABEL: define <2 x float> @test_rint_v2f32_preserve_flags258; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {259; CHECK-NEXT: [[RINT:%.*]] = tail call nnan nsz contract <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]])260; CHECK-NEXT: ret <2 x float> [[RINT]]261;262 %rint = tail call contract nsz nnan <2 x float> @_Z5floorDv2_f(<2 x float> %arg)263 ret <2 x float> %rint264}265 266define float @test_rint_f32_preserve_flags_md(float %arg) {267; CHECK-LABEL: define float @test_rint_f32_preserve_flags_md268; CHECK-SAME: (float [[ARG:%.*]]) {269; CHECK-NEXT: [[RINT:%.*]] = tail call nnan ninf float @llvm.floor.f32(float [[ARG]]), !foo !0270; CHECK-NEXT: ret float [[RINT]]271;272 %rint = tail call nnan ninf float @_Z5floorf(float %arg), !foo !0273 ret float %rint274}275 276define <2 x float> @test_rint_v2f32_preserve_flags_md(<2 x float> %arg) {277; CHECK-LABEL: define <2 x float> @test_rint_v2f32_preserve_flags_md278; CHECK-SAME: (<2 x float> [[ARG:%.*]]) {279; CHECK-NEXT: [[RINT:%.*]] = tail call nnan nsz contract <2 x float> @llvm.floor.v2f32(<2 x float> [[ARG]]), !foo !0280; CHECK-NEXT: ret <2 x float> [[RINT]]281;282 %rint = tail call contract nsz nnan <2 x float> @_Z5floorDv2_f(<2 x float> %arg), !foo !0283 ret <2 x float> %rint284}285 286; Test the libm name, not a recognized opencl builtin.287declare float @rintf(float) #2288declare double @rint(double) #2289 290define float @test_libm_rint_f32(float %arg) {291; CHECK-LABEL: define float @test_libm_rint_f32292; CHECK-SAME: (float [[ARG:%.*]]) {293; CHECK-NEXT: [[RINT:%.*]] = tail call float @rintf(float [[ARG]])294; CHECK-NEXT: ret float [[RINT]]295;296 %rint = tail call float @rintf(float %arg)297 ret float %rint298}299 300define double @test_libm_rint_f64(double %arg) {301; CHECK-LABEL: define double @test_libm_rint_f64302; CHECK-SAME: (double [[ARG:%.*]]) {303; CHECK-NEXT: [[RINT:%.*]] = tail call double @rint(double [[ARG]])304; CHECK-NEXT: ret double [[RINT]]305;306 %rint = tail call double @rint(double %arg)307 ret double %rint308}309 310define float @test_rint_f32_strictfp(float %arg) #3 {311; CHECK-LABEL: define float @test_rint_f32_strictfp312; CHECK-SAME: (float [[ARG:%.*]]) #[[ATTR2:[0-9]+]] {313; CHECK-NEXT: [[RINT:%.*]] = tail call nnan float @_Z5floorf(float [[ARG]]) #[[ATTR2]]314; CHECK-NEXT: ret float [[RINT]]315;316 %rint = tail call nnan float @_Z5floorf(float %arg) #3317 ret float %rint318}319 320attributes #0 = { nobuiltin }321attributes #1 = { "no-builtins" }322attributes #2 = { nounwind memory(none) }323attributes #3 = { strictfp }324 325!0 = !{i32 1234}326