brintos

brintos / llvm-project-archived public Read only

0
0
Text · 20.6 KiB · 696a87b Raw
563 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 < %s | FileCheck -check-prefix=GFX10 %s3; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx803 < %s | FileCheck -check-prefix=GFX8 %s4; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1200 -mattr=-real-true16 < %s | FileCheck -check-prefix=GFX12 %s5 6define float @test_min_max_ValK0_K1_f32(float %a) #0 {7; GFX10-LABEL: test_min_max_ValK0_K1_f32:8; GFX10:       ; %bb.0:9; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)10; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.011; GFX10-NEXT:    s_setpc_b64 s[30:31]12;13; GFX8-LABEL: test_min_max_ValK0_K1_f32:14; GFX8:       ; %bb.0:15; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)16; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.017; GFX8-NEXT:    s_setpc_b64 s[30:31]18;19; GFX12-LABEL: test_min_max_ValK0_K1_f32:20; GFX12:       ; %bb.0:21; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x022; GFX12-NEXT:    s_wait_expcnt 0x023; GFX12-NEXT:    s_wait_samplecnt 0x024; GFX12-NEXT:    s_wait_bvhcnt 0x025; GFX12-NEXT:    s_wait_kmcnt 0x026; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.027; GFX12-NEXT:    s_setpc_b64 s[30:31]28  %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 2.0)29  %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 4.0)30  ret float %fmed31}32 33define float @test_min_max_K0Val_K1_f32(float %a) #1 {34; GFX10-LABEL: test_min_max_K0Val_K1_f32:35; GFX10:       ; %bb.0:36; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)37; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.038; GFX10-NEXT:    s_setpc_b64 s[30:31]39;40; GFX8-LABEL: test_min_max_K0Val_K1_f32:41; GFX8:       ; %bb.0:42; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)43; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.044; GFX8-NEXT:    s_setpc_b64 s[30:31]45;46; GFX12-LABEL: test_min_max_K0Val_K1_f32:47; GFX12:       ; %bb.0:48; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x049; GFX12-NEXT:    s_wait_expcnt 0x050; GFX12-NEXT:    s_wait_samplecnt 0x051; GFX12-NEXT:    s_wait_bvhcnt 0x052; GFX12-NEXT:    s_wait_kmcnt 0x053; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.054; GFX12-NEXT:    s_setpc_b64 s[30:31]55  %maxnum = call nnan float @llvm.maxnum.f32(float 2.0, float %a)56  %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 4.0)57  ret float %fmed58}59 60; min-max patterns for ieee=true do not have to check for NaNs61; 'v_max_f16_e32 v0, v0, v0' is from fcanonicalize of the input to fmin/fmax with ieee=true62define half @test_min_K1max_ValK0_f16(half %a) #0 {63; GFX10-LABEL: test_min_K1max_ValK0_f16:64; GFX10:       ; %bb.0:65; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)66; GFX10-NEXT:    v_max_f16_e32 v0, v0, v067; GFX10-NEXT:    v_med3_f16 v0, v0, 2.0, 4.068; GFX10-NEXT:    s_setpc_b64 s[30:31]69;70; GFX8-LABEL: test_min_K1max_ValK0_f16:71; GFX8:       ; %bb.0:72; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)73; GFX8-NEXT:    v_max_f16_e32 v0, v0, v074; GFX8-NEXT:    v_max_f16_e32 v0, 2.0, v075; GFX8-NEXT:    v_min_f16_e32 v0, 4.0, v076; GFX8-NEXT:    s_setpc_b64 s[30:31]77;78; GFX12-LABEL: test_min_K1max_ValK0_f16:79; GFX12:       ; %bb.0:80; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x081; GFX12-NEXT:    s_wait_expcnt 0x082; GFX12-NEXT:    s_wait_samplecnt 0x083; GFX12-NEXT:    s_wait_bvhcnt 0x084; GFX12-NEXT:    s_wait_kmcnt 0x085; GFX12-NEXT:    v_max_num_f16_e32 v0, v0, v086; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)87; GFX12-NEXT:    v_med3_num_f16 v0, v0, 2.0, 4.088; GFX12-NEXT:    s_setpc_b64 s[30:31]89  %maxnum = call half @llvm.maxnum.f16(half %a, half 2.0)90  %fmed = call half @llvm.minnum.f16(half 4.0, half %maxnum)91  ret half %fmed92}93 94define half @test_min_K1max_K0Val_f16(half %a) #1 {95; GFX10-LABEL: test_min_K1max_K0Val_f16:96; GFX10:       ; %bb.0:97; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)98; GFX10-NEXT:    v_med3_f16 v0, v0, 2.0, 4.099; GFX10-NEXT:    s_setpc_b64 s[30:31]100;101; GFX8-LABEL: test_min_K1max_K0Val_f16:102; GFX8:       ; %bb.0:103; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)104; GFX8-NEXT:    v_max_f16_e32 v0, 2.0, v0105; GFX8-NEXT:    v_min_f16_e32 v0, 4.0, v0106; GFX8-NEXT:    s_setpc_b64 s[30:31]107;108; GFX12-LABEL: test_min_K1max_K0Val_f16:109; GFX12:       ; %bb.0:110; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0111; GFX12-NEXT:    s_wait_expcnt 0x0112; GFX12-NEXT:    s_wait_samplecnt 0x0113; GFX12-NEXT:    s_wait_bvhcnt 0x0114; GFX12-NEXT:    s_wait_kmcnt 0x0115; GFX12-NEXT:    v_med3_num_f16 v0, v0, 2.0, 4.0116; GFX12-NEXT:    s_setpc_b64 s[30:31]117  %maxnum = call nnan half @llvm.maxnum.f16(half 2.0, half %a)118  %fmed = call nnan half @llvm.minnum.f16(half 4.0, half %maxnum)119  ret half %fmed120}121 122; max-mix patterns work only for non-NaN inputs123define float @test_max_min_ValK1_K0_f32(float %a) #0 {124; GFX10-LABEL: test_max_min_ValK1_K0_f32:125; GFX10:       ; %bb.0:126; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)127; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0128; GFX10-NEXT:    s_setpc_b64 s[30:31]129;130; GFX8-LABEL: test_max_min_ValK1_K0_f32:131; GFX8:       ; %bb.0:132; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)133; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0134; GFX8-NEXT:    s_setpc_b64 s[30:31]135;136; GFX12-LABEL: test_max_min_ValK1_K0_f32:137; GFX12:       ; %bb.0:138; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0139; GFX12-NEXT:    s_wait_expcnt 0x0140; GFX12-NEXT:    s_wait_samplecnt 0x0141; GFX12-NEXT:    s_wait_bvhcnt 0x0142; GFX12-NEXT:    s_wait_kmcnt 0x0143; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.0144; GFX12-NEXT:    s_setpc_b64 s[30:31]145  %minnum = call nnan float @llvm.minnum.f32(float %a, float 4.0)146  %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 2.0)147  ret float %fmed148}149 150define float @test_max_min_K1Val_K0_f32(float %a) #1 {151; GFX10-LABEL: test_max_min_K1Val_K0_f32:152; GFX10:       ; %bb.0:153; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)154; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0155; GFX10-NEXT:    s_setpc_b64 s[30:31]156;157; GFX8-LABEL: test_max_min_K1Val_K0_f32:158; GFX8:       ; %bb.0:159; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)160; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0161; GFX8-NEXT:    s_setpc_b64 s[30:31]162;163; GFX12-LABEL: test_max_min_K1Val_K0_f32:164; GFX12:       ; %bb.0:165; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0166; GFX12-NEXT:    s_wait_expcnt 0x0167; GFX12-NEXT:    s_wait_samplecnt 0x0168; GFX12-NEXT:    s_wait_bvhcnt 0x0169; GFX12-NEXT:    s_wait_kmcnt 0x0170; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.0171; GFX12-NEXT:    s_setpc_b64 s[30:31]172  %minnum = call nnan float @llvm.minnum.f32(float 4.0, float %a)173  %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 2.0)174  ret float %fmed175}176 177define half @test_max_K0min_ValK1_f16(half %a) #0 {178; GFX10-LABEL: test_max_K0min_ValK1_f16:179; GFX10:       ; %bb.0:180; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)181; GFX10-NEXT:    v_med3_f16 v0, v0, 2.0, 4.0182; GFX10-NEXT:    s_setpc_b64 s[30:31]183;184; GFX8-LABEL: test_max_K0min_ValK1_f16:185; GFX8:       ; %bb.0:186; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)187; GFX8-NEXT:    v_min_f16_e32 v0, 4.0, v0188; GFX8-NEXT:    v_max_f16_e32 v0, 2.0, v0189; GFX8-NEXT:    s_setpc_b64 s[30:31]190;191; GFX12-LABEL: test_max_K0min_ValK1_f16:192; GFX12:       ; %bb.0:193; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0194; GFX12-NEXT:    s_wait_expcnt 0x0195; GFX12-NEXT:    s_wait_samplecnt 0x0196; GFX12-NEXT:    s_wait_bvhcnt 0x0197; GFX12-NEXT:    s_wait_kmcnt 0x0198; GFX12-NEXT:    v_med3_num_f16 v0, v0, 2.0, 4.0199; GFX12-NEXT:    s_setpc_b64 s[30:31]200  %minnum = call nnan half @llvm.minnum.f16(half %a, half 4.0)201  %fmed = call nnan half @llvm.maxnum.f16(half 2.0, half %minnum)202  ret half %fmed203}204 205define half @test_max_K0min_K1Val_f16(half %a) #1 {206; GFX10-LABEL: test_max_K0min_K1Val_f16:207; GFX10:       ; %bb.0:208; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)209; GFX10-NEXT:    v_med3_f16 v0, v0, 2.0, 4.0210; GFX10-NEXT:    s_setpc_b64 s[30:31]211;212; GFX8-LABEL: test_max_K0min_K1Val_f16:213; GFX8:       ; %bb.0:214; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)215; GFX8-NEXT:    v_min_f16_e32 v0, 4.0, v0216; GFX8-NEXT:    v_max_f16_e32 v0, 2.0, v0217; GFX8-NEXT:    s_setpc_b64 s[30:31]218;219; GFX12-LABEL: test_max_K0min_K1Val_f16:220; GFX12:       ; %bb.0:221; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0222; GFX12-NEXT:    s_wait_expcnt 0x0223; GFX12-NEXT:    s_wait_samplecnt 0x0224; GFX12-NEXT:    s_wait_bvhcnt 0x0225; GFX12-NEXT:    s_wait_kmcnt 0x0226; GFX12-NEXT:    v_med3_num_f16 v0, v0, 2.0, 4.0227; GFX12-NEXT:    s_setpc_b64 s[30:31]228  %minnum = call nnan half @llvm.minnum.f16(half 4.0, half %a)229  %fmed = call nnan half @llvm.maxnum.f16(half 2.0, half %minnum)230  ret half %fmed231}232 233; global nnan function attribute always forces fmed3 combine234 235define float @test_min_max_global_nnan(float %a) {236; GFX10-LABEL: test_min_max_global_nnan:237; GFX10:       ; %bb.0:238; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)239; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0240; GFX10-NEXT:    s_setpc_b64 s[30:31]241;242; GFX8-LABEL: test_min_max_global_nnan:243; GFX8:       ; %bb.0:244; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)245; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0246; GFX8-NEXT:    s_setpc_b64 s[30:31]247;248; GFX12-LABEL: test_min_max_global_nnan:249; GFX12:       ; %bb.0:250; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0251; GFX12-NEXT:    s_wait_expcnt 0x0252; GFX12-NEXT:    s_wait_samplecnt 0x0253; GFX12-NEXT:    s_wait_bvhcnt 0x0254; GFX12-NEXT:    s_wait_kmcnt 0x0255; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.0256; GFX12-NEXT:    s_setpc_b64 s[30:31]257  %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 2.0)258  %fmed = call float @llvm.minnum.f32(float %maxnum, float 4.0)259  ret float %fmed260}261 262define float @test_max_min_global_nnan(float %a) {263; GFX10-LABEL: test_max_min_global_nnan:264; GFX10:       ; %bb.0:265; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)266; GFX10-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0267; GFX10-NEXT:    s_setpc_b64 s[30:31]268;269; GFX8-LABEL: test_max_min_global_nnan:270; GFX8:       ; %bb.0:271; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)272; GFX8-NEXT:    v_med3_f32 v0, v0, 2.0, 4.0273; GFX8-NEXT:    s_setpc_b64 s[30:31]274;275; GFX12-LABEL: test_max_min_global_nnan:276; GFX12:       ; %bb.0:277; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0278; GFX12-NEXT:    s_wait_expcnt 0x0279; GFX12-NEXT:    s_wait_samplecnt 0x0280; GFX12-NEXT:    s_wait_bvhcnt 0x0281; GFX12-NEXT:    s_wait_kmcnt 0x0282; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.0283; GFX12-NEXT:    s_setpc_b64 s[30:31]284  %minnum = call nnan float @llvm.minnum.f32(float %a, float 4.0)285  %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 2.0)286  ret float %fmed287}288 289; ------------------------------------------------------------------------------290; Negative patterns291; ------------------------------------------------------------------------------292 293; min(max(Val, K0), K1) K0 > K1, should be K0<=K1294define float @test_min_max_K0_gt_K1(float %a) #0 {295; GFX10-LABEL: test_min_max_K0_gt_K1:296; GFX10:       ; %bb.0:297; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)298; GFX10-NEXT:    v_max_f32_e32 v0, 4.0, v0299; GFX10-NEXT:    v_min_f32_e32 v0, 2.0, v0300; GFX10-NEXT:    s_setpc_b64 s[30:31]301;302; GFX8-LABEL: test_min_max_K0_gt_K1:303; GFX8:       ; %bb.0:304; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)305; GFX8-NEXT:    v_max_f32_e32 v0, 4.0, v0306; GFX8-NEXT:    v_min_f32_e32 v0, 2.0, v0307; GFX8-NEXT:    s_setpc_b64 s[30:31]308;309; GFX12-LABEL: test_min_max_K0_gt_K1:310; GFX12:       ; %bb.0:311; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0312; GFX12-NEXT:    s_wait_expcnt 0x0313; GFX12-NEXT:    s_wait_samplecnt 0x0314; GFX12-NEXT:    s_wait_bvhcnt 0x0315; GFX12-NEXT:    s_wait_kmcnt 0x0316; GFX12-NEXT:    v_maxmin_num_f32 v0, v0, 4.0, 2.0317; GFX12-NEXT:    s_setpc_b64 s[30:31]318  %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 4.0)319  %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 2.0)320  ret float %fmed321}322 323; max(min(Val, K1), K0) K0 > K1, should be K0<=K1324define float @test_max_min_K0_gt_K1(float %a) #0 {325; GFX10-LABEL: test_max_min_K0_gt_K1:326; GFX10:       ; %bb.0:327; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)328; GFX10-NEXT:    v_min_f32_e32 v0, 2.0, v0329; GFX10-NEXT:    v_max_f32_e32 v0, 4.0, v0330; GFX10-NEXT:    s_setpc_b64 s[30:31]331;332; GFX8-LABEL: test_max_min_K0_gt_K1:333; GFX8:       ; %bb.0:334; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)335; GFX8-NEXT:    v_min_f32_e32 v0, 2.0, v0336; GFX8-NEXT:    v_max_f32_e32 v0, 4.0, v0337; GFX8-NEXT:    s_setpc_b64 s[30:31]338;339; GFX12-LABEL: test_max_min_K0_gt_K1:340; GFX12:       ; %bb.0:341; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0342; GFX12-NEXT:    s_wait_expcnt 0x0343; GFX12-NEXT:    s_wait_samplecnt 0x0344; GFX12-NEXT:    s_wait_bvhcnt 0x0345; GFX12-NEXT:    s_wait_kmcnt 0x0346; GFX12-NEXT:    v_minmax_num_f32 v0, v0, 2.0, 4.0347; GFX12-NEXT:    s_setpc_b64 s[30:31]348  %minnum = call nnan float @llvm.minnum.f32(float %a, float 2.0)349  %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 4.0)350  ret float %fmed351}352 353; non-inline constant354define float @test_min_max_non_inline_const(float %a) #0 {355; GFX10-LABEL: test_min_max_non_inline_const:356; GFX10:       ; %bb.0:357; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)358; GFX10-NEXT:    v_max_f32_e32 v0, 2.0, v0359; GFX10-NEXT:    v_min_f32_e32 v0, 0x41000000, v0360; GFX10-NEXT:    s_setpc_b64 s[30:31]361;362; GFX8-LABEL: test_min_max_non_inline_const:363; GFX8:       ; %bb.0:364; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)365; GFX8-NEXT:    v_max_f32_e32 v0, 2.0, v0366; GFX8-NEXT:    v_min_f32_e32 v0, 0x41000000, v0367; GFX8-NEXT:    s_setpc_b64 s[30:31]368;369; GFX12-LABEL: test_min_max_non_inline_const:370; GFX12:       ; %bb.0:371; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0372; GFX12-NEXT:    s_wait_expcnt 0x0373; GFX12-NEXT:    s_wait_samplecnt 0x0374; GFX12-NEXT:    s_wait_bvhcnt 0x0375; GFX12-NEXT:    s_wait_kmcnt 0x0376; GFX12-NEXT:    v_maxmin_num_f32 v0, v0, 2.0, 0x41000000377; GFX12-NEXT:    s_setpc_b64 s[30:31]378  %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 2.0)379  %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 8.0)380  ret float %fmed381}382 383; there is no fmed3 for f64 or v2f16 types384 385define double @test_min_max_f64(double %a) #0 {386; GFX10-LABEL: test_min_max_f64:387; GFX10:       ; %bb.0:388; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)389; GFX10-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0390; GFX10-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0391; GFX10-NEXT:    s_setpc_b64 s[30:31]392;393; GFX8-LABEL: test_min_max_f64:394; GFX8:       ; %bb.0:395; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)396; GFX8-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0397; GFX8-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0398; GFX8-NEXT:    s_setpc_b64 s[30:31]399;400; GFX12-LABEL: test_min_max_f64:401; GFX12:       ; %bb.0:402; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0403; GFX12-NEXT:    s_wait_expcnt 0x0404; GFX12-NEXT:    s_wait_samplecnt 0x0405; GFX12-NEXT:    s_wait_bvhcnt 0x0406; GFX12-NEXT:    s_wait_kmcnt 0x0407; GFX12-NEXT:    v_max_num_f64_e32 v[0:1], 2.0, v[0:1]408; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)409; GFX12-NEXT:    v_min_num_f64_e32 v[0:1], 4.0, v[0:1]410; GFX12-NEXT:    s_setpc_b64 s[30:31]411  %maxnum = call nnan double @llvm.maxnum.f64(double %a, double 2.0)412  %fmed = call nnan double @llvm.minnum.f64(double %maxnum, double 4.0)413  ret double %fmed414}415 416define <2 x half> @test_min_max_v2f16(<2 x half> %a) #0 {417; GFX10-LABEL: test_min_max_v2f16:418; GFX10:       ; %bb.0:419; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)420; GFX10-NEXT:    v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0]421; GFX10-NEXT:    v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0]422; GFX10-NEXT:    s_setpc_b64 s[30:31]423;424; GFX8-LABEL: test_min_max_v2f16:425; GFX8:       ; %bb.0:426; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)427; GFX8-NEXT:    v_mov_b32_e32 v2, 0x4000428; GFX8-NEXT:    v_max_f16_e32 v1, 2.0, v0429; GFX8-NEXT:    v_max_f16_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD430; GFX8-NEXT:    v_mov_b32_e32 v2, 0x4400431; GFX8-NEXT:    v_min_f16_e32 v1, 4.0, v1432; GFX8-NEXT:    v_min_f16_sdwa v0, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD433; GFX8-NEXT:    v_or_b32_e32 v0, v1, v0434; GFX8-NEXT:    s_setpc_b64 s[30:31]435;436; GFX12-LABEL: test_min_max_v2f16:437; GFX12:       ; %bb.0:438; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0439; GFX12-NEXT:    s_wait_expcnt 0x0440; GFX12-NEXT:    s_wait_samplecnt 0x0441; GFX12-NEXT:    s_wait_bvhcnt 0x0442; GFX12-NEXT:    s_wait_kmcnt 0x0443; GFX12-NEXT:    v_pk_max_num_f16 v0, v0, 2.0 op_sel_hi:[1,0]444; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)445; GFX12-NEXT:    v_pk_min_num_f16 v0, v0, 4.0 op_sel_hi:[1,0]446; GFX12-NEXT:    s_setpc_b64 s[30:31]447  %maxnum = call nnan <2 x half> @llvm.maxnum.v2f16(<2 x half> %a, <2 x half> <half 2.0, half 2.0>)448  %fmed = call nnan <2 x half> @llvm.minnum.v2f16(<2 x half> %maxnum, <2 x half> <half 4.0, half 4.0>)449  ret <2 x half> %fmed450}451 452; input that can be NaN453 454; min-max patterns for ieee=false require known non-NaN input455define float @test_min_max_maybe_NaN_input_ieee_false(float %a) #1 {456; GFX10-LABEL: test_min_max_maybe_NaN_input_ieee_false:457; GFX10:       ; %bb.0:458; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)459; GFX10-NEXT:    v_max_f32_e32 v0, 2.0, v0460; GFX10-NEXT:    v_min_f32_e32 v0, 4.0, v0461; GFX10-NEXT:    s_setpc_b64 s[30:31]462;463; GFX8-LABEL: test_min_max_maybe_NaN_input_ieee_false:464; GFX8:       ; %bb.0:465; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)466; GFX8-NEXT:    v_max_f32_e32 v0, 2.0, v0467; GFX8-NEXT:    v_min_f32_e32 v0, 4.0, v0468; GFX8-NEXT:    s_setpc_b64 s[30:31]469;470; GFX12-LABEL: test_min_max_maybe_NaN_input_ieee_false:471; GFX12:       ; %bb.0:472; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0473; GFX12-NEXT:    s_wait_expcnt 0x0474; GFX12-NEXT:    s_wait_samplecnt 0x0475; GFX12-NEXT:    s_wait_bvhcnt 0x0476; GFX12-NEXT:    s_wait_kmcnt 0x0477; GFX12-NEXT:    v_max_num_f32_e32 v0, v0, v0478; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)479; GFX12-NEXT:    v_med3_num_f32 v0, v0, 2.0, 4.0480; GFX12-NEXT:    s_setpc_b64 s[30:31]481  %maxnum = call float @llvm.maxnum.f32(float %a, float 2.0)482  %fmed = call float @llvm.minnum.f32(float %maxnum, float 4.0)483  ret float %fmed484}485 486; max-min patterns always require known non-NaN input487 488define float @test_max_min_maybe_NaN_input_ieee_false(float %a) #1 {489; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_false:490; GFX10:       ; %bb.0:491; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)492; GFX10-NEXT:    v_min_f32_e32 v0, 4.0, v0493; GFX10-NEXT:    v_max_f32_e32 v0, 2.0, v0494; GFX10-NEXT:    s_setpc_b64 s[30:31]495;496; GFX8-LABEL: test_max_min_maybe_NaN_input_ieee_false:497; GFX8:       ; %bb.0:498; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)499; GFX8-NEXT:    v_min_f32_e32 v0, 4.0, v0500; GFX8-NEXT:    v_max_f32_e32 v0, 2.0, v0501; GFX8-NEXT:    s_setpc_b64 s[30:31]502;503; GFX12-LABEL: test_max_min_maybe_NaN_input_ieee_false:504; GFX12:       ; %bb.0:505; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0506; GFX12-NEXT:    s_wait_expcnt 0x0507; GFX12-NEXT:    s_wait_samplecnt 0x0508; GFX12-NEXT:    s_wait_bvhcnt 0x0509; GFX12-NEXT:    s_wait_kmcnt 0x0510; GFX12-NEXT:    v_max_num_f32_e32 v0, v0, v0511; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)512; GFX12-NEXT:    v_minmax_num_f32 v0, v0, 4.0, 2.0513; GFX12-NEXT:    s_setpc_b64 s[30:31]514  %minnum = call float @llvm.minnum.f32(float %a, float 4.0)515  %fmed = call float @llvm.maxnum.f32(float %minnum, float 2.0)516  ret float %fmed517}518 519; 'v_max_f32_e32 v0, v0, v0' is from fcanonicalize of the input to fmin/fmax with ieee=true520define float @test_max_min_maybe_NaN_input_ieee_true(float %a) #0 {521; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_true:522; GFX10:       ; %bb.0:523; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)524; GFX10-NEXT:    v_max_f32_e32 v0, v0, v0525; GFX10-NEXT:    v_min_f32_e32 v0, 4.0, v0526; GFX10-NEXT:    v_max_f32_e32 v0, 2.0, v0527; GFX10-NEXT:    s_setpc_b64 s[30:31]528;529; GFX8-LABEL: test_max_min_maybe_NaN_input_ieee_true:530; GFX8:       ; %bb.0:531; GFX8-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)532; GFX8-NEXT:    v_mul_f32_e32 v0, 1.0, v0533; GFX8-NEXT:    v_min_f32_e32 v0, 4.0, v0534; GFX8-NEXT:    v_max_f32_e32 v0, 2.0, v0535; GFX8-NEXT:    s_setpc_b64 s[30:31]536;537; GFX12-LABEL: test_max_min_maybe_NaN_input_ieee_true:538; GFX12:       ; %bb.0:539; GFX12-NEXT:    s_wait_loadcnt_dscnt 0x0540; GFX12-NEXT:    s_wait_expcnt 0x0541; GFX12-NEXT:    s_wait_samplecnt 0x0542; GFX12-NEXT:    s_wait_bvhcnt 0x0543; GFX12-NEXT:    s_wait_kmcnt 0x0544; GFX12-NEXT:    v_max_num_f32_e32 v0, v0, v0545; GFX12-NEXT:    s_delay_alu instid0(VALU_DEP_1)546; GFX12-NEXT:    v_minmax_num_f32 v0, v0, 4.0, 2.0547; GFX12-NEXT:    s_setpc_b64 s[30:31]548  %minnum = call float @llvm.minnum.f32(float %a, float 4.0)549  %fmed = call float @llvm.maxnum.f32(float %minnum, float 2.0)550  ret float %fmed551}552 553declare half @llvm.minnum.f16(half, half)554declare half @llvm.maxnum.f16(half, half)555declare float @llvm.minnum.f32(float, float)556declare float @llvm.maxnum.f32(float, float)557declare double @llvm.minnum.f64(double, double)558declare double @llvm.maxnum.f64(double, double)559declare <2 x half> @llvm.minnum.v2f16(<2 x half>, <2 x half>)560declare <2 x half> @llvm.maxnum.v2f16(<2 x half>, <2 x half>)561attributes #0 = {"amdgpu-ieee"="true"}562attributes #1 = {"amdgpu-ieee"="false"}563