brintos

brintos / llvm-project-archived public Read only

0
0
Text · 417.0 KiB · 29163c1 Raw
9404 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22; RUN: llc -mtriple=amdgcn -global-isel=0 < %s | FileCheck -enable-var-scope -check-prefixes=SI,SI-SDAG %s3; RUN: llc -mtriple=amdgcn -global-isel=1 < %s | FileCheck -enable-var-scope -check-prefixes=SI,SI-GISEL %s4; RUN: llc -mtriple=amdgcn -mcpu=tonga -global-isel=0 < %s | FileCheck -enable-var-scope -check-prefixes=VI-SDAG %s5; RUN: llc -mtriple=amdgcn -mcpu=tonga -global-isel=1 < %s | FileCheck -enable-var-scope -check-prefixes=VI-GISEL %s6; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -global-isel=0 < %s | FileCheck -enable-var-scope -check-prefixes=GFX9,GFX9-SDAG %s7; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -global-isel=1 < %s | FileCheck -enable-var-scope -check-prefixes=GFX9,GFX9-GISEL %s8; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -global-isel=0 -mattr=-real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-SDAG,GFX11-SDAG-FAKE16 %s9; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -global-isel=1 -mattr=-real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-GISEL,GFX11-GISEL-FAKE16 %s10; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -global-isel=0 -mattr=+real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-SDAG,GFX11-SDAG-TRUE16 %s11; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -global-isel=1 -mattr=+real-true16 < %s | FileCheck -enable-var-scope -check-prefixes=GFX11,GFX11-GISEL,GFX11-GISEL-TRUE16 %s12 13define amdgpu_kernel void @v_test_nnan_input_fmed3_r_i_i_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {14; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:15; SI-SDAG:       ; %bb.0:16; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x917; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf00018; SI-SDAG-NEXT:    s_mov_b32 s6, 019; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v020; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 021; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)22; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]23; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr6424; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]25; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)26; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v227; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.028; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr6429; SI-SDAG-NEXT:    s_endpgm30;31; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:32; SI-GISEL:       ; %bb.0:33; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x934; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v035; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 036; SI-GISEL-NEXT:    s_mov_b32 s6, 037; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf00038; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)39; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]40; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr6441; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)42; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v243; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.044; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]45; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr6446; SI-GISEL-NEXT:    s_endpgm47;48; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:49; VI-SDAG:       ; %bb.0:50; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x2451; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v052; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)53; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s354; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v255; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc56; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]57; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s158; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v259; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc60; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)61; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v362; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.063; VI-SDAG-NEXT:    flat_store_dword v[0:1], v264; VI-SDAG-NEXT:    s_endpgm65;66; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:67; VI-GISEL:       ; %bb.0:68; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x2469; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v070; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)71; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s272; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s373; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v274; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc75; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]76; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s077; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s178; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v279; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc80; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)81; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v382; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.083; VI-GISEL-NEXT:    flat_store_dword v[0:1], v284; VI-GISEL-NEXT:    s_endpgm85;86; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:87; GFX9:       ; %bb.0:88; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x2489; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v090; GFX9-NEXT:    s_waitcnt lgkmcnt(0)91; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]92; GFX9-NEXT:    s_waitcnt vmcnt(0)93; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v194; GFX9-NEXT:    v_med3_f32 v1, v1, 2.0, 4.095; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]96; GFX9-NEXT:    s_endpgm97;98; GFX11-LABEL: v_test_nnan_input_fmed3_r_i_i_f32:99; GFX11:       ; %bb.0:100; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24101; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0102; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)103; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0104; GFX11-NEXT:    s_waitcnt lgkmcnt(0)105; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]106; GFX11-NEXT:    s_waitcnt vmcnt(0)107; GFX11-NEXT:    v_add_f32_e32 v1, 1.0, v1108; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0109; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]110; GFX11-NEXT:    s_endpgm111  %tid = call i32 @llvm.amdgcn.workitem.id.x()112  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid113  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid114  %a = load float, ptr addrspace(1) %gep0115  %a.add = fadd nnan float %a, 1.0116  %max = call float @llvm.maxnum.f32(float %a.add, float 2.0)117  %med = call float @llvm.minnum.f32(float %max, float 4.0)118 119  store float %med, ptr addrspace(1) %outgep120  ret void121}122 123define amdgpu_kernel void @v_test_fmed3_nnan_r_i_i_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {124; SI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_f32:125; SI-SDAG:       ; %bb.0:126; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9127; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000128; SI-SDAG-NEXT:    s_mov_b32 s6, 0129; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0130; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0131; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)132; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]133; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64134; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]135; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)136; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2137; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0138; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64139; SI-SDAG-NEXT:    s_endpgm140;141; SI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_f32:142; SI-GISEL:       ; %bb.0:143; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9144; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0145; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0146; SI-GISEL-NEXT:    s_mov_b32 s6, 0147; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000148; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)149; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]150; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64151; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)152; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2153; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0154; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]155; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64156; SI-GISEL-NEXT:    s_endpgm157;158; VI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_f32:159; VI-SDAG:       ; %bb.0:160; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24161; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0162; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)163; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3164; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2165; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc166; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]167; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1168; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2169; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc170; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)171; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v3172; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0173; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2174; VI-SDAG-NEXT:    s_endpgm175;176; VI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_f32:177; VI-GISEL:       ; %bb.0:178; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24179; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0180; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)181; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2182; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3183; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2184; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc185; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]186; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0187; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1188; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2189; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc190; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)191; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v3192; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0193; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2194; VI-GISEL-NEXT:    s_endpgm195;196; GFX9-LABEL: v_test_fmed3_nnan_r_i_i_f32:197; GFX9:       ; %bb.0:198; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24199; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v0200; GFX9-NEXT:    s_waitcnt lgkmcnt(0)201; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]202; GFX9-NEXT:    s_waitcnt vmcnt(0)203; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v1204; GFX9-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0205; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]206; GFX9-NEXT:    s_endpgm207;208; GFX11-LABEL: v_test_fmed3_nnan_r_i_i_f32:209; GFX11:       ; %bb.0:210; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24211; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0212; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)213; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0214; GFX11-NEXT:    s_waitcnt lgkmcnt(0)215; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]216; GFX11-NEXT:    s_waitcnt vmcnt(0)217; GFX11-NEXT:    v_add_f32_e32 v1, 1.0, v1218; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0219; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]220; GFX11-NEXT:    s_endpgm221  %tid = call i32 @llvm.amdgcn.workitem.id.x()222  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid223  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid224  %a = load float, ptr addrspace(1) %gep0225  %a.add = fadd nnan float %a, 1.0226 227  %max = call float @llvm.maxnum.f32(float %a.add, float 2.0)228  %med = call float @llvm.minnum.f32(float %max, float 4.0)229 230  store float %med, ptr addrspace(1) %outgep231  ret void232}233 234define amdgpu_kernel void @v_test_fmed3_nnan_r_i_i_commute0_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {235; SI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:236; SI-SDAG:       ; %bb.0:237; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9238; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000239; SI-SDAG-NEXT:    s_mov_b32 s6, 0240; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0241; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0242; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)243; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]244; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64245; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]246; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)247; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2248; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0249; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64250; SI-SDAG-NEXT:    s_endpgm251;252; SI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:253; SI-GISEL:       ; %bb.0:254; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9255; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0256; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0257; SI-GISEL-NEXT:    s_mov_b32 s6, 0258; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000259; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)260; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]261; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64262; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)263; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2264; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0265; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]266; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64267; SI-GISEL-NEXT:    s_endpgm268;269; VI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:270; VI-SDAG:       ; %bb.0:271; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24272; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0273; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)274; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3275; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2276; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc277; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]278; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1279; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2280; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc281; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)282; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v3283; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0284; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2285; VI-SDAG-NEXT:    s_endpgm286;287; VI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:288; VI-GISEL:       ; %bb.0:289; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24290; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0291; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)292; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2293; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3294; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2295; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc296; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]297; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0298; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1299; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2300; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc301; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)302; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v3303; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0304; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2305; VI-GISEL-NEXT:    s_endpgm306;307; GFX9-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:308; GFX9:       ; %bb.0:309; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24310; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v0311; GFX9-NEXT:    s_waitcnt lgkmcnt(0)312; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]313; GFX9-NEXT:    s_waitcnt vmcnt(0)314; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v1315; GFX9-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0316; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]317; GFX9-NEXT:    s_endpgm318;319; GFX11-LABEL: v_test_fmed3_nnan_r_i_i_commute0_f32:320; GFX11:       ; %bb.0:321; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24322; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0323; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)324; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0325; GFX11-NEXT:    s_waitcnt lgkmcnt(0)326; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]327; GFX11-NEXT:    s_waitcnt vmcnt(0)328; GFX11-NEXT:    v_add_f32_e32 v1, 1.0, v1329; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0330; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]331; GFX11-NEXT:    s_endpgm332  %tid = call i32 @llvm.amdgcn.workitem.id.x()333  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid334  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid335  %a = load float, ptr addrspace(1) %gep0336  %a.add = fadd nnan float %a, 1.0337 338  %max = call float @llvm.maxnum.f32(float 2.0, float %a.add)339  %med = call float @llvm.minnum.f32(float 4.0, float %max)340 341  store float %med, ptr addrspace(1) %outgep342  ret void343}344 345define amdgpu_kernel void @v_test_fmed3_nnan_r_i_i_commute1_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {346; SI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:347; SI-SDAG:       ; %bb.0:348; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9349; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000350; SI-SDAG-NEXT:    s_mov_b32 s6, 0351; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0352; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0353; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)354; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]355; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64356; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]357; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)358; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2359; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0360; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64361; SI-SDAG-NEXT:    s_endpgm362;363; SI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:364; SI-GISEL:       ; %bb.0:365; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9366; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0367; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0368; SI-GISEL-NEXT:    s_mov_b32 s6, 0369; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000370; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)371; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]372; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64373; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)374; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2375; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0376; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]377; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64378; SI-GISEL-NEXT:    s_endpgm379;380; VI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:381; VI-SDAG:       ; %bb.0:382; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24383; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0384; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)385; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3386; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2387; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc388; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]389; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1390; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2391; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc392; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)393; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v3394; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0395; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2396; VI-SDAG-NEXT:    s_endpgm397;398; VI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:399; VI-GISEL:       ; %bb.0:400; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24401; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0402; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)403; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2404; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3405; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2406; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc407; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]408; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0409; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1410; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2411; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc412; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)413; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v3414; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0415; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2416; VI-GISEL-NEXT:    s_endpgm417;418; GFX9-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:419; GFX9:       ; %bb.0:420; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24421; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v0422; GFX9-NEXT:    s_waitcnt lgkmcnt(0)423; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]424; GFX9-NEXT:    s_waitcnt vmcnt(0)425; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v1426; GFX9-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0427; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]428; GFX9-NEXT:    s_endpgm429;430; GFX11-LABEL: v_test_fmed3_nnan_r_i_i_commute1_f32:431; GFX11:       ; %bb.0:432; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24433; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0434; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)435; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0436; GFX11-NEXT:    s_waitcnt lgkmcnt(0)437; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]438; GFX11-NEXT:    s_waitcnt vmcnt(0)439; GFX11-NEXT:    v_add_f32_e32 v1, 1.0, v1440; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0441; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]442; GFX11-NEXT:    s_endpgm443  %tid = call i32 @llvm.amdgcn.workitem.id.x()444  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid445  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid446  %a = load float, ptr addrspace(1) %gep0447  %a.add = fadd nnan float %a, 1.0448 449  %max = call float @llvm.maxnum.f32(float %a.add, float 2.0)450  %med = call float @llvm.minnum.f32(float 4.0, float %max)451 452  store float %med, ptr addrspace(1) %outgep453  ret void454}455 456define amdgpu_kernel void @v_test_fmed3_nnan_r_i_i_constant_order_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {457; SI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:458; SI-SDAG:       ; %bb.0:459; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9460; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000461; SI-SDAG-NEXT:    s_mov_b32 s6, 0462; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0463; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0464; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)465; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]466; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64467; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]468; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)469; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2470; SI-SDAG-NEXT:    v_max_f32_e32 v2, 4.0, v2471; SI-SDAG-NEXT:    v_min_f32_e32 v2, 2.0, v2472; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64473; SI-SDAG-NEXT:    s_endpgm474;475; SI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:476; SI-GISEL:       ; %bb.0:477; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9478; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0479; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0480; SI-GISEL-NEXT:    s_mov_b32 s6, 0481; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000482; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)483; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]484; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64485; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)486; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2487; SI-GISEL-NEXT:    v_max_f32_e32 v2, 4.0, v2488; SI-GISEL-NEXT:    v_min_f32_e32 v2, 2.0, v2489; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]490; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64491; SI-GISEL-NEXT:    s_endpgm492;493; VI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:494; VI-SDAG:       ; %bb.0:495; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24496; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0497; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)498; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3499; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2500; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc501; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]502; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2503; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1504; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc505; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)506; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v3507; VI-SDAG-NEXT:    v_max_f32_e32 v2, 4.0, v2508; VI-SDAG-NEXT:    v_min_f32_e32 v2, 2.0, v2509; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2510; VI-SDAG-NEXT:    s_endpgm511;512; VI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:513; VI-GISEL:       ; %bb.0:514; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24515; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0516; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)517; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2518; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3519; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2520; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc521; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]522; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0523; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2524; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1525; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc526; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)527; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v3528; VI-GISEL-NEXT:    v_max_f32_e32 v2, 4.0, v2529; VI-GISEL-NEXT:    v_min_f32_e32 v2, 2.0, v2530; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2531; VI-GISEL-NEXT:    s_endpgm532;533; GFX9-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:534; GFX9:       ; %bb.0:535; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24536; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v0537; GFX9-NEXT:    s_waitcnt lgkmcnt(0)538; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]539; GFX9-NEXT:    s_waitcnt vmcnt(0)540; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v1541; GFX9-NEXT:    v_max_f32_e32 v1, 4.0, v1542; GFX9-NEXT:    v_min_f32_e32 v1, 2.0, v1543; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]544; GFX9-NEXT:    s_endpgm545;546; GFX11-LABEL: v_test_fmed3_nnan_r_i_i_constant_order_f32:547; GFX11:       ; %bb.0:548; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24549; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0550; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)551; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0552; GFX11-NEXT:    s_waitcnt lgkmcnt(0)553; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]554; GFX11-NEXT:    s_waitcnt vmcnt(0)555; GFX11-NEXT:    v_add_f32_e32 v1, 1.0, v1556; GFX11-NEXT:    v_maxmin_f32 v1, v1, 4.0, 2.0557; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]558; GFX11-NEXT:    s_endpgm559  %tid = call i32 @llvm.amdgcn.workitem.id.x()560  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid561  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid562  %a = load float, ptr addrspace(1) %gep0563  %a.add = fadd nnan float %a, 1.0564 565  %max = call float @llvm.maxnum.f32(float %a.add, float 4.0)566  %med = call float @llvm.minnum.f32(float %max, float 2.0)567 568  store float %med, ptr addrspace(1) %outgep569  ret void570}571 572define amdgpu_kernel void @v_test_fmed3_nnan_r_i_i_multi_use_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {573; SI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:574; SI-SDAG:       ; %bb.0:575; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9576; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000577; SI-SDAG-NEXT:    s_mov_b32 s6, 0578; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0579; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0580; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)581; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]582; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64583; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]584; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)585; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2586; SI-SDAG-NEXT:    v_max_f32_e32 v2, 2.0, v2587; SI-SDAG-NEXT:    v_min_f32_e32 v3, 4.0, v2588; SI-SDAG-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr64589; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)590; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64591; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)592; SI-SDAG-NEXT:    s_endpgm593;594; SI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:595; SI-GISEL:       ; %bb.0:596; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9597; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0598; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0599; SI-GISEL-NEXT:    s_mov_b32 s6, 0600; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000601; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)602; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]603; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64604; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]605; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)606; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2607; SI-GISEL-NEXT:    v_max_f32_e32 v3, 2.0, v2608; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0609; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64610; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)611; SI-GISEL-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr64612; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)613; SI-GISEL-NEXT:    s_endpgm614;615; VI-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:616; VI-SDAG:       ; %bb.0:617; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24618; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0619; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)620; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3621; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2622; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc623; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]624; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2625; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1626; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc627; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)628; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v3629; VI-SDAG-NEXT:    v_max_f32_e32 v2, 2.0, v2630; VI-SDAG-NEXT:    v_min_f32_e32 v3, 4.0, v2631; VI-SDAG-NEXT:    flat_store_dword v[0:1], v3632; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)633; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2634; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)635; VI-SDAG-NEXT:    s_endpgm636;637; VI-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:638; VI-GISEL:       ; %bb.0:639; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24640; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0641; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)642; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2643; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3644; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2645; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc646; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]647; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0648; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1649; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2650; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc651; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)652; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v3653; VI-GISEL-NEXT:    v_max_f32_e32 v3, 2.0, v2654; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0655; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2656; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)657; VI-GISEL-NEXT:    flat_store_dword v[0:1], v3658; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)659; VI-GISEL-NEXT:    s_endpgm660;661; GFX9-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:662; GFX9-SDAG:       ; %bb.0:663; GFX9-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24664; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0665; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)666; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[2:3]667; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)668; GFX9-SDAG-NEXT:    v_add_f32_e32 v1, 1.0, v1669; GFX9-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v1670; GFX9-SDAG-NEXT:    v_min_f32_e32 v2, 4.0, v1671; GFX9-SDAG-NEXT:    global_store_dword v0, v2, s[0:1]672; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)673; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[0:1]674; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)675; GFX9-SDAG-NEXT:    s_endpgm676;677; GFX9-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:678; GFX9-GISEL:       ; %bb.0:679; GFX9-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24680; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0681; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)682; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[2:3]683; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)684; GFX9-GISEL-NEXT:    v_add_f32_e32 v1, 1.0, v1685; GFX9-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v1686; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0687; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[0:1]688; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)689; GFX9-GISEL-NEXT:    global_store_dword v0, v2, s[0:1]690; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)691; GFX9-GISEL-NEXT:    s_endpgm692;693; GFX11-SDAG-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:694; GFX11-SDAG:       ; %bb.0:695; GFX11-SDAG-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24696; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v0697; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)698; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0699; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)700; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3]701; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)702; GFX11-SDAG-NEXT:    v_add_f32_e32 v1, 1.0, v1703; GFX11-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v1704; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)705; GFX11-SDAG-NEXT:    v_min_f32_e32 v2, 4.0, v1706; GFX11-SDAG-NEXT:    global_store_b32 v0, v2, s[0:1] dlc707; GFX11-SDAG-NEXT:    s_waitcnt_vscnt null, 0x0708; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1] dlc709; GFX11-SDAG-NEXT:    s_waitcnt_vscnt null, 0x0710; GFX11-SDAG-NEXT:    s_endpgm711;712; GFX11-GISEL-LABEL: v_test_fmed3_nnan_r_i_i_multi_use_f32:713; GFX11-GISEL:       ; %bb.0:714; GFX11-GISEL-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24715; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v0716; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)717; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0718; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)719; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3]720; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)721; GFX11-GISEL-NEXT:    v_add_f32_e32 v1, 1.0, v1722; GFX11-GISEL-NEXT:    v_med3_f32 v2, v1, 2.0, 4.0723; GFX11-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v1724; GFX11-GISEL-NEXT:    global_store_b32 v0, v2, s[0:1] dlc725; GFX11-GISEL-NEXT:    s_waitcnt_vscnt null, 0x0726; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1] dlc727; GFX11-GISEL-NEXT:    s_waitcnt_vscnt null, 0x0728; GFX11-GISEL-NEXT:    s_endpgm729  %tid = call i32 @llvm.amdgcn.workitem.id.x()730  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid731  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid732  %a = load float, ptr addrspace(1) %gep0733  %a.add = fadd nnan float %a, 1.0734 735  %max = call float @llvm.maxnum.f32(float %a.add, float 2.0)736  %med = call float @llvm.minnum.f32(float %max, float 4.0)737 738  store volatile float %med, ptr addrspace(1) %outgep739  store volatile float %max, ptr addrspace(1) %outgep740  ret void741}742 743define amdgpu_kernel void @v_test_fmed3_r_i_i_f64(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {744; SI-SDAG-LABEL: v_test_fmed3_r_i_i_f64:745; SI-SDAG:       ; %bb.0:746; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9747; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000748; SI-SDAG-NEXT:    s_mov_b32 s6, 0749; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 3, v0750; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0751; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)752; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]753; SI-SDAG-NEXT:    buffer_load_dwordx2 v[2:3], v[0:1], s[4:7], 0 addr64754; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]755; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)756; SI-SDAG-NEXT:    v_add_f64 v[2:3], v[2:3], 1.0757; SI-SDAG-NEXT:    v_max_f64 v[2:3], v[2:3], 2.0758; SI-SDAG-NEXT:    v_min_f64 v[2:3], v[2:3], 4.0759; SI-SDAG-NEXT:    buffer_store_dwordx2 v[2:3], v[0:1], s[0:3], 0 addr64760; SI-SDAG-NEXT:    s_endpgm761;762; SI-GISEL-LABEL: v_test_fmed3_r_i_i_f64:763; SI-GISEL:       ; %bb.0:764; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9765; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 3, v0766; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0767; SI-GISEL-NEXT:    s_mov_b32 s6, 0768; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000769; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)770; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]771; SI-GISEL-NEXT:    buffer_load_dwordx2 v[2:3], v[0:1], s[4:7], 0 addr64772; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)773; SI-GISEL-NEXT:    v_add_f64 v[2:3], v[2:3], 1.0774; SI-GISEL-NEXT:    v_max_f64 v[2:3], v[2:3], 2.0775; SI-GISEL-NEXT:    v_min_f64 v[2:3], v[2:3], 4.0776; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]777; SI-GISEL-NEXT:    buffer_store_dwordx2 v[2:3], v[0:1], s[0:3], 0 addr64778; SI-GISEL-NEXT:    s_endpgm779;780; VI-SDAG-LABEL: v_test_fmed3_r_i_i_f64:781; VI-SDAG:       ; %bb.0:782; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24783; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 3, v0784; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)785; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3786; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2787; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc788; VI-SDAG-NEXT:    flat_load_dwordx2 v[0:1], v[0:1]789; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s1790; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s0, v2791; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc792; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)793; VI-SDAG-NEXT:    v_add_f64 v[0:1], v[0:1], 1.0794; VI-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0795; VI-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0796; VI-SDAG-NEXT:    flat_store_dwordx2 v[2:3], v[0:1]797; VI-SDAG-NEXT:    s_endpgm798;799; VI-GISEL-LABEL: v_test_fmed3_r_i_i_f64:800; VI-GISEL:       ; %bb.0:801; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24802; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v4, 3, v0803; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)804; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2805; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3806; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v4807; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc808; VI-GISEL-NEXT:    flat_load_dwordx2 v[0:1], v[0:1]809; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s1810; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s0811; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v4812; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc813; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)814; VI-GISEL-NEXT:    v_add_f64 v[0:1], v[0:1], 1.0815; VI-GISEL-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0816; VI-GISEL-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0817; VI-GISEL-NEXT:    flat_store_dwordx2 v[2:3], v[0:1]818; VI-GISEL-NEXT:    s_endpgm819;820; GFX9-LABEL: v_test_fmed3_r_i_i_f64:821; GFX9:       ; %bb.0:822; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24823; GFX9-NEXT:    v_lshlrev_b32_e32 v2, 3, v0824; GFX9-NEXT:    s_waitcnt lgkmcnt(0)825; GFX9-NEXT:    global_load_dwordx2 v[0:1], v2, s[2:3]826; GFX9-NEXT:    s_waitcnt vmcnt(0)827; GFX9-NEXT:    v_add_f64 v[0:1], v[0:1], 1.0828; GFX9-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0829; GFX9-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0830; GFX9-NEXT:    global_store_dwordx2 v2, v[0:1], s[0:1]831; GFX9-NEXT:    s_endpgm832;833; GFX11-LABEL: v_test_fmed3_r_i_i_f64:834; GFX11:       ; %bb.0:835; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24836; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0837; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)838; GFX11-NEXT:    v_lshlrev_b32_e32 v2, 3, v0839; GFX11-NEXT:    s_waitcnt lgkmcnt(0)840; GFX11-NEXT:    global_load_b64 v[0:1], v2, s[2:3]841; GFX11-NEXT:    s_waitcnt vmcnt(0)842; GFX11-NEXT:    v_add_f64 v[0:1], v[0:1], 1.0843; GFX11-NEXT:    v_max_f64 v[0:1], v[0:1], 2.0844; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)845; GFX11-NEXT:    v_min_f64 v[0:1], v[0:1], 4.0846; GFX11-NEXT:    global_store_b64 v2, v[0:1], s[0:1]847; GFX11-NEXT:    s_endpgm848  %tid = call i32 @llvm.amdgcn.workitem.id.x()849  %gep0 = getelementptr double, ptr addrspace(1) %aptr, i32 %tid850  %outgep = getelementptr double, ptr addrspace(1) %out, i32 %tid851  %a = load double, ptr addrspace(1) %gep0852  %a.add = fadd nnan double %a, 1.0853 854  %max = call double @llvm.maxnum.f64(double %a.add, double 2.0)855  %med = call double @llvm.minnum.f64(double %max, double 4.0)856 857  store double %med, ptr addrspace(1) %outgep858  ret void859}860 861define amdgpu_kernel void @v_test_fmed3_r_i_i_no_nans_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) #2 {862; SI-SDAG-LABEL: v_test_fmed3_r_i_i_no_nans_f32:863; SI-SDAG:       ; %bb.0:864; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9865; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000866; SI-SDAG-NEXT:    s_mov_b32 s6, 0867; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0868; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0869; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)870; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]871; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64872; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]873; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)874; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0875; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64876; SI-SDAG-NEXT:    s_endpgm877;878; SI-GISEL-LABEL: v_test_fmed3_r_i_i_no_nans_f32:879; SI-GISEL:       ; %bb.0:880; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9881; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0882; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0883; SI-GISEL-NEXT:    s_mov_b32 s6, 0884; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000885; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)886; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]887; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64888; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)889; SI-GISEL-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0890; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]891; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64892; SI-GISEL-NEXT:    s_endpgm893;894; VI-SDAG-LABEL: v_test_fmed3_r_i_i_no_nans_f32:895; VI-SDAG:       ; %bb.0:896; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24897; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v0898; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)899; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s3900; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v2901; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc902; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]903; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s1904; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v2905; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc906; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)907; VI-SDAG-NEXT:    v_med3_f32 v2, v3, 2.0, 4.0908; VI-SDAG-NEXT:    flat_store_dword v[0:1], v2909; VI-SDAG-NEXT:    s_endpgm910;911; VI-GISEL-LABEL: v_test_fmed3_r_i_i_no_nans_f32:912; VI-GISEL:       ; %bb.0:913; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24914; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v0915; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)916; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s2917; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s3918; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2919; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc920; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]921; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s0922; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s1923; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v2924; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc925; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)926; VI-GISEL-NEXT:    v_med3_f32 v2, v3, 2.0, 4.0927; VI-GISEL-NEXT:    flat_store_dword v[0:1], v2928; VI-GISEL-NEXT:    s_endpgm929;930; GFX9-LABEL: v_test_fmed3_r_i_i_no_nans_f32:931; GFX9:       ; %bb.0:932; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x24933; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v0934; GFX9-NEXT:    s_waitcnt lgkmcnt(0)935; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]936; GFX9-NEXT:    s_waitcnt vmcnt(0)937; GFX9-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0938; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]939; GFX9-NEXT:    s_endpgm940;941; GFX11-LABEL: v_test_fmed3_r_i_i_no_nans_f32:942; GFX11:       ; %bb.0:943; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x24944; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v0945; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)946; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v0947; GFX11-NEXT:    s_waitcnt lgkmcnt(0)948; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]949; GFX11-NEXT:    s_waitcnt vmcnt(0)950; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.0951; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]952; GFX11-NEXT:    s_endpgm953  %tid = call i32 @llvm.amdgcn.workitem.id.x()954  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid955  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid956  %a = load float, ptr addrspace(1) %gep0957 958  %max = call nnan float @llvm.maxnum.f32(float %a, float 2.0)959  %med = call nnan float @llvm.minnum.f32(float %max, float 4.0)960 961  store float %med, ptr addrspace(1) %outgep962  ret void963}964 965define amdgpu_kernel void @v_test_legacy_fmed3_r_i_i_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {966; SI-SDAG-LABEL: v_test_legacy_fmed3_r_i_i_f32:967; SI-SDAG:       ; %bb.0:968; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9969; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf000970; SI-SDAG-NEXT:    s_mov_b32 s6, 0971; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v0972; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 0973; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)974; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]975; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64976; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]977; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)978; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v2979; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.0980; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64981; SI-SDAG-NEXT:    s_endpgm982;983; SI-GISEL-LABEL: v_test_legacy_fmed3_r_i_i_f32:984; SI-GISEL:       ; %bb.0:985; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x9986; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v0987; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0988; SI-GISEL-NEXT:    s_mov_b32 s6, 0989; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf000990; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)991; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]992; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr64993; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)994; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v2995; SI-GISEL-NEXT:    v_max_legacy_f32_e64 v2, v2, 2.0996; SI-GISEL-NEXT:    v_min_legacy_f32_e64 v2, v2, 4.0997; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]998; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr64999; SI-GISEL-NEXT:    s_endpgm1000;1001; VI-SDAG-LABEL: v_test_legacy_fmed3_r_i_i_f32:1002; VI-SDAG:       ; %bb.0:1003; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x241004; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v01005; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1006; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31007; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v21008; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1009; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]1010; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11011; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v21012; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1013; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1014; VI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v31015; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.01016; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21017; VI-SDAG-NEXT:    s_endpgm1018;1019; VI-GISEL-LABEL: v_test_legacy_fmed3_r_i_i_f32:1020; VI-GISEL:       ; %bb.0:1021; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x241022; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v01023; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1024; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21025; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31026; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v21027; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1028; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]1029; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01030; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11031; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v21032; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1033; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1034; VI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v31035; VI-GISEL-NEXT:    v_cmp_nlt_f32_e32 vcc, 2.0, v21036; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 2.0, vcc1037; VI-GISEL-NEXT:    v_cmp_ngt_f32_e32 vcc, 4.0, v21038; VI-GISEL-NEXT:    v_cndmask_b32_e64 v2, v2, 4.0, vcc1039; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21040; VI-GISEL-NEXT:    s_endpgm1041;1042; GFX9-SDAG-LABEL: v_test_legacy_fmed3_r_i_i_f32:1043; GFX9-SDAG:       ; %bb.0:1044; GFX9-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x241045; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01046; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1047; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[2:3]1048; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1049; GFX9-SDAG-NEXT:    v_add_f32_e32 v1, 1.0, v11050; GFX9-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.01051; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[0:1]1052; GFX9-SDAG-NEXT:    s_endpgm1053;1054; GFX9-GISEL-LABEL: v_test_legacy_fmed3_r_i_i_f32:1055; GFX9-GISEL:       ; %bb.0:1056; GFX9-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x241057; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01058; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1059; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[2:3]1060; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1061; GFX9-GISEL-NEXT:    v_add_f32_e32 v1, 1.0, v11062; GFX9-GISEL-NEXT:    v_cmp_nlt_f32_e32 vcc, 2.0, v11063; GFX9-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 2.0, vcc1064; GFX9-GISEL-NEXT:    v_cmp_ngt_f32_e32 vcc, 4.0, v11065; GFX9-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 4.0, vcc1066; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[0:1]1067; GFX9-GISEL-NEXT:    s_endpgm1068;1069; GFX11-SDAG-LABEL: v_test_legacy_fmed3_r_i_i_f32:1070; GFX11-SDAG:       ; %bb.0:1071; GFX11-SDAG-NEXT:    s_load_b128 s[0:3], s[4:5], 0x241072; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v01073; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)1074; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01075; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1076; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3]1077; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1078; GFX11-SDAG-NEXT:    v_add_f32_e32 v1, 1.0, v11079; GFX11-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.01080; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]1081; GFX11-SDAG-NEXT:    s_endpgm1082;1083; GFX11-GISEL-LABEL: v_test_legacy_fmed3_r_i_i_f32:1084; GFX11-GISEL:       ; %bb.0:1085; GFX11-GISEL-NEXT:    s_load_b128 s[0:3], s[4:5], 0x241086; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v01087; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)1088; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01089; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1090; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3]1091; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1092; GFX11-GISEL-NEXT:    v_add_f32_e32 v1, 1.0, v11093; GFX11-GISEL-NEXT:    v_cmp_nlt_f32_e32 vcc_lo, 2.0, v11094; GFX11-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 2.0, vcc_lo1095; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1096; GFX11-GISEL-NEXT:    v_cmp_ngt_f32_e32 vcc_lo, 4.0, v11097; GFX11-GISEL-NEXT:    v_cndmask_b32_e64 v1, v1, 4.0, vcc_lo1098; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]1099; GFX11-GISEL-NEXT:    s_endpgm1100  %tid = call i32 @llvm.amdgcn.workitem.id.x()1101  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid1102  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid1103  %a = load float, ptr addrspace(1) %gep01104  %a.nnan = fadd nnan float %a, 1.01105 1106  ; fmax_legacy1107  %cmp0 = fcmp ule float %a.nnan, 2.01108  %max = select i1 %cmp0, float 2.0, float %a.nnan1109 1110  ; fmin_legacy1111  %cmp1 = fcmp uge float %max, 4.01112  %med = select i1 %cmp1, float 4.0, float %max1113 1114  store float %med, ptr addrspace(1) %outgep1115  ret void1116}1117 1118define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_srcmod0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {1119; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1120; SI-SDAG:       ; %bb.0:1121; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91122; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0001123; SI-SDAG-NEXT:    s_mov_b32 s10, 01124; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01125; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 01126; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]1127; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]1128; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1129; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]1130; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]1131; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]1132; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1133; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1134; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc1135; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1136; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc1137; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1138; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]1139; SI-SDAG-NEXT:    v_med3_f32 v2, -v2, v3, v41140; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641141; SI-SDAG-NEXT:    s_endpgm1142;1143; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1144; SI-GISEL:       ; %bb.0:1145; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91146; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01147; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 01148; SI-GISEL-NEXT:    s_mov_b32 s10, 01149; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0001150; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1151; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]1152; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1153; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1154; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]1155; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc1156; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1157; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]1158; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc1159; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1160; SI-GISEL-NEXT:    v_mul_f32_e32 v2, -1.0, v21161; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v41162; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]1163; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641164; SI-GISEL-NEXT:    s_endpgm1165;1166; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1167; VI-SDAG:       ; %bb.0:1168; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241169; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v01170; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1171; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31172; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v61173; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1174; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s51175; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v61176; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1177; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s71178; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v61179; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1180; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc1181; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1182; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc1183; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1184; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc1185; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1186; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11187; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v61188; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1189; VI-SDAG-NEXT:    v_med3_f32 v2, -v7, v2, v31190; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21191; VI-SDAG-NEXT:    s_endpgm1192;1193; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1194; VI-GISEL:       ; %bb.0:1195; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241196; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v01197; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1198; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21199; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31200; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61201; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1202; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s41203; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s51204; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v61205; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1206; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s61207; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s71208; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v61209; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1210; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc1211; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1212; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc1213; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1214; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc1215; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1216; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01217; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11218; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61219; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1220; VI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v71221; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v31222; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21223; VI-GISEL-NEXT:    s_endpgm1224;1225; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1226; GFX9-SDAG:       ; %bb.0:1227; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241228; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01229; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1230; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc1231; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1232; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc1233; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1234; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc1235; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1236; GFX9-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v31237; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]1238; GFX9-SDAG-NEXT:    s_endpgm1239;1240; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1241; GFX9-GISEL:       ; %bb.0:1242; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241243; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01244; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1245; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc1246; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1247; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc1248; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1249; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc1250; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1251; GFX9-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v11252; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31253; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]1254; GFX9-GISEL-NEXT:    s_endpgm1255;1256; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1257; GFX11-SDAG:       ; %bb.0:1258; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241259; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v01260; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)1261; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01262; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1263; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1264; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1265; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1266; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1267; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1268; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1269; GFX11-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v31270; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]1271; GFX11-SDAG-NEXT:    s_endpgm1272;1273; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0:1274; GFX11-GISEL:       ; %bb.0:1275; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241276; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v01277; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1278; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01279; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1280; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1281; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1282; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1283; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1284; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1285; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1286; GFX11-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v11287; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1288; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31289; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]1290; GFX11-GISEL-NEXT:    s_endpgm1291  %tid = call i32 @llvm.amdgcn.workitem.id.x()1292  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid1293  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid1294  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid1295  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid1296  %a = load volatile float, ptr addrspace(1) %gep01297  %b = load volatile float, ptr addrspace(1) %gep11298  %c = load volatile float, ptr addrspace(1) %gep21299  %a.fneg = fsub float -0.0, %a1300  %tmp0 = call nnan float @llvm.minnum.f32(float %a.fneg, float %b)1301  %tmp1 = call nnan float @llvm.maxnum.f32(float %a.fneg, float %b)1302  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)1303  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)1304  store float %med3, ptr addrspace(1) %outgep1305  ret void1306}1307 1308define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_srcmod1(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {1309; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1310; SI-SDAG:       ; %bb.0:1311; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91312; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0001313; SI-SDAG-NEXT:    s_mov_b32 s10, 01314; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01315; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 01316; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]1317; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]1318; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1319; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]1320; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]1321; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]1322; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1323; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1324; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc1325; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1326; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc1327; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1328; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]1329; SI-SDAG-NEXT:    v_med3_f32 v2, v2, -v3, v41330; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641331; SI-SDAG-NEXT:    s_endpgm1332;1333; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1334; SI-GISEL:       ; %bb.0:1335; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91336; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01337; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 01338; SI-GISEL-NEXT:    s_mov_b32 s10, 01339; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0001340; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1341; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]1342; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1343; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1344; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]1345; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc1346; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1347; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]1348; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc1349; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1350; SI-GISEL-NEXT:    v_mul_f32_e32 v3, -1.0, v31351; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v41352; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]1353; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641354; SI-GISEL-NEXT:    s_endpgm1355;1356; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1357; VI-SDAG:       ; %bb.0:1358; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241359; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v01360; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1361; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31362; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v61363; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1364; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s51365; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v61366; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1367; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s71368; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v61369; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1370; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc1371; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1372; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc1373; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1374; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc1375; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1376; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11377; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v61378; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1379; VI-SDAG-NEXT:    v_med3_f32 v2, v7, -v2, v31380; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21381; VI-SDAG-NEXT:    s_endpgm1382;1383; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1384; VI-GISEL:       ; %bb.0:1385; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241386; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v01387; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1388; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21389; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31390; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61391; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1392; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s41393; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s51394; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v61395; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1396; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s61397; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s71398; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v61399; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1400; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc1401; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1402; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc1403; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1404; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc1405; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1406; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01407; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11408; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61409; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1410; VI-GISEL-NEXT:    v_mul_f32_e32 v2, -1.0, v21411; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v31412; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21413; VI-GISEL-NEXT:    s_endpgm1414;1415; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1416; GFX9-SDAG:       ; %bb.0:1417; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241418; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01419; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1420; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc1421; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1422; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc1423; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1424; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc1425; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1426; GFX9-SDAG-NEXT:    v_med3_f32 v1, v1, -v2, v31427; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]1428; GFX9-SDAG-NEXT:    s_endpgm1429;1430; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1431; GFX9-GISEL:       ; %bb.0:1432; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241433; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01434; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1435; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc1436; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1437; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc1438; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1439; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc1440; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1441; GFX9-GISEL-NEXT:    v_max_f32_e64 v2, -v2, -v21442; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31443; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]1444; GFX9-GISEL-NEXT:    s_endpgm1445;1446; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1447; GFX11-SDAG:       ; %bb.0:1448; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241449; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v01450; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)1451; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01452; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1453; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1454; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1455; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1456; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1457; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1458; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1459; GFX11-SDAG-NEXT:    v_med3_f32 v1, v1, -v2, v31460; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]1461; GFX11-SDAG-NEXT:    s_endpgm1462;1463; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod1:1464; GFX11-GISEL:       ; %bb.0:1465; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241466; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v01467; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1468; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01469; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1470; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1471; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1472; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1473; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1474; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1475; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1476; GFX11-GISEL-NEXT:    v_max_f32_e64 v2, -v2, -v21477; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1478; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31479; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]1480; GFX11-GISEL-NEXT:    s_endpgm1481  %tid = call i32 @llvm.amdgcn.workitem.id.x()1482  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid1483  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid1484  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid1485  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid1486  %a = load volatile float, ptr addrspace(1) %gep01487  %b = load volatile float, ptr addrspace(1) %gep11488  %c = load volatile float, ptr addrspace(1) %gep21489  %b.fneg = fsub float -0.0, %b1490  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b.fneg)1491  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b.fneg)1492  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)1493  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)1494  store float %med3, ptr addrspace(1) %outgep1495  ret void1496}1497 1498define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_srcmod2(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {1499; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1500; SI-SDAG:       ; %bb.0:1501; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91502; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0001503; SI-SDAG-NEXT:    s_mov_b32 s10, 01504; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01505; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 01506; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]1507; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]1508; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1509; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]1510; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]1511; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]1512; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1513; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1514; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc1515; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1516; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc1517; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1518; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]1519; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, -v41520; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641521; SI-SDAG-NEXT:    s_endpgm1522;1523; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1524; SI-GISEL:       ; %bb.0:1525; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91526; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01527; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 01528; SI-GISEL-NEXT:    s_mov_b32 s10, 01529; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0001530; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1531; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]1532; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1533; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1534; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]1535; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc1536; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1537; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]1538; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc1539; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1540; SI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v41541; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v41542; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]1543; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641544; SI-GISEL-NEXT:    s_endpgm1545;1546; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1547; VI-SDAG:       ; %bb.0:1548; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241549; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v01550; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1551; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31552; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v61553; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1554; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s51555; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v61556; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1557; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s71558; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v61559; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1560; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc1561; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1562; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc1563; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1564; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc1565; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1566; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11567; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v61568; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1569; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, -v31570; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21571; VI-SDAG-NEXT:    s_endpgm1572;1573; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1574; VI-GISEL:       ; %bb.0:1575; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241576; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v01577; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1578; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21579; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31580; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61581; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1582; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s41583; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s51584; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v61585; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1586; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s61587; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s71588; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v61589; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1590; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc1591; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1592; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc1593; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1594; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc1595; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1596; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01597; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11598; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61599; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1600; VI-GISEL-NEXT:    v_mul_f32_e32 v3, -1.0, v31601; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v31602; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21603; VI-GISEL-NEXT:    s_endpgm1604;1605; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1606; GFX9-SDAG:       ; %bb.0:1607; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241608; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01609; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1610; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc1611; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1612; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc1613; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1614; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc1615; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1616; GFX9-SDAG-NEXT:    v_med3_f32 v1, v1, v2, -v31617; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]1618; GFX9-SDAG-NEXT:    s_endpgm1619;1620; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1621; GFX9-GISEL:       ; %bb.0:1622; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241623; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01624; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1625; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc1626; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1627; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc1628; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1629; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc1630; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1631; GFX9-GISEL-NEXT:    v_max_f32_e64 v3, -v3, -v31632; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31633; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]1634; GFX9-GISEL-NEXT:    s_endpgm1635;1636; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1637; GFX11-SDAG:       ; %bb.0:1638; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241639; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v01640; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)1641; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01642; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1643; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1644; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1645; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1646; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1647; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1648; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1649; GFX11-SDAG-NEXT:    v_med3_f32 v1, v1, v2, -v31650; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]1651; GFX11-SDAG-NEXT:    s_endpgm1652;1653; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod2:1654; GFX11-GISEL:       ; %bb.0:1655; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241656; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v01657; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1658; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01659; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1660; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1661; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1662; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1663; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1664; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1665; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1666; GFX11-GISEL-NEXT:    v_max_f32_e64 v3, -v3, -v31667; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1668; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v31669; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]1670; GFX11-GISEL-NEXT:    s_endpgm1671  %tid = call i32 @llvm.amdgcn.workitem.id.x()1672  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid1673  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid1674  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid1675  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid1676  %a = load volatile float, ptr addrspace(1) %gep01677  %b = load volatile float, ptr addrspace(1) %gep11678  %c = load volatile float, ptr addrspace(1) %gep21679  %c.fneg = fsub float -0.0, %c1680  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)1681  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)1682  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c.fneg)1683  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)1684  store float %med3, ptr addrspace(1) %outgep1685  ret void1686}1687 1688define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_srcmod012(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {1689; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1690; SI-SDAG:       ; %bb.0:1691; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91692; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0001693; SI-SDAG-NEXT:    s_mov_b32 s10, 01694; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01695; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 01696; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]1697; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]1698; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1699; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]1700; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]1701; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]1702; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1703; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1704; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc1705; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1706; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc1707; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1708; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]1709; SI-SDAG-NEXT:    v_med3_f32 v2, -v2, |v3|, -|v4|1710; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641711; SI-SDAG-NEXT:    s_endpgm1712;1713; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1714; SI-GISEL:       ; %bb.0:1715; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91716; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01717; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 01718; SI-GISEL-NEXT:    s_mov_b32 s10, 01719; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0001720; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1721; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]1722; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1723; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1724; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]1725; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc1726; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1727; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]1728; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc1729; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1730; SI-GISEL-NEXT:    v_mul_f32_e32 v2, -1.0, v21731; SI-GISEL-NEXT:    v_mul_f32_e64 v4, -1.0, |v4|1732; SI-GISEL-NEXT:    v_med3_f32 v2, v2, |v3|, v41733; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]1734; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641735; SI-GISEL-NEXT:    s_endpgm1736;1737; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1738; VI-SDAG:       ; %bb.0:1739; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241740; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v01741; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1742; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31743; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v61744; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1745; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s51746; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v61747; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1748; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s71749; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v61750; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1751; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc1752; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1753; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc1754; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1755; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc1756; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1757; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11758; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v61759; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1760; VI-SDAG-NEXT:    v_med3_f32 v2, -v7, |v2|, -|v3|1761; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21762; VI-SDAG-NEXT:    s_endpgm1763;1764; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1765; VI-GISEL:       ; %bb.0:1766; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241767; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v01768; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1769; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21770; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31771; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61772; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1773; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s41774; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s51775; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v61776; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1777; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s61778; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s71779; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v61780; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1781; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc1782; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1783; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc1784; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1785; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc1786; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1787; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01788; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11789; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61790; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1791; VI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v71792; VI-GISEL-NEXT:    v_mul_f32_e64 v3, -1.0, |v3|1793; VI-GISEL-NEXT:    v_med3_f32 v2, v4, |v2|, v31794; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21795; VI-GISEL-NEXT:    s_endpgm1796;1797; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1798; GFX9-SDAG:       ; %bb.0:1799; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241800; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01801; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1802; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc1803; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1804; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc1805; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1806; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc1807; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)1808; GFX9-SDAG-NEXT:    v_med3_f32 v1, -v1, |v2|, -|v3|1809; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]1810; GFX9-SDAG-NEXT:    s_endpgm1811;1812; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1813; GFX9-GISEL:       ; %bb.0:1814; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x241815; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01816; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1817; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc1818; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1819; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc1820; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1821; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc1822; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)1823; GFX9-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v11824; GFX9-GISEL-NEXT:    v_max_f32_e64 v3, -|v3|, -|v3|1825; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, |v2|, v31826; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]1827; GFX9-GISEL-NEXT:    s_endpgm1828;1829; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1830; GFX11-SDAG:       ; %bb.0:1831; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241832; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v01833; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)1834; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01835; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1836; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1837; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1838; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1839; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1840; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1841; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)1842; GFX11-SDAG-NEXT:    v_med3_f32 v1, -v1, |v2|, -|v3|1843; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]1844; GFX11-SDAG-NEXT:    s_endpgm1845;1846; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod012:1847; GFX11-GISEL:       ; %bb.0:1848; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x241849; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v01850; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1851; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01852; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1853; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc1854; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1855; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc1856; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1857; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc1858; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)1859; GFX11-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v11860; GFX11-GISEL-NEXT:    v_max_f32_e64 v3, -|v3|, -|v3|1861; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)1862; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, |v2|, v31863; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]1864; GFX11-GISEL-NEXT:    s_endpgm1865  %tid = call i32 @llvm.amdgcn.workitem.id.x()1866  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid1867  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid1868  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid1869  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid1870  %a = load volatile float, ptr addrspace(1) %gep01871  %b = load volatile float, ptr addrspace(1) %gep11872  %c = load volatile float, ptr addrspace(1) %gep21873 1874  %a.fneg = fsub float -0.0, %a1875  %b.fabs = call nnan float @llvm.fabs.f32(float %b)1876  %c.fabs = call nnan float @llvm.fabs.f32(float %c)1877  %c.fabs.fneg = fsub float -0.0, %c.fabs1878 1879  %tmp0 = call nnan float @llvm.minnum.f32(float %a.fneg, float %b.fabs)1880  %tmp1 = call nnan float @llvm.maxnum.f32(float %a.fneg, float %b.fabs)1881  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c.fabs.fneg)1882  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)1883 1884  store float %med3, ptr addrspace(1) %outgep1885  ret void1886}1887 1888define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_negabs012(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {1889; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:1890; SI-SDAG:       ; %bb.0:1891; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91892; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0001893; SI-SDAG-NEXT:    s_mov_b32 s10, 01894; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v01895; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 01896; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]1897; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]1898; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1899; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]1900; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]1901; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]1902; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1903; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1904; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc1905; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1906; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc1907; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)1908; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]1909; SI-SDAG-NEXT:    v_med3_f32 v2, -|v2|, -|v3|, -|v4|1910; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641911; SI-SDAG-NEXT:    s_endpgm1912;1913; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:1914; SI-GISEL:       ; %bb.0:1915; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x91916; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v01917; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 01918; SI-GISEL-NEXT:    s_mov_b32 s10, 01919; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0001920; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1921; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]1922; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc1923; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1924; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]1925; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc1926; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1927; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]1928; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc1929; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)1930; SI-GISEL-NEXT:    v_mul_f32_e64 v2, -1.0, |v2|1931; SI-GISEL-NEXT:    v_mul_f32_e64 v3, -1.0, |v3|1932; SI-GISEL-NEXT:    v_mul_f32_e64 v4, -1.0, |v4|1933; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v41934; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]1935; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr641936; SI-GISEL-NEXT:    s_endpgm1937;1938; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:1939; VI-SDAG:       ; %bb.0:1940; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241941; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v01942; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)1943; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s31944; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v61945; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1946; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s51947; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v61948; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1949; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s71950; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v61951; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1952; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc1953; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1954; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc1955; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1956; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc1957; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)1958; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s11959; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v61960; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1961; VI-SDAG-NEXT:    v_med3_f32 v2, -|v7|, -|v2|, -|v3|1962; VI-SDAG-NEXT:    flat_store_dword v[0:1], v21963; VI-SDAG-NEXT:    s_endpgm1964;1965; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:1966; VI-GISEL:       ; %bb.0:1967; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x241968; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v01969; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)1970; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s21971; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s31972; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61973; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1974; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s41975; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s51976; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v61977; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc1978; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s61979; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s71980; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v61981; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc1982; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc1983; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1984; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc1985; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1986; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc1987; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)1988; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s01989; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s11990; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v61991; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc1992; VI-GISEL-NEXT:    v_mul_f32_e64 v4, -1.0, |v7|1993; VI-GISEL-NEXT:    v_mul_f32_e64 v2, -1.0, |v2|1994; VI-GISEL-NEXT:    v_mul_f32_e64 v3, -1.0, |v3|1995; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v31996; VI-GISEL-NEXT:    flat_store_dword v[0:1], v21997; VI-GISEL-NEXT:    s_endpgm1998;1999; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:2000; GFX9-SDAG:       ; %bb.0:2001; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242002; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02003; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2004; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc2005; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)2006; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc2007; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)2008; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc2009; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)2010; GFX9-SDAG-NEXT:    v_med3_f32 v1, -|v1|, -|v2|, -|v3|2011; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]2012; GFX9-SDAG-NEXT:    s_endpgm2013;2014; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:2015; GFX9-GISEL:       ; %bb.0:2016; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242017; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02018; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2019; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc2020; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)2021; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc2022; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)2023; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc2024; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)2025; GFX9-GISEL-NEXT:    v_max_f32_e64 v1, -|v1|, -|v1|2026; GFX9-GISEL-NEXT:    v_max_f32_e64 v2, -|v2|, -|v2|2027; GFX9-GISEL-NEXT:    v_max_f32_e64 v3, -|v3|, -|v3|2028; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v32029; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]2030; GFX9-GISEL-NEXT:    s_endpgm2031;2032; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:2033; GFX11-SDAG:       ; %bb.0:2034; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242035; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v02036; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)2037; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02038; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2039; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2040; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)2041; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2042; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)2043; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2044; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)2045; GFX11-SDAG-NEXT:    v_med3_f32 v1, -|v1|, -|v2|, -|v3|2046; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]2047; GFX11-SDAG-NEXT:    s_endpgm2048;2049; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_negabs012:2050; GFX11-GISEL:       ; %bb.0:2051; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242052; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v02053; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)2054; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02055; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2056; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2057; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)2058; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2059; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)2060; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2061; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)2062; GFX11-GISEL-NEXT:    v_max_f32_e64 v1, -|v1|, -|v1|2063; GFX11-GISEL-NEXT:    v_max_f32_e64 v2, -|v2|, -|v2|2064; GFX11-GISEL-NEXT:    v_max_f32_e64 v3, -|v3|, -|v3|2065; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)2066; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v32067; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]2068; GFX11-GISEL-NEXT:    s_endpgm2069  %tid = call i32 @llvm.amdgcn.workitem.id.x()2070  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2071  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2072  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2073  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2074  %a = load volatile float, ptr addrspace(1) %gep02075  %b = load volatile float, ptr addrspace(1) %gep12076  %c = load volatile float, ptr addrspace(1) %gep22077 2078  %a.fabs = call float @llvm.fabs.f32(float %a)2079  %a.fabs.fneg = fsub float -0.0, %a.fabs2080  %b.fabs = call float @llvm.fabs.f32(float %b)2081  %b.fabs.fneg = fsub float -0.0, %b.fabs2082  %c.fabs = call float @llvm.fabs.f32(float %c)2083  %c.fabs.fneg = fsub float -0.0, %c.fabs2084 2085  %tmp0 = call nnan float @llvm.minnum.f32(float %a.fabs.fneg, float %b.fabs.fneg)2086  %tmp1 = call nnan float @llvm.maxnum.f32(float %a.fabs.fneg, float %b.fabs.fneg)2087  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c.fabs.fneg)2088  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)2089 2090  store float %med3, ptr addrspace(1) %outgep2091  ret void2092}2093 2094define amdgpu_kernel void @v_nnan_inputs_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {2095; SI-SDAG-LABEL: v_nnan_inputs_med3_f32_pat0:2096; SI-SDAG:       ; %bb.0:2097; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92098; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002099; SI-SDAG-NEXT:    s_mov_b32 s10, 02100; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02101; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02102; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2103; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2104; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2105; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2106; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2107; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2108; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2109; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2110; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2111; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2112; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2113; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2114; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2115; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v22116; SI-SDAG-NEXT:    v_add_f32_e32 v3, 2.0, v32117; SI-SDAG-NEXT:    v_add_f32_e32 v4, 4.0, v42118; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42119; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642120; SI-SDAG-NEXT:    s_endpgm2121;2122; SI-GISEL-LABEL: v_nnan_inputs_med3_f32_pat0:2123; SI-GISEL:       ; %bb.0:2124; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92125; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02126; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02127; SI-GISEL-NEXT:    s_mov_b32 s10, 02128; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002129; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2130; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2131; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2132; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2133; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2134; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2135; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2136; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2137; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2138; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2139; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v22140; SI-GISEL-NEXT:    v_add_f32_e32 v3, 2.0, v32141; SI-GISEL-NEXT:    v_add_f32_e32 v4, 4.0, v42142; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42143; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2144; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642145; SI-GISEL-NEXT:    s_endpgm2146;2147; VI-SDAG-LABEL: v_nnan_inputs_med3_f32_pat0:2148; VI-SDAG:       ; %bb.0:2149; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242150; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02151; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2152; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32153; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62154; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2155; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52156; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62157; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2158; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72159; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62160; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2161; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2162; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2163; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2164; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2165; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2166; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2167; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12168; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62169; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2170; VI-SDAG-NEXT:    v_add_f32_e32 v4, 1.0, v72171; VI-SDAG-NEXT:    v_add_f32_e32 v2, 2.0, v22172; VI-SDAG-NEXT:    v_add_f32_e32 v3, 4.0, v32173; VI-SDAG-NEXT:    v_med3_f32 v2, v4, v2, v32174; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22175; VI-SDAG-NEXT:    s_endpgm2176;2177; VI-GISEL-LABEL: v_nnan_inputs_med3_f32_pat0:2178; VI-GISEL:       ; %bb.0:2179; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242180; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02181; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2182; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22183; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32184; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62185; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2186; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42187; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52188; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62189; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2190; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62191; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72192; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62193; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2194; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2195; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2196; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2197; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2198; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2199; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2200; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02201; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12202; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62203; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2204; VI-GISEL-NEXT:    v_add_f32_e32 v4, 1.0, v72205; VI-GISEL-NEXT:    v_add_f32_e32 v2, 2.0, v22206; VI-GISEL-NEXT:    v_add_f32_e32 v3, 4.0, v32207; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v32208; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22209; VI-GISEL-NEXT:    s_endpgm2210;2211; GFX9-LABEL: v_nnan_inputs_med3_f32_pat0:2212; GFX9:       ; %bb.0:2213; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242214; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02215; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2216; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc2217; GFX9-NEXT:    s_waitcnt vmcnt(0)2218; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc2219; GFX9-NEXT:    s_waitcnt vmcnt(0)2220; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc2221; GFX9-NEXT:    s_waitcnt vmcnt(0)2222; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v12223; GFX9-NEXT:    v_add_f32_e32 v2, 2.0, v22224; GFX9-NEXT:    v_add_f32_e32 v3, 4.0, v32225; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v32226; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]2227; GFX9-NEXT:    s_endpgm2228;2229; GFX11-LABEL: v_nnan_inputs_med3_f32_pat0:2230; GFX11:       ; %bb.0:2231; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242232; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v02233; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2234; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v02235; GFX11-NEXT:    s_waitcnt lgkmcnt(0)2236; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2237; GFX11-NEXT:    s_waitcnt vmcnt(0)2238; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2239; GFX11-NEXT:    s_waitcnt vmcnt(0)2240; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2241; GFX11-NEXT:    s_waitcnt vmcnt(0)2242; GFX11-NEXT:    v_dual_add_f32 v1, 1.0, v1 :: v_dual_add_f32 v2, 2.0, v22243; GFX11-NEXT:    v_add_f32_e32 v3, 4.0, v32244; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2245; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v32246; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]2247; GFX11-NEXT:    s_endpgm2248  %tid = call i32 @llvm.amdgcn.workitem.id.x()2249  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2250  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2251  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2252  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2253  %a = load volatile float, ptr addrspace(1) %gep02254  %b = load volatile float, ptr addrspace(1) %gep12255  %c = load volatile float, ptr addrspace(1) %gep22256 2257  %a.nnan = fadd nnan float %a, 1.02258  %b.nnan = fadd nnan float %b, 2.02259  %c.nnan = fadd nnan float %c, 4.02260 2261  %tmp0 = call float @llvm.minnum.f32(float %a.nnan, float %b.nnan)2262  %tmp1 = call float @llvm.maxnum.f32(float %a.nnan, float %b.nnan)2263  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c.nnan)2264  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)2265  store float %med3, ptr addrspace(1) %outgep2266  ret void2267}2268 2269define amdgpu_kernel void @v_nnan_input_calls_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {2270; SI-SDAG-LABEL: v_nnan_input_calls_med3_f32_pat0:2271; SI-SDAG:       ; %bb.0:2272; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92273; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002274; SI-SDAG-NEXT:    s_mov_b32 s10, 02275; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02276; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02277; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2278; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2279; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2280; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2281; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2282; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2283; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2284; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2285; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2286; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2287; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2288; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2289; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2290; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42291; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642292; SI-SDAG-NEXT:    s_endpgm2293;2294; SI-GISEL-LABEL: v_nnan_input_calls_med3_f32_pat0:2295; SI-GISEL:       ; %bb.0:2296; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92297; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02298; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02299; SI-GISEL-NEXT:    s_mov_b32 s10, 02300; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002301; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2302; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2303; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2304; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2305; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2306; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2307; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2308; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2309; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2310; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2311; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42312; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2313; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642314; SI-GISEL-NEXT:    s_endpgm2315;2316; VI-SDAG-LABEL: v_nnan_input_calls_med3_f32_pat0:2317; VI-SDAG:       ; %bb.0:2318; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242319; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02320; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2321; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32322; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62323; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2324; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52325; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62326; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2327; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72328; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62329; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2330; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2331; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2332; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2333; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2334; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2335; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2336; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12337; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62338; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2339; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v32340; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22341; VI-SDAG-NEXT:    s_endpgm2342;2343; VI-GISEL-LABEL: v_nnan_input_calls_med3_f32_pat0:2344; VI-GISEL:       ; %bb.0:2345; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242346; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02347; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2348; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22349; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32350; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62351; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2352; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42353; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52354; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62355; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2356; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62357; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72358; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62359; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2360; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2361; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2362; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2363; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2364; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2365; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2366; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02367; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12368; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62369; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2370; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v32371; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22372; VI-GISEL-NEXT:    s_endpgm2373;2374; GFX9-LABEL: v_nnan_input_calls_med3_f32_pat0:2375; GFX9:       ; %bb.0:2376; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242377; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02378; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2379; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc2380; GFX9-NEXT:    s_waitcnt vmcnt(0)2381; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc2382; GFX9-NEXT:    s_waitcnt vmcnt(0)2383; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc2384; GFX9-NEXT:    s_waitcnt vmcnt(0)2385; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v32386; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]2387; GFX9-NEXT:    s_endpgm2388;2389; GFX11-LABEL: v_nnan_input_calls_med3_f32_pat0:2390; GFX11:       ; %bb.0:2391; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242392; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v02393; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2394; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v02395; GFX11-NEXT:    s_waitcnt lgkmcnt(0)2396; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2397; GFX11-NEXT:    s_waitcnt vmcnt(0)2398; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2399; GFX11-NEXT:    s_waitcnt vmcnt(0)2400; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2401; GFX11-NEXT:    s_waitcnt vmcnt(0)2402; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v32403; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]2404; GFX11-NEXT:    s_endpgm2405  %tid = call i32 @llvm.amdgcn.workitem.id.x()2406  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2407  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2408  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2409  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2410  %a = load volatile float, ptr addrspace(1) %gep02411  %b = load volatile float, ptr addrspace(1) %gep12412  %c = load volatile float, ptr addrspace(1) %gep22413  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)2414  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)2415  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)2416  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)2417  store float %med3, ptr addrspace(1) %outgep2418  ret void2419}2420 2421define amdgpu_kernel void @v_nnan_call_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {2422; SI-SDAG-LABEL: v_nnan_call_med3_f32_pat0:2423; SI-SDAG:       ; %bb.0:2424; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92425; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002426; SI-SDAG-NEXT:    s_mov_b32 s10, 02427; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02428; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02429; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2430; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2431; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2432; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2433; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2434; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2435; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2436; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2437; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2438; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2439; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2440; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2441; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2442; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42443; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642444; SI-SDAG-NEXT:    s_endpgm2445;2446; SI-GISEL-LABEL: v_nnan_call_med3_f32_pat0:2447; SI-GISEL:       ; %bb.0:2448; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92449; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02450; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02451; SI-GISEL-NEXT:    s_mov_b32 s10, 02452; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002453; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2454; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2455; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2456; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2457; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2458; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2459; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2460; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2461; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2462; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2463; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42464; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2465; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642466; SI-GISEL-NEXT:    s_endpgm2467;2468; VI-SDAG-LABEL: v_nnan_call_med3_f32_pat0:2469; VI-SDAG:       ; %bb.0:2470; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242471; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02472; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2473; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32474; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62475; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2476; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52477; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62478; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2479; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72480; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62481; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2482; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2483; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2484; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2485; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2486; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2487; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2488; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12489; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62490; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2491; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v32492; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22493; VI-SDAG-NEXT:    s_endpgm2494;2495; VI-GISEL-LABEL: v_nnan_call_med3_f32_pat0:2496; VI-GISEL:       ; %bb.0:2497; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242498; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02499; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2500; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22501; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32502; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62503; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2504; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42505; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52506; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62507; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2508; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62509; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72510; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62511; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2512; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2513; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2514; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2515; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2516; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2517; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2518; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02519; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12520; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62521; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2522; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v32523; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22524; VI-GISEL-NEXT:    s_endpgm2525;2526; GFX9-LABEL: v_nnan_call_med3_f32_pat0:2527; GFX9:       ; %bb.0:2528; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242529; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02530; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2531; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc2532; GFX9-NEXT:    s_waitcnt vmcnt(0)2533; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc2534; GFX9-NEXT:    s_waitcnt vmcnt(0)2535; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc2536; GFX9-NEXT:    s_waitcnt vmcnt(0)2537; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v32538; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]2539; GFX9-NEXT:    s_endpgm2540;2541; GFX11-LABEL: v_nnan_call_med3_f32_pat0:2542; GFX11:       ; %bb.0:2543; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242544; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v02545; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2546; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v02547; GFX11-NEXT:    s_waitcnt lgkmcnt(0)2548; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2549; GFX11-NEXT:    s_waitcnt vmcnt(0)2550; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2551; GFX11-NEXT:    s_waitcnt vmcnt(0)2552; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2553; GFX11-NEXT:    s_waitcnt vmcnt(0)2554; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v32555; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]2556; GFX11-NEXT:    s_endpgm2557  %tid = call i32 @llvm.amdgcn.workitem.id.x()2558  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2559  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2560  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2561  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2562  %a = load volatile float, ptr addrspace(1) %gep02563  %b = load volatile float, ptr addrspace(1) %gep12564  %c = load volatile float, ptr addrspace(1) %gep22565  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)2566  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)2567  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)2568  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)2569  store float %med3, ptr addrspace(1) %outgep2570  ret void2571}2572 2573define amdgpu_kernel void @v_fast_call_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {2574; SI-SDAG-LABEL: v_fast_call_med3_f32_pat0:2575; SI-SDAG:       ; %bb.0:2576; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92577; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002578; SI-SDAG-NEXT:    s_mov_b32 s10, 02579; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02580; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02581; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2582; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2583; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2584; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2585; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2586; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2587; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2588; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2589; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2590; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2591; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2592; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2593; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2594; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42595; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642596; SI-SDAG-NEXT:    s_endpgm2597;2598; SI-GISEL-LABEL: v_fast_call_med3_f32_pat0:2599; SI-GISEL:       ; %bb.0:2600; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92601; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02602; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02603; SI-GISEL-NEXT:    s_mov_b32 s10, 02604; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002605; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2606; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2607; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2608; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2609; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2610; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2611; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2612; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2613; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2614; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2615; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42616; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2617; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642618; SI-GISEL-NEXT:    s_endpgm2619;2620; VI-SDAG-LABEL: v_fast_call_med3_f32_pat0:2621; VI-SDAG:       ; %bb.0:2622; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242623; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02624; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2625; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32626; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62627; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2628; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52629; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62630; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2631; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72632; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62633; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2634; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2635; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2636; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2637; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2638; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2639; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2640; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12641; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62642; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2643; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v32644; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22645; VI-SDAG-NEXT:    s_endpgm2646;2647; VI-GISEL-LABEL: v_fast_call_med3_f32_pat0:2648; VI-GISEL:       ; %bb.0:2649; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242650; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02651; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2652; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22653; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32654; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62655; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2656; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42657; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52658; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62659; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2660; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62661; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72662; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62663; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2664; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2665; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2666; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2667; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2668; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2669; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2670; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02671; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12672; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62673; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2674; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v32675; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22676; VI-GISEL-NEXT:    s_endpgm2677;2678; GFX9-LABEL: v_fast_call_med3_f32_pat0:2679; GFX9:       ; %bb.0:2680; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242681; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02682; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2683; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc2684; GFX9-NEXT:    s_waitcnt vmcnt(0)2685; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc2686; GFX9-NEXT:    s_waitcnt vmcnt(0)2687; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc2688; GFX9-NEXT:    s_waitcnt vmcnt(0)2689; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v32690; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]2691; GFX9-NEXT:    s_endpgm2692;2693; GFX11-LABEL: v_fast_call_med3_f32_pat0:2694; GFX11:       ; %bb.0:2695; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242696; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v02697; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2698; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v02699; GFX11-NEXT:    s_waitcnt lgkmcnt(0)2700; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2701; GFX11-NEXT:    s_waitcnt vmcnt(0)2702; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2703; GFX11-NEXT:    s_waitcnt vmcnt(0)2704; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2705; GFX11-NEXT:    s_waitcnt vmcnt(0)2706; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v32707; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]2708; GFX11-NEXT:    s_endpgm2709  %tid = call i32 @llvm.amdgcn.workitem.id.x()2710  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2711  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2712  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2713  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2714  %a = load volatile float, ptr addrspace(1) %gep02715  %b = load volatile float, ptr addrspace(1) %gep12716  %c = load volatile float, ptr addrspace(1) %gep22717  %tmp0 = call fast float @llvm.minnum.f32(float %a, float %b)2718  %tmp1 = call fast float @llvm.maxnum.f32(float %a, float %b)2719  %tmp2 = call fast float @llvm.minnum.f32(float %tmp1, float %c)2720  %med3 = call fast float @llvm.maxnum.f32(float %tmp0, float %tmp2)2721  store float %med3, ptr addrspace(1) %outgep2722  ret void2723}2724 2725; 16 combinations2726 2727; 0: max(min(x, y), min(max(x, y), z))2728; 1: max(min(x, y), min(max(y, x), z))2729; 2: max(min(x, y), min(z, max(x, y)))2730; 3: max(min(x, y), min(z, max(y, x)))2731; 4: max(min(y, x), min(max(x, y), z))2732; 5: max(min(y, x), min(max(y, x), z))2733; 6: max(min(y, x), min(z, max(x, y)))2734; 7: max(min(y, x), min(z, max(y, x)))2735; + commute outermost max2736 2737define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {2738; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0:2739; SI-SDAG:       ; %bb.0:2740; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92741; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002742; SI-SDAG-NEXT:    s_mov_b32 s10, 02743; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02744; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02745; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2746; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2747; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2748; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2749; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2750; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2751; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2752; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2753; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2754; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2755; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2756; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2757; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2758; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42759; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642760; SI-SDAG-NEXT:    s_endpgm2761;2762; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0:2763; SI-GISEL:       ; %bb.0:2764; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92765; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02766; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02767; SI-GISEL-NEXT:    s_mov_b32 s10, 02768; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002769; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2770; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2771; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2772; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2773; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2774; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2775; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2776; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2777; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2778; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2779; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42780; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2781; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642782; SI-GISEL-NEXT:    s_endpgm2783;2784; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0:2785; VI-SDAG:       ; %bb.0:2786; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242787; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02788; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2789; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32790; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62791; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2792; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52793; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62794; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2795; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72796; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62797; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2798; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2799; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2800; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2801; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2802; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2803; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2804; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12805; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62806; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2807; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v32808; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22809; VI-SDAG-NEXT:    s_endpgm2810;2811; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0:2812; VI-GISEL:       ; %bb.0:2813; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242814; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02815; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2816; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22817; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32818; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62819; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2820; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42821; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52822; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62823; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2824; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62825; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72826; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62827; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2828; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2829; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2830; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2831; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2832; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2833; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2834; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02835; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12836; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62837; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2838; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v32839; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22840; VI-GISEL-NEXT:    s_endpgm2841;2842; GFX9-LABEL: v_test_global_nnans_med3_f32_pat0:2843; GFX9:       ; %bb.0:2844; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242845; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02846; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2847; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc2848; GFX9-NEXT:    s_waitcnt vmcnt(0)2849; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc2850; GFX9-NEXT:    s_waitcnt vmcnt(0)2851; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc2852; GFX9-NEXT:    s_waitcnt vmcnt(0)2853; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v32854; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]2855; GFX9-NEXT:    s_endpgm2856;2857; GFX11-LABEL: v_test_global_nnans_med3_f32_pat0:2858; GFX11:       ; %bb.0:2859; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x242860; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v02861; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)2862; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v02863; GFX11-NEXT:    s_waitcnt lgkmcnt(0)2864; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc2865; GFX11-NEXT:    s_waitcnt vmcnt(0)2866; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc2867; GFX11-NEXT:    s_waitcnt vmcnt(0)2868; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc2869; GFX11-NEXT:    s_waitcnt vmcnt(0)2870; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v32871; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]2872; GFX11-NEXT:    s_endpgm2873  %tid = call i32 @llvm.amdgcn.workitem.id.x()2874  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid2875  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid2876  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid2877  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid2878  %a = load volatile float, ptr addrspace(1) %gep02879  %b = load volatile float, ptr addrspace(1) %gep12880  %c = load volatile float, ptr addrspace(1) %gep22881  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)2882  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)2883  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)2884  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)2885  store float %med3, ptr addrspace(1) %outgep2886  ret void2887}2888 2889define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat1(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {2890; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1:2891; SI-SDAG:       ; %bb.0:2892; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92893; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0002894; SI-SDAG-NEXT:    s_mov_b32 s10, 02895; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v02896; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 02897; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]2898; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]2899; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2900; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]2901; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]2902; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]2903; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2904; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2905; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc2906; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2907; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc2908; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)2909; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]2910; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v42911; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642912; SI-SDAG-NEXT:    s_endpgm2913;2914; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1:2915; SI-GISEL:       ; %bb.0:2916; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x92917; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v02918; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 02919; SI-GISEL-NEXT:    s_mov_b32 s10, 02920; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0002921; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2922; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]2923; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc2924; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2925; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]2926; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc2927; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2928; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]2929; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc2930; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)2931; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v42932; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]2933; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr642934; SI-GISEL-NEXT:    s_endpgm2935;2936; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1:2937; VI-SDAG:       ; %bb.0:2938; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242939; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v02940; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)2941; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s32942; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v62943; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2944; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s52945; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v62946; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2947; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s72948; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v62949; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2950; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc2951; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2952; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc2953; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2954; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc2955; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)2956; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s12957; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v62958; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2959; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v32960; VI-SDAG-NEXT:    flat_store_dword v[0:1], v22961; VI-SDAG-NEXT:    s_endpgm2962;2963; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1:2964; VI-GISEL:       ; %bb.0:2965; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x242966; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v02967; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)2968; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s22969; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s32970; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62971; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2972; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s42973; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s52974; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v62975; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc2976; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s62977; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s72978; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v62979; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc2980; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc2981; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2982; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc2983; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2984; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc2985; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)2986; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s02987; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s12988; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v62989; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc2990; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v32991; VI-GISEL-NEXT:    flat_store_dword v[0:1], v22992; VI-GISEL-NEXT:    s_endpgm2993;2994; GFX9-LABEL: v_test_global_nnans_med3_f32_pat1:2995; GFX9:       ; %bb.0:2996; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x242997; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v02998; GFX9-NEXT:    s_waitcnt lgkmcnt(0)2999; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3000; GFX9-NEXT:    s_waitcnt vmcnt(0)3001; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3002; GFX9-NEXT:    s_waitcnt vmcnt(0)3003; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3004; GFX9-NEXT:    s_waitcnt vmcnt(0)3005; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v33006; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3007; GFX9-NEXT:    s_endpgm3008;3009; GFX11-LABEL: v_test_global_nnans_med3_f32_pat1:3010; GFX11:       ; %bb.0:3011; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243012; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03013; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3014; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03015; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3016; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3017; GFX11-NEXT:    s_waitcnt vmcnt(0)3018; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3019; GFX11-NEXT:    s_waitcnt vmcnt(0)3020; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3021; GFX11-NEXT:    s_waitcnt vmcnt(0)3022; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v33023; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3024; GFX11-NEXT:    s_endpgm3025  %tid = call i32 @llvm.amdgcn.workitem.id.x()3026  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3027  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3028  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3029  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3030  %a = load volatile float, ptr addrspace(1) %gep03031  %b = load volatile float, ptr addrspace(1) %gep13032  %c = load volatile float, ptr addrspace(1) %gep23033  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)3034  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)3035  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)3036  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3037  store float %med3, ptr addrspace(1) %outgep3038  ret void3039}3040 3041define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat1_srcmod0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3042; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3043; SI-SDAG:       ; %bb.0:3044; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93045; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003046; SI-SDAG-NEXT:    s_mov_b32 s10, 03047; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03048; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03049; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3050; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3051; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3052; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3053; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3054; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3055; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3056; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3057; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3058; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3059; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3060; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3061; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3062; SI-SDAG-NEXT:    v_med3_f32 v2, -v2, v3, v43063; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643064; SI-SDAG-NEXT:    s_endpgm3065;3066; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3067; SI-GISEL:       ; %bb.0:3068; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93069; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03070; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03071; SI-GISEL-NEXT:    s_mov_b32 s10, 03072; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003073; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3074; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3075; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3076; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3077; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3078; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3079; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3080; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3081; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3082; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3083; SI-GISEL-NEXT:    v_mul_f32_e32 v2, -1.0, v23084; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v43085; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3086; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643087; SI-GISEL-NEXT:    s_endpgm3088;3089; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3090; VI-SDAG:       ; %bb.0:3091; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243092; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03093; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3094; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33095; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63096; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3097; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53098; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63099; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3100; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73101; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63102; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3103; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3104; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3105; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3106; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3107; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3108; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3109; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13110; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63111; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3112; VI-SDAG-NEXT:    v_med3_f32 v2, -v7, v2, v33113; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23114; VI-SDAG-NEXT:    s_endpgm3115;3116; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3117; VI-GISEL:       ; %bb.0:3118; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243119; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03120; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3121; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23122; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33123; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63124; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3125; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43126; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53127; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63128; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3129; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63130; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73131; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63132; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3133; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3134; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3135; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3136; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3137; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3138; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3139; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03140; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13141; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63142; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3143; VI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v73144; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v33145; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23146; VI-GISEL-NEXT:    s_endpgm3147;3148; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3149; GFX9-SDAG:       ; %bb.0:3150; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243151; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03152; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3153; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc3154; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)3155; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc3156; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)3157; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc3158; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)3159; GFX9-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v33160; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]3161; GFX9-SDAG-NEXT:    s_endpgm3162;3163; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3164; GFX9-GISEL:       ; %bb.0:3165; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243166; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03167; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3168; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc3169; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)3170; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc3171; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)3172; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc3173; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)3174; GFX9-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v13175; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v33176; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]3177; GFX9-GISEL-NEXT:    s_endpgm3178;3179; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3180; GFX11-SDAG:       ; %bb.0:3181; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243182; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v03183; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)3184; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03185; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3186; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3187; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)3188; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3189; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)3190; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3191; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)3192; GFX11-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v33193; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]3194; GFX11-SDAG-NEXT:    s_endpgm3195;3196; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat1_srcmod0:3197; GFX11-GISEL:       ; %bb.0:3198; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243199; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v03200; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)3201; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03202; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3203; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3204; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)3205; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3206; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)3207; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3208; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)3209; GFX11-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v13210; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)3211; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v33212; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]3213; GFX11-GISEL-NEXT:    s_endpgm3214  %tid = call i32 @llvm.amdgcn.workitem.id.x()3215  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3216  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3217  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3218  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3219  %a = load volatile float, ptr addrspace(1) %gep03220  %b = load volatile float, ptr addrspace(1) %gep13221  %c = load volatile float, ptr addrspace(1) %gep23222  %a.fneg = fsub float -0.0, %a3223  %tmp0 = call nnan float @llvm.maxnum.f32(float %a.fneg, float %b)3224  %tmp1 = call nnan float @llvm.minnum.f32(float %a.fneg, float %b)3225  %tmp2 = call nnan float @llvm.maxnum.f32(float %tmp1, float %c)3226  %med3 = call nnan float @llvm.minnum.f32(float %tmp0, float %tmp2)3227  store float %med3, ptr addrspace(1) %outgep3228  ret void3229}3230 3231define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat2(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3232; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat2:3233; SI-SDAG:       ; %bb.0:3234; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93235; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003236; SI-SDAG-NEXT:    s_mov_b32 s10, 03237; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03238; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03239; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3240; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3241; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3242; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3243; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3244; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3245; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3246; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3247; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3248; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3249; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3250; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3251; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3252; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v43253; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643254; SI-SDAG-NEXT:    s_endpgm3255;3256; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat2:3257; SI-GISEL:       ; %bb.0:3258; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93259; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03260; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03261; SI-GISEL-NEXT:    s_mov_b32 s10, 03262; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003263; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3264; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3265; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3266; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3267; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3268; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3269; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3270; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3271; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3272; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3273; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v43274; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3275; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643276; SI-GISEL-NEXT:    s_endpgm3277;3278; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat2:3279; VI-SDAG:       ; %bb.0:3280; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243281; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03282; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3283; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33284; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63285; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3286; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53287; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63288; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3289; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73290; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63291; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3292; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3293; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3294; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3295; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3296; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3297; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3298; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13299; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63300; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3301; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v33302; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23303; VI-SDAG-NEXT:    s_endpgm3304;3305; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat2:3306; VI-GISEL:       ; %bb.0:3307; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243308; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03309; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3310; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23311; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33312; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63313; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3314; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43315; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53316; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63317; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3318; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63319; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73320; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63321; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3322; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3323; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3324; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3325; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3326; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3327; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3328; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03329; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13330; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63331; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3332; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v33333; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23334; VI-GISEL-NEXT:    s_endpgm3335;3336; GFX9-LABEL: v_test_global_nnans_med3_f32_pat2:3337; GFX9:       ; %bb.0:3338; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243339; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v03340; GFX9-NEXT:    s_waitcnt lgkmcnt(0)3341; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3342; GFX9-NEXT:    s_waitcnt vmcnt(0)3343; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3344; GFX9-NEXT:    s_waitcnt vmcnt(0)3345; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3346; GFX9-NEXT:    s_waitcnt vmcnt(0)3347; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v33348; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3349; GFX9-NEXT:    s_endpgm3350;3351; GFX11-LABEL: v_test_global_nnans_med3_f32_pat2:3352; GFX11:       ; %bb.0:3353; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243354; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03355; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3356; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03357; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3358; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3359; GFX11-NEXT:    s_waitcnt vmcnt(0)3360; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3361; GFX11-NEXT:    s_waitcnt vmcnt(0)3362; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3363; GFX11-NEXT:    s_waitcnt vmcnt(0)3364; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v33365; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3366; GFX11-NEXT:    s_endpgm3367  %tid = call i32 @llvm.amdgcn.workitem.id.x()3368  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3369  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3370  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3371  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3372  %a = load volatile float, ptr addrspace(1) %gep03373  %b = load volatile float, ptr addrspace(1) %gep13374  %c = load volatile float, ptr addrspace(1) %gep23375  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)3376  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)3377  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)3378  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3379  store float %med3, ptr addrspace(1) %outgep3380  ret void3381}3382 3383define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat3(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3384; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat3:3385; SI-SDAG:       ; %bb.0:3386; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93387; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003388; SI-SDAG-NEXT:    s_mov_b32 s10, 03389; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03390; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03391; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3392; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3393; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3394; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3395; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3396; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3397; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3398; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3399; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3400; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3401; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3402; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3403; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3404; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v43405; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643406; SI-SDAG-NEXT:    s_endpgm3407;3408; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat3:3409; SI-GISEL:       ; %bb.0:3410; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93411; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03412; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03413; SI-GISEL-NEXT:    s_mov_b32 s10, 03414; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003415; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3416; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3417; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3418; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3419; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3420; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3421; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3422; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3423; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3424; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3425; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v43426; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3427; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643428; SI-GISEL-NEXT:    s_endpgm3429;3430; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat3:3431; VI-SDAG:       ; %bb.0:3432; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243433; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03434; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3435; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33436; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63437; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3438; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53439; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63440; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3441; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73442; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63443; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3444; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3445; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3446; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3447; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3448; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3449; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3450; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13451; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63452; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3453; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v33454; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23455; VI-SDAG-NEXT:    s_endpgm3456;3457; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat3:3458; VI-GISEL:       ; %bb.0:3459; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243460; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03461; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3462; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23463; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33464; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63465; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3466; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43467; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53468; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63469; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3470; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63471; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73472; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63473; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3474; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3475; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3476; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3477; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3478; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3479; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3480; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03481; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13482; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63483; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3484; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v33485; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23486; VI-GISEL-NEXT:    s_endpgm3487;3488; GFX9-LABEL: v_test_global_nnans_med3_f32_pat3:3489; GFX9:       ; %bb.0:3490; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243491; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v03492; GFX9-NEXT:    s_waitcnt lgkmcnt(0)3493; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3494; GFX9-NEXT:    s_waitcnt vmcnt(0)3495; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3496; GFX9-NEXT:    s_waitcnt vmcnt(0)3497; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3498; GFX9-NEXT:    s_waitcnt vmcnt(0)3499; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v33500; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3501; GFX9-NEXT:    s_endpgm3502;3503; GFX11-LABEL: v_test_global_nnans_med3_f32_pat3:3504; GFX11:       ; %bb.0:3505; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243506; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03507; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3508; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03509; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3510; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3511; GFX11-NEXT:    s_waitcnt vmcnt(0)3512; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3513; GFX11-NEXT:    s_waitcnt vmcnt(0)3514; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3515; GFX11-NEXT:    s_waitcnt vmcnt(0)3516; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v33517; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3518; GFX11-NEXT:    s_endpgm3519  %tid = call i32 @llvm.amdgcn.workitem.id.x()3520  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3521  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3522  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3523  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3524  %a = load volatile float, ptr addrspace(1) %gep03525  %b = load volatile float, ptr addrspace(1) %gep13526  %c = load volatile float, ptr addrspace(1) %gep23527  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)3528  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)3529  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)3530  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3531  store float %med3, ptr addrspace(1) %outgep3532  ret void3533}3534 3535define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat4(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3536; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat4:3537; SI-SDAG:       ; %bb.0:3538; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93539; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003540; SI-SDAG-NEXT:    s_mov_b32 s10, 03541; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03542; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03543; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3544; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3545; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3546; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3547; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3548; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3549; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3550; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3551; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3552; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3553; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3554; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3555; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3556; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v43557; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643558; SI-SDAG-NEXT:    s_endpgm3559;3560; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat4:3561; SI-GISEL:       ; %bb.0:3562; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93563; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03564; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03565; SI-GISEL-NEXT:    s_mov_b32 s10, 03566; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003567; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3568; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3569; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3570; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3571; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3572; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3573; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3574; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3575; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3576; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3577; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v43578; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3579; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643580; SI-GISEL-NEXT:    s_endpgm3581;3582; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat4:3583; VI-SDAG:       ; %bb.0:3584; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243585; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03586; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3587; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33588; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63589; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3590; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53591; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63592; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3593; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73594; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63595; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3596; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3597; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3598; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3599; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3600; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3601; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3602; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13603; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63604; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3605; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v33606; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23607; VI-SDAG-NEXT:    s_endpgm3608;3609; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat4:3610; VI-GISEL:       ; %bb.0:3611; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243612; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03613; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3614; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23615; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33616; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63617; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3618; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43619; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53620; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63621; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3622; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63623; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73624; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63625; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3626; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3627; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3628; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3629; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3630; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3631; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3632; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03633; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13634; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63635; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3636; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v33637; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23638; VI-GISEL-NEXT:    s_endpgm3639;3640; GFX9-LABEL: v_test_global_nnans_med3_f32_pat4:3641; GFX9:       ; %bb.0:3642; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243643; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v03644; GFX9-NEXT:    s_waitcnt lgkmcnt(0)3645; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3646; GFX9-NEXT:    s_waitcnt vmcnt(0)3647; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3648; GFX9-NEXT:    s_waitcnt vmcnt(0)3649; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3650; GFX9-NEXT:    s_waitcnt vmcnt(0)3651; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v33652; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3653; GFX9-NEXT:    s_endpgm3654;3655; GFX11-LABEL: v_test_global_nnans_med3_f32_pat4:3656; GFX11:       ; %bb.0:3657; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243658; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03659; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3660; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03661; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3662; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3663; GFX11-NEXT:    s_waitcnt vmcnt(0)3664; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3665; GFX11-NEXT:    s_waitcnt vmcnt(0)3666; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3667; GFX11-NEXT:    s_waitcnt vmcnt(0)3668; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v33669; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3670; GFX11-NEXT:    s_endpgm3671  %tid = call i32 @llvm.amdgcn.workitem.id.x()3672  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3673  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3674  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3675  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3676  %a = load volatile float, ptr addrspace(1) %gep03677  %b = load volatile float, ptr addrspace(1) %gep13678  %c = load volatile float, ptr addrspace(1) %gep23679  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)3680  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)3681  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)3682  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3683  store float %med3, ptr addrspace(1) %outgep3684  ret void3685}3686 3687define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat5(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3688; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat5:3689; SI-SDAG:       ; %bb.0:3690; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93691; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003692; SI-SDAG-NEXT:    s_mov_b32 s10, 03693; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03694; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03695; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3696; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3697; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3698; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3699; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3700; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3701; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3702; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3703; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3704; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3705; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3706; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3707; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3708; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v43709; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643710; SI-SDAG-NEXT:    s_endpgm3711;3712; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat5:3713; SI-GISEL:       ; %bb.0:3714; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93715; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03716; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03717; SI-GISEL-NEXT:    s_mov_b32 s10, 03718; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003719; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3720; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3721; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3722; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3723; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3724; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3725; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3726; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3727; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3728; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3729; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v43730; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3731; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643732; SI-GISEL-NEXT:    s_endpgm3733;3734; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat5:3735; VI-SDAG:       ; %bb.0:3736; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243737; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03738; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3739; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33740; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63741; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3742; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53743; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63744; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3745; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73746; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63747; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3748; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3749; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3750; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3751; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3752; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3753; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3754; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13755; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63756; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3757; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v33758; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23759; VI-SDAG-NEXT:    s_endpgm3760;3761; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat5:3762; VI-GISEL:       ; %bb.0:3763; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243764; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03765; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3766; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23767; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33768; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63769; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3770; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43771; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53772; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63773; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3774; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63775; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73776; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63777; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3778; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3779; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3780; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3781; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3782; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3783; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3784; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03785; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13786; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63787; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3788; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v33789; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23790; VI-GISEL-NEXT:    s_endpgm3791;3792; GFX9-LABEL: v_test_global_nnans_med3_f32_pat5:3793; GFX9:       ; %bb.0:3794; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243795; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v03796; GFX9-NEXT:    s_waitcnt lgkmcnt(0)3797; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3798; GFX9-NEXT:    s_waitcnt vmcnt(0)3799; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3800; GFX9-NEXT:    s_waitcnt vmcnt(0)3801; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3802; GFX9-NEXT:    s_waitcnt vmcnt(0)3803; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v33804; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3805; GFX9-NEXT:    s_endpgm3806;3807; GFX11-LABEL: v_test_global_nnans_med3_f32_pat5:3808; GFX11:       ; %bb.0:3809; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243810; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03811; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3812; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03813; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3814; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3815; GFX11-NEXT:    s_waitcnt vmcnt(0)3816; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3817; GFX11-NEXT:    s_waitcnt vmcnt(0)3818; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3819; GFX11-NEXT:    s_waitcnt vmcnt(0)3820; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v33821; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3822; GFX11-NEXT:    s_endpgm3823  %tid = call i32 @llvm.amdgcn.workitem.id.x()3824  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3825  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3826  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3827  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3828  %a = load volatile float, ptr addrspace(1) %gep03829  %b = load volatile float, ptr addrspace(1) %gep13830  %c = load volatile float, ptr addrspace(1) %gep23831  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)3832  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)3833  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)3834  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3835  store float %med3, ptr addrspace(1) %outgep3836  ret void3837}3838 3839define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat6(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3840; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat6:3841; SI-SDAG:       ; %bb.0:3842; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93843; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003844; SI-SDAG-NEXT:    s_mov_b32 s10, 03845; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03846; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03847; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]3848; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]3849; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3850; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]3851; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]3852; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]3853; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3854; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3855; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc3856; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3857; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc3858; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)3859; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]3860; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v43861; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643862; SI-SDAG-NEXT:    s_endpgm3863;3864; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat6:3865; SI-GISEL:       ; %bb.0:3866; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93867; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v03868; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 03869; SI-GISEL-NEXT:    s_mov_b32 s10, 03870; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0003871; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3872; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]3873; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc3874; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3875; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]3876; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc3877; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3878; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]3879; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc3880; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)3881; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v43882; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]3883; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr643884; SI-GISEL-NEXT:    s_endpgm3885;3886; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat6:3887; VI-SDAG:       ; %bb.0:3888; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243889; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v03890; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)3891; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s33892; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v63893; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3894; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s53895; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v63896; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3897; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s73898; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v63899; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3900; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc3901; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3902; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc3903; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3904; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc3905; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)3906; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s13907; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v63908; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3909; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v33910; VI-SDAG-NEXT:    flat_store_dword v[0:1], v23911; VI-SDAG-NEXT:    s_endpgm3912;3913; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat6:3914; VI-GISEL:       ; %bb.0:3915; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x243916; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v03917; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)3918; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s23919; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s33920; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63921; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3922; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s43923; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s53924; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v63925; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc3926; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s63927; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s73928; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v63929; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc3930; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc3931; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3932; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc3933; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3934; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc3935; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)3936; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s03937; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s13938; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v63939; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc3940; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v33941; VI-GISEL-NEXT:    flat_store_dword v[0:1], v23942; VI-GISEL-NEXT:    s_endpgm3943;3944; GFX9-LABEL: v_test_global_nnans_med3_f32_pat6:3945; GFX9:       ; %bb.0:3946; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x243947; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v03948; GFX9-NEXT:    s_waitcnt lgkmcnt(0)3949; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc3950; GFX9-NEXT:    s_waitcnt vmcnt(0)3951; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc3952; GFX9-NEXT:    s_waitcnt vmcnt(0)3953; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc3954; GFX9-NEXT:    s_waitcnt vmcnt(0)3955; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v33956; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]3957; GFX9-NEXT:    s_endpgm3958;3959; GFX11-LABEL: v_test_global_nnans_med3_f32_pat6:3960; GFX11:       ; %bb.0:3961; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x243962; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v03963; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)3964; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v03965; GFX11-NEXT:    s_waitcnt lgkmcnt(0)3966; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc3967; GFX11-NEXT:    s_waitcnt vmcnt(0)3968; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc3969; GFX11-NEXT:    s_waitcnt vmcnt(0)3970; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc3971; GFX11-NEXT:    s_waitcnt vmcnt(0)3972; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v33973; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]3974; GFX11-NEXT:    s_endpgm3975  %tid = call i32 @llvm.amdgcn.workitem.id.x()3976  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid3977  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid3978  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid3979  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid3980  %a = load volatile float, ptr addrspace(1) %gep03981  %b = load volatile float, ptr addrspace(1) %gep13982  %c = load volatile float, ptr addrspace(1) %gep23983  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)3984  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)3985  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)3986  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)3987  store float %med3, ptr addrspace(1) %outgep3988  ret void3989}3990 3991define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat7(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {3992; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat7:3993; SI-SDAG:       ; %bb.0:3994; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x93995; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0003996; SI-SDAG-NEXT:    s_mov_b32 s10, 03997; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v03998; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 03999; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4000; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4001; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4002; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4003; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4004; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4005; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4006; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4007; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4008; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4009; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4010; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4011; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4012; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v44013; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644014; SI-SDAG-NEXT:    s_endpgm4015;4016; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat7:4017; SI-GISEL:       ; %bb.0:4018; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94019; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04020; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04021; SI-GISEL-NEXT:    s_mov_b32 s10, 04022; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004023; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4024; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4025; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4026; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4027; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4028; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4029; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4030; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4031; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4032; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4033; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v44034; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4035; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644036; SI-GISEL-NEXT:    s_endpgm4037;4038; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat7:4039; VI-SDAG:       ; %bb.0:4040; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244041; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04042; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4043; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34044; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64045; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4046; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54047; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64048; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4049; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74050; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64051; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4052; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4053; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4054; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4055; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4056; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4057; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4058; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14059; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64060; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4061; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v34062; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24063; VI-SDAG-NEXT:    s_endpgm4064;4065; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat7:4066; VI-GISEL:       ; %bb.0:4067; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244068; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04069; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4070; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24071; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34072; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64073; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4074; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44075; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54076; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64077; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4078; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64079; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74080; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64081; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4082; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4083; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4084; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4085; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4086; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4087; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4088; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04089; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14090; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64091; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4092; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v34093; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24094; VI-GISEL-NEXT:    s_endpgm4095;4096; GFX9-LABEL: v_test_global_nnans_med3_f32_pat7:4097; GFX9:       ; %bb.0:4098; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244099; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04100; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4101; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4102; GFX9-NEXT:    s_waitcnt vmcnt(0)4103; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4104; GFX9-NEXT:    s_waitcnt vmcnt(0)4105; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4106; GFX9-NEXT:    s_waitcnt vmcnt(0)4107; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v34108; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4109; GFX9-NEXT:    s_endpgm4110;4111; GFX11-LABEL: v_test_global_nnans_med3_f32_pat7:4112; GFX11:       ; %bb.0:4113; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244114; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04115; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4116; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04117; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4118; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4119; GFX11-NEXT:    s_waitcnt vmcnt(0)4120; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4121; GFX11-NEXT:    s_waitcnt vmcnt(0)4122; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4123; GFX11-NEXT:    s_waitcnt vmcnt(0)4124; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v34125; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4126; GFX11-NEXT:    s_endpgm4127  %tid = call i32 @llvm.amdgcn.workitem.id.x()4128  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4129  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4130  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4131  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4132  %a = load volatile float, ptr addrspace(1) %gep04133  %b = load volatile float, ptr addrspace(1) %gep14134  %c = load volatile float, ptr addrspace(1) %gep24135  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)4136  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)4137  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)4138  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)4139  store float %med3, ptr addrspace(1) %outgep4140  ret void4141}4142 4143define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat8(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4144; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat8:4145; SI-SDAG:       ; %bb.0:4146; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94147; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004148; SI-SDAG-NEXT:    s_mov_b32 s10, 04149; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04150; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04151; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4152; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4153; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4154; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4155; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4156; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4157; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4158; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4159; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4160; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4161; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4162; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4163; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4164; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v44165; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644166; SI-SDAG-NEXT:    s_endpgm4167;4168; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat8:4169; SI-GISEL:       ; %bb.0:4170; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94171; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04172; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04173; SI-GISEL-NEXT:    s_mov_b32 s10, 04174; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004175; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4176; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4177; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4178; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4179; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4180; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4181; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4182; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4183; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4184; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4185; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v44186; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4187; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644188; SI-GISEL-NEXT:    s_endpgm4189;4190; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat8:4191; VI-SDAG:       ; %bb.0:4192; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244193; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04194; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4195; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34196; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64197; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4198; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54199; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64200; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4201; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74202; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64203; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4204; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4205; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4206; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4207; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4208; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4209; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4210; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14211; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64212; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4213; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v34214; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24215; VI-SDAG-NEXT:    s_endpgm4216;4217; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat8:4218; VI-GISEL:       ; %bb.0:4219; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244220; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04221; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4222; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24223; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34224; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64225; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4226; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44227; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54228; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64229; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4230; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64231; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74232; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64233; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4234; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4235; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4236; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4237; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4238; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4239; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4240; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04241; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14242; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64243; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4244; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v34245; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24246; VI-GISEL-NEXT:    s_endpgm4247;4248; GFX9-LABEL: v_test_global_nnans_med3_f32_pat8:4249; GFX9:       ; %bb.0:4250; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244251; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04252; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4253; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4254; GFX9-NEXT:    s_waitcnt vmcnt(0)4255; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4256; GFX9-NEXT:    s_waitcnt vmcnt(0)4257; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4258; GFX9-NEXT:    s_waitcnt vmcnt(0)4259; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v34260; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4261; GFX9-NEXT:    s_endpgm4262;4263; GFX11-LABEL: v_test_global_nnans_med3_f32_pat8:4264; GFX11:       ; %bb.0:4265; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244266; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04267; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4268; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04269; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4270; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4271; GFX11-NEXT:    s_waitcnt vmcnt(0)4272; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4273; GFX11-NEXT:    s_waitcnt vmcnt(0)4274; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4275; GFX11-NEXT:    s_waitcnt vmcnt(0)4276; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v34277; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4278; GFX11-NEXT:    s_endpgm4279  %tid = call i32 @llvm.amdgcn.workitem.id.x()4280  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4281  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4282  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4283  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4284  %a = load volatile float, ptr addrspace(1) %gep04285  %b = load volatile float, ptr addrspace(1) %gep14286  %c = load volatile float, ptr addrspace(1) %gep24287  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)4288  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)4289  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)4290  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)4291  store float %med3, ptr addrspace(1) %outgep4292  ret void4293}4294 4295define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat9(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4296; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat9:4297; SI-SDAG:       ; %bb.0:4298; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94299; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004300; SI-SDAG-NEXT:    s_mov_b32 s10, 04301; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04302; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04303; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4304; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4305; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4306; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4307; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4308; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4309; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4310; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4311; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4312; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4313; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4314; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4315; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4316; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v44317; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644318; SI-SDAG-NEXT:    s_endpgm4319;4320; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat9:4321; SI-GISEL:       ; %bb.0:4322; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94323; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04324; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04325; SI-GISEL-NEXT:    s_mov_b32 s10, 04326; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004327; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4328; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4329; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4330; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4331; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4332; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4333; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4334; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4335; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4336; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4337; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v44338; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4339; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644340; SI-GISEL-NEXT:    s_endpgm4341;4342; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat9:4343; VI-SDAG:       ; %bb.0:4344; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244345; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04346; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4347; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34348; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64349; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4350; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54351; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64352; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4353; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74354; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64355; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4356; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4357; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4358; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4359; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4360; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4361; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4362; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14363; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64364; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4365; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v34366; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24367; VI-SDAG-NEXT:    s_endpgm4368;4369; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat9:4370; VI-GISEL:       ; %bb.0:4371; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244372; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04373; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4374; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24375; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34376; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64377; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4378; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44379; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54380; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64381; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4382; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64383; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74384; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64385; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4386; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4387; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4388; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4389; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4390; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4391; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4392; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04393; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14394; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64395; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4396; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v34397; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24398; VI-GISEL-NEXT:    s_endpgm4399;4400; GFX9-LABEL: v_test_global_nnans_med3_f32_pat9:4401; GFX9:       ; %bb.0:4402; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244403; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04404; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4405; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4406; GFX9-NEXT:    s_waitcnt vmcnt(0)4407; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4408; GFX9-NEXT:    s_waitcnt vmcnt(0)4409; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4410; GFX9-NEXT:    s_waitcnt vmcnt(0)4411; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v34412; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4413; GFX9-NEXT:    s_endpgm4414;4415; GFX11-LABEL: v_test_global_nnans_med3_f32_pat9:4416; GFX11:       ; %bb.0:4417; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244418; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04419; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4420; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04421; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4422; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4423; GFX11-NEXT:    s_waitcnt vmcnt(0)4424; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4425; GFX11-NEXT:    s_waitcnt vmcnt(0)4426; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4427; GFX11-NEXT:    s_waitcnt vmcnt(0)4428; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v34429; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4430; GFX11-NEXT:    s_endpgm4431  %tid = call i32 @llvm.amdgcn.workitem.id.x()4432  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4433  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4434  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4435  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4436  %a = load volatile float, ptr addrspace(1) %gep04437  %b = load volatile float, ptr addrspace(1) %gep14438  %c = load volatile float, ptr addrspace(1) %gep24439  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)4440  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)4441  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)4442  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)4443  store float %med3, ptr addrspace(1) %outgep4444  ret void4445}4446 4447define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat10(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4448; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat10:4449; SI-SDAG:       ; %bb.0:4450; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94451; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004452; SI-SDAG-NEXT:    s_mov_b32 s10, 04453; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04454; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04455; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4456; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4457; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4458; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4459; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4460; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4461; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4462; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4463; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4464; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4465; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4466; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4467; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4468; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v44469; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644470; SI-SDAG-NEXT:    s_endpgm4471;4472; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat10:4473; SI-GISEL:       ; %bb.0:4474; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94475; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04476; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04477; SI-GISEL-NEXT:    s_mov_b32 s10, 04478; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004479; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4480; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4481; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4482; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4483; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4484; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4485; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4486; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4487; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4488; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4489; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v44490; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4491; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644492; SI-GISEL-NEXT:    s_endpgm4493;4494; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat10:4495; VI-SDAG:       ; %bb.0:4496; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244497; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04498; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4499; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34500; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64501; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4502; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54503; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64504; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4505; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74506; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64507; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4508; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4509; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4510; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4511; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4512; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4513; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4514; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14515; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64516; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4517; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v34518; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24519; VI-SDAG-NEXT:    s_endpgm4520;4521; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat10:4522; VI-GISEL:       ; %bb.0:4523; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244524; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04525; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4526; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24527; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34528; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64529; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4530; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44531; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54532; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64533; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4534; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64535; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74536; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64537; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4538; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4539; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4540; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4541; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4542; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4543; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4544; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04545; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14546; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64547; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4548; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v34549; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24550; VI-GISEL-NEXT:    s_endpgm4551;4552; GFX9-LABEL: v_test_global_nnans_med3_f32_pat10:4553; GFX9:       ; %bb.0:4554; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244555; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04556; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4557; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4558; GFX9-NEXT:    s_waitcnt vmcnt(0)4559; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4560; GFX9-NEXT:    s_waitcnt vmcnt(0)4561; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4562; GFX9-NEXT:    s_waitcnt vmcnt(0)4563; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v34564; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4565; GFX9-NEXT:    s_endpgm4566;4567; GFX11-LABEL: v_test_global_nnans_med3_f32_pat10:4568; GFX11:       ; %bb.0:4569; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244570; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04571; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4572; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04573; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4574; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4575; GFX11-NEXT:    s_waitcnt vmcnt(0)4576; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4577; GFX11-NEXT:    s_waitcnt vmcnt(0)4578; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4579; GFX11-NEXT:    s_waitcnt vmcnt(0)4580; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v34581; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4582; GFX11-NEXT:    s_endpgm4583  %tid = call i32 @llvm.amdgcn.workitem.id.x()4584  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4585  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4586  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4587  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4588  %a = load volatile float, ptr addrspace(1) %gep04589  %b = load volatile float, ptr addrspace(1) %gep14590  %c = load volatile float, ptr addrspace(1) %gep24591  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)4592  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)4593  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)4594  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)4595  store float %med3, ptr addrspace(1) %outgep4596  ret void4597}4598 4599define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat11(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4600; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat11:4601; SI-SDAG:       ; %bb.0:4602; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94603; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004604; SI-SDAG-NEXT:    s_mov_b32 s10, 04605; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04606; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04607; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4608; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4609; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4610; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4611; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4612; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4613; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4614; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4615; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4616; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4617; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4618; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4619; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4620; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v44621; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644622; SI-SDAG-NEXT:    s_endpgm4623;4624; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat11:4625; SI-GISEL:       ; %bb.0:4626; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94627; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04628; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04629; SI-GISEL-NEXT:    s_mov_b32 s10, 04630; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004631; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4632; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4633; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4634; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4635; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4636; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4637; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4638; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4639; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4640; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4641; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v44642; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4643; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644644; SI-GISEL-NEXT:    s_endpgm4645;4646; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat11:4647; VI-SDAG:       ; %bb.0:4648; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244649; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04650; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4651; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34652; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64653; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4654; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54655; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64656; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4657; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74658; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64659; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4660; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4661; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4662; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4663; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4664; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4665; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4666; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14667; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64668; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4669; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v34670; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24671; VI-SDAG-NEXT:    s_endpgm4672;4673; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat11:4674; VI-GISEL:       ; %bb.0:4675; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244676; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04677; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4678; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24679; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34680; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64681; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4682; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44683; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54684; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64685; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4686; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64687; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74688; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64689; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4690; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4691; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4692; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4693; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4694; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4695; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4696; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04697; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14698; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64699; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4700; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v34701; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24702; VI-GISEL-NEXT:    s_endpgm4703;4704; GFX9-LABEL: v_test_global_nnans_med3_f32_pat11:4705; GFX9:       ; %bb.0:4706; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244707; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04708; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4709; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4710; GFX9-NEXT:    s_waitcnt vmcnt(0)4711; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4712; GFX9-NEXT:    s_waitcnt vmcnt(0)4713; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4714; GFX9-NEXT:    s_waitcnt vmcnt(0)4715; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v34716; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4717; GFX9-NEXT:    s_endpgm4718;4719; GFX11-LABEL: v_test_global_nnans_med3_f32_pat11:4720; GFX11:       ; %bb.0:4721; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244722; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04723; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4724; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04725; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4726; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4727; GFX11-NEXT:    s_waitcnt vmcnt(0)4728; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4729; GFX11-NEXT:    s_waitcnt vmcnt(0)4730; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4731; GFX11-NEXT:    s_waitcnt vmcnt(0)4732; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v34733; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4734; GFX11-NEXT:    s_endpgm4735  %tid = call i32 @llvm.amdgcn.workitem.id.x()4736  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4737  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4738  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4739  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4740  %a = load volatile float, ptr addrspace(1) %gep04741  %b = load volatile float, ptr addrspace(1) %gep14742  %c = load volatile float, ptr addrspace(1) %gep24743  %tmp0 = call nnan float @llvm.minnum.f32(float %a, float %b)4744  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)4745  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)4746  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)4747  store float %med3, ptr addrspace(1) %outgep4748  ret void4749}4750 4751define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat12(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4752; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat12:4753; SI-SDAG:       ; %bb.0:4754; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94755; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004756; SI-SDAG-NEXT:    s_mov_b32 s10, 04757; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04758; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04759; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4760; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4761; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4762; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4763; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4764; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4765; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4766; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4767; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4768; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4769; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4770; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4771; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4772; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v44773; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644774; SI-SDAG-NEXT:    s_endpgm4775;4776; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat12:4777; SI-GISEL:       ; %bb.0:4778; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94779; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04780; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04781; SI-GISEL-NEXT:    s_mov_b32 s10, 04782; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004783; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4784; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4785; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4786; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4787; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4788; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4789; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4790; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4791; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4792; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4793; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v44794; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4795; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644796; SI-GISEL-NEXT:    s_endpgm4797;4798; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat12:4799; VI-SDAG:       ; %bb.0:4800; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244801; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04802; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4803; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34804; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64805; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4806; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54807; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64808; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4809; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74810; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64811; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4812; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4813; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4814; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4815; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4816; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4817; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4818; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14819; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64820; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4821; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v34822; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24823; VI-SDAG-NEXT:    s_endpgm4824;4825; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat12:4826; VI-GISEL:       ; %bb.0:4827; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244828; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04829; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4830; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24831; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34832; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64833; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4834; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44835; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54836; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64837; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4838; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64839; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74840; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64841; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4842; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4843; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4844; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4845; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4846; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4847; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4848; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s04849; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s14850; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64851; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4852; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v34853; VI-GISEL-NEXT:    flat_store_dword v[0:1], v24854; VI-GISEL-NEXT:    s_endpgm4855;4856; GFX9-LABEL: v_test_global_nnans_med3_f32_pat12:4857; GFX9:       ; %bb.0:4858; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x244859; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v04860; GFX9-NEXT:    s_waitcnt lgkmcnt(0)4861; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc4862; GFX9-NEXT:    s_waitcnt vmcnt(0)4863; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc4864; GFX9-NEXT:    s_waitcnt vmcnt(0)4865; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc4866; GFX9-NEXT:    s_waitcnt vmcnt(0)4867; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v34868; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]4869; GFX9-NEXT:    s_endpgm4870;4871; GFX11-LABEL: v_test_global_nnans_med3_f32_pat12:4872; GFX11:       ; %bb.0:4873; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x244874; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v04875; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)4876; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v04877; GFX11-NEXT:    s_waitcnt lgkmcnt(0)4878; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc4879; GFX11-NEXT:    s_waitcnt vmcnt(0)4880; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc4881; GFX11-NEXT:    s_waitcnt vmcnt(0)4882; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc4883; GFX11-NEXT:    s_waitcnt vmcnt(0)4884; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v34885; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]4886; GFX11-NEXT:    s_endpgm4887  %tid = call i32 @llvm.amdgcn.workitem.id.x()4888  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid4889  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid4890  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid4891  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid4892  %a = load volatile float, ptr addrspace(1) %gep04893  %b = load volatile float, ptr addrspace(1) %gep14894  %c = load volatile float, ptr addrspace(1) %gep24895  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)4896  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)4897  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)4898  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)4899  store float %med3, ptr addrspace(1) %outgep4900  ret void4901}4902 4903define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat13(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {4904; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat13:4905; SI-SDAG:       ; %bb.0:4906; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94907; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0004908; SI-SDAG-NEXT:    s_mov_b32 s10, 04909; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v04910; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 04911; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]4912; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]4913; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4914; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]4915; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]4916; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]4917; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4918; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4919; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc4920; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4921; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc4922; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)4923; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]4924; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v44925; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644926; SI-SDAG-NEXT:    s_endpgm4927;4928; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat13:4929; SI-GISEL:       ; %bb.0:4930; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x94931; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v04932; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 04933; SI-GISEL-NEXT:    s_mov_b32 s10, 04934; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0004935; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4936; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]4937; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc4938; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4939; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]4940; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc4941; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4942; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]4943; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc4944; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)4945; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v44946; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]4947; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr644948; SI-GISEL-NEXT:    s_endpgm4949;4950; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat13:4951; VI-SDAG:       ; %bb.0:4952; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244953; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v04954; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)4955; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s34956; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v64957; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4958; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s54959; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v64960; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4961; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s74962; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v64963; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4964; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc4965; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4966; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc4967; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4968; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc4969; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)4970; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s14971; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v64972; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4973; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v34974; VI-SDAG-NEXT:    flat_store_dword v[0:1], v24975; VI-SDAG-NEXT:    s_endpgm4976;4977; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat13:4978; VI-GISEL:       ; %bb.0:4979; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x244980; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v04981; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)4982; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s24983; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s34984; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v64985; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc4986; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s44987; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s54988; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v64989; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc4990; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s64991; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s74992; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v64993; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc4994; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc4995; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4996; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc4997; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)4998; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc4999; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5000; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05001; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15002; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65003; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5004; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v35005; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25006; VI-GISEL-NEXT:    s_endpgm5007;5008; GFX9-LABEL: v_test_global_nnans_med3_f32_pat13:5009; GFX9:       ; %bb.0:5010; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245011; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05012; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5013; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5014; GFX9-NEXT:    s_waitcnt vmcnt(0)5015; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5016; GFX9-NEXT:    s_waitcnt vmcnt(0)5017; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5018; GFX9-NEXT:    s_waitcnt vmcnt(0)5019; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v35020; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5021; GFX9-NEXT:    s_endpgm5022;5023; GFX11-LABEL: v_test_global_nnans_med3_f32_pat13:5024; GFX11:       ; %bb.0:5025; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245026; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v05027; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)5028; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v05029; GFX11-NEXT:    s_waitcnt lgkmcnt(0)5030; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5031; GFX11-NEXT:    s_waitcnt vmcnt(0)5032; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5033; GFX11-NEXT:    s_waitcnt vmcnt(0)5034; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5035; GFX11-NEXT:    s_waitcnt vmcnt(0)5036; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v35037; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]5038; GFX11-NEXT:    s_endpgm5039  %tid = call i32 @llvm.amdgcn.workitem.id.x()5040  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5041  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5042  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5043  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5044  %a = load volatile float, ptr addrspace(1) %gep05045  %b = load volatile float, ptr addrspace(1) %gep15046  %c = load volatile float, ptr addrspace(1) %gep25047  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)5048  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)5049  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)5050  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)5051  store float %med3, ptr addrspace(1) %outgep5052  ret void5053}5054 5055define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat14(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {5056; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat14:5057; SI-SDAG:       ; %bb.0:5058; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95059; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005060; SI-SDAG-NEXT:    s_mov_b32 s10, 05061; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05062; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05063; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5064; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5065; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5066; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5067; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5068; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5069; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5070; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5071; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5072; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5073; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5074; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5075; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5076; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v45077; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645078; SI-SDAG-NEXT:    s_endpgm5079;5080; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat14:5081; SI-GISEL:       ; %bb.0:5082; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95083; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05084; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05085; SI-GISEL-NEXT:    s_mov_b32 s10, 05086; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005087; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5088; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5089; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5090; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5091; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5092; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5093; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5094; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5095; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5096; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5097; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v45098; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]5099; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645100; SI-GISEL-NEXT:    s_endpgm5101;5102; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat14:5103; VI-SDAG:       ; %bb.0:5104; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245105; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v05106; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5107; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s35108; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v65109; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5110; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s55111; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v65112; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5113; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s75114; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v65115; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5116; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc5117; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5118; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc5119; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5120; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc5121; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5122; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s15123; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v65124; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5125; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v35126; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25127; VI-SDAG-NEXT:    s_endpgm5128;5129; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat14:5130; VI-GISEL:       ; %bb.0:5131; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245132; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v05133; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5134; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s25135; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s35136; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65137; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5138; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s45139; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s55140; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v65141; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5142; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s65143; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s75144; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v65145; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5146; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc5147; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5148; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc5149; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5150; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc5151; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5152; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05153; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15154; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65155; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5156; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v35157; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25158; VI-GISEL-NEXT:    s_endpgm5159;5160; GFX9-LABEL: v_test_global_nnans_med3_f32_pat14:5161; GFX9:       ; %bb.0:5162; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245163; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05164; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5165; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5166; GFX9-NEXT:    s_waitcnt vmcnt(0)5167; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5168; GFX9-NEXT:    s_waitcnt vmcnt(0)5169; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5170; GFX9-NEXT:    s_waitcnt vmcnt(0)5171; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v35172; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5173; GFX9-NEXT:    s_endpgm5174;5175; GFX11-LABEL: v_test_global_nnans_med3_f32_pat14:5176; GFX11:       ; %bb.0:5177; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245178; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v05179; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)5180; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v05181; GFX11-NEXT:    s_waitcnt lgkmcnt(0)5182; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5183; GFX11-NEXT:    s_waitcnt vmcnt(0)5184; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5185; GFX11-NEXT:    s_waitcnt vmcnt(0)5186; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5187; GFX11-NEXT:    s_waitcnt vmcnt(0)5188; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v35189; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]5190; GFX11-NEXT:    s_endpgm5191  %tid = call i32 @llvm.amdgcn.workitem.id.x()5192  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5193  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5194  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5195  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5196  %a = load volatile float, ptr addrspace(1) %gep05197  %b = load volatile float, ptr addrspace(1) %gep15198  %c = load volatile float, ptr addrspace(1) %gep25199  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)5200  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)5201  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)5202  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)5203  store float %med3, ptr addrspace(1) %outgep5204  ret void5205}5206 5207define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat15(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {5208; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat15:5209; SI-SDAG:       ; %bb.0:5210; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95211; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005212; SI-SDAG-NEXT:    s_mov_b32 s10, 05213; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05214; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05215; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5216; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5217; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5218; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5219; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5220; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5221; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5222; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5223; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5224; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5225; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5226; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5227; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5228; SI-SDAG-NEXT:    v_med3_f32 v2, v3, v2, v45229; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645230; SI-SDAG-NEXT:    s_endpgm5231;5232; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat15:5233; SI-GISEL:       ; %bb.0:5234; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95235; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05236; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05237; SI-GISEL-NEXT:    s_mov_b32 s10, 05238; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005239; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5240; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5241; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5242; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5243; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5244; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5245; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5246; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5247; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5248; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5249; SI-GISEL-NEXT:    v_med3_f32 v2, v3, v2, v45250; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]5251; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645252; SI-GISEL-NEXT:    s_endpgm5253;5254; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat15:5255; VI-SDAG:       ; %bb.0:5256; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245257; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v05258; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5259; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s35260; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v65261; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5262; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s55263; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v65264; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5265; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s75266; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v65267; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5268; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc5269; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5270; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc5271; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5272; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc5273; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5274; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s15275; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v65276; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5277; VI-SDAG-NEXT:    v_med3_f32 v2, v2, v7, v35278; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25279; VI-SDAG-NEXT:    s_endpgm5280;5281; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat15:5282; VI-GISEL:       ; %bb.0:5283; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245284; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v05285; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5286; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s25287; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s35288; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65289; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5290; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s45291; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s55292; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v65293; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5294; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s65295; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s75296; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v65297; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5298; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc5299; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5300; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc5301; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5302; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc5303; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5304; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05305; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15306; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65307; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5308; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v7, v35309; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25310; VI-GISEL-NEXT:    s_endpgm5311;5312; GFX9-LABEL: v_test_global_nnans_med3_f32_pat15:5313; GFX9:       ; %bb.0:5314; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245315; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05316; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5317; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5318; GFX9-NEXT:    s_waitcnt vmcnt(0)5319; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5320; GFX9-NEXT:    s_waitcnt vmcnt(0)5321; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5322; GFX9-NEXT:    s_waitcnt vmcnt(0)5323; GFX9-NEXT:    v_med3_f32 v1, v2, v1, v35324; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5325; GFX9-NEXT:    s_endpgm5326;5327; GFX11-LABEL: v_test_global_nnans_med3_f32_pat15:5328; GFX11:       ; %bb.0:5329; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245330; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v05331; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)5332; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v05333; GFX11-NEXT:    s_waitcnt lgkmcnt(0)5334; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5335; GFX11-NEXT:    s_waitcnt vmcnt(0)5336; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5337; GFX11-NEXT:    s_waitcnt vmcnt(0)5338; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5339; GFX11-NEXT:    s_waitcnt vmcnt(0)5340; GFX11-NEXT:    v_med3_f32 v1, v2, v1, v35341; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]5342; GFX11-NEXT:    s_endpgm5343  %tid = call i32 @llvm.amdgcn.workitem.id.x()5344  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5345  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5346  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5347  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5348  %a = load volatile float, ptr addrspace(1) %gep05349  %b = load volatile float, ptr addrspace(1) %gep15350  %c = load volatile float, ptr addrspace(1) %gep25351  %tmp0 = call nnan float @llvm.minnum.f32(float %b, float %a)5352  %tmp1 = call nnan float @llvm.maxnum.f32(float %b, float %a)5353  %tmp2 = call nnan float @llvm.minnum.f32(float %c, float %tmp1)5354  %med3 = call nnan float @llvm.maxnum.f32(float %tmp2, float %tmp0)5355  store float %med3, ptr addrspace(1) %outgep5356  ret void5357}5358 5359; Also handle `min` at the root:5360; min(max(x, y), max(min(x, y), z))5361 5362define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat16(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {5363; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat16:5364; SI-SDAG:       ; %bb.0:5365; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95366; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005367; SI-SDAG-NEXT:    s_mov_b32 s10, 05368; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05369; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05370; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5371; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5372; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5373; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5374; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5375; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5376; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5377; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5378; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5379; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5380; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5381; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5382; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5383; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v45384; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645385; SI-SDAG-NEXT:    s_endpgm5386;5387; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat16:5388; SI-GISEL:       ; %bb.0:5389; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95390; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05391; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05392; SI-GISEL-NEXT:    s_mov_b32 s10, 05393; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005394; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5395; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5396; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5397; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5398; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5399; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5400; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5401; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5402; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5403; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5404; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v45405; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]5406; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645407; SI-GISEL-NEXT:    s_endpgm5408;5409; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat16:5410; VI-SDAG:       ; %bb.0:5411; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245412; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v05413; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5414; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s35415; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v65416; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5417; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s55418; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v65419; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5420; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s75421; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v65422; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5423; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc5424; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5425; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc5426; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5427; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc5428; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5429; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s15430; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v65431; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5432; VI-SDAG-NEXT:    v_med3_f32 v2, v7, v2, v35433; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25434; VI-SDAG-NEXT:    s_endpgm5435;5436; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat16:5437; VI-GISEL:       ; %bb.0:5438; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245439; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v05440; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5441; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s25442; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s35443; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65444; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5445; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s45446; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s55447; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v65448; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5449; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s65450; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s75451; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v65452; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5453; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc5454; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5455; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc5456; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5457; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc5458; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5459; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05460; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15461; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65462; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5463; VI-GISEL-NEXT:    v_med3_f32 v2, v7, v2, v35464; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25465; VI-GISEL-NEXT:    s_endpgm5466;5467; GFX9-LABEL: v_test_global_nnans_med3_f32_pat16:5468; GFX9:       ; %bb.0:5469; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245470; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05471; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5472; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5473; GFX9-NEXT:    s_waitcnt vmcnt(0)5474; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5475; GFX9-NEXT:    s_waitcnt vmcnt(0)5476; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5477; GFX9-NEXT:    s_waitcnt vmcnt(0)5478; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v35479; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5480; GFX9-NEXT:    s_endpgm5481;5482; GFX11-LABEL: v_test_global_nnans_med3_f32_pat16:5483; GFX11:       ; %bb.0:5484; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245485; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v05486; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)5487; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v05488; GFX11-NEXT:    s_waitcnt lgkmcnt(0)5489; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5490; GFX11-NEXT:    s_waitcnt vmcnt(0)5491; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5492; GFX11-NEXT:    s_waitcnt vmcnt(0)5493; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5494; GFX11-NEXT:    s_waitcnt vmcnt(0)5495; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v35496; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]5497; GFX11-NEXT:    s_endpgm5498  %tid = call i32 @llvm.amdgcn.workitem.id.x()5499  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5500  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5501  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5502  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5503  %a = load volatile float, ptr addrspace(1) %gep05504  %b = load volatile float, ptr addrspace(1) %gep15505  %c = load volatile float, ptr addrspace(1) %gep25506  %tmp0 = call nnan float @llvm.maxnum.f32(float %a, float %b)5507  %tmp1 = call nnan float @llvm.minnum.f32(float %a, float %b)5508  %tmp2 = call nnan float @llvm.maxnum.f32(float %tmp1, float %c)5509  %med3 = call nnan float @llvm.minnum.f32(float %tmp0, float %tmp2)5510  store float %med3, ptr addrspace(1) %outgep5511  ret void5512}5513 5514; ---------------------------------------------------------------------5515; Negative patterns5516; ---------------------------------------------------------------------5517 5518define amdgpu_kernel void @v_test_safe_med3_f32_pat0_multi_use0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {5519; SI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5520; SI-SDAG:       ; %bb.0:5521; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95522; SI-SDAG-NEXT:    s_mov_b32 s10, 05523; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005524; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05525; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05526; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5527; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5528; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5529; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5530; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5531; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5532; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5533; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5534; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5535; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5536; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5537; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5538; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5539; SI-SDAG-NEXT:    s_mov_b32 s10, -15540; SI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v25541; SI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v35542; SI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v45543; SI-SDAG-NEXT:    v_min_f32_e32 v5, v2, v35544; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v35545; SI-SDAG-NEXT:    buffer_store_dword v5, off, s[8:11], 05546; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5547; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v45548; SI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v25549; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645550; SI-SDAG-NEXT:    s_endpgm5551;5552; SI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5553; SI-GISEL:       ; %bb.0:5554; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95555; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05556; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05557; SI-GISEL-NEXT:    s_mov_b32 s10, 05558; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005559; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5560; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5561; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5562; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5563; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5564; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5565; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5566; SI-GISEL-NEXT:    s_mov_b32 s2, -15567; SI-GISEL-NEXT:    s_mov_b32 s3, s115568; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5569; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5570; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5571; SI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v25572; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v35573; SI-GISEL-NEXT:    v_min_f32_e32 v5, v2, v35574; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v35575; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v45576; SI-GISEL-NEXT:    buffer_store_dword v5, off, s[0:3], 05577; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5578; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v35579; SI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v25580; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]5581; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645582; SI-GISEL-NEXT:    s_endpgm5583;5584; VI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5585; VI-SDAG:       ; %bb.0:5586; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245587; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v05588; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5589; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s35590; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v65591; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5592; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s55593; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v65594; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5595; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s75596; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v65597; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5598; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc5599; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5600; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc5601; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5602; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc5603; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5604; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s15605; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v65606; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5607; VI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v75608; VI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v25609; VI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v35610; VI-SDAG-NEXT:    v_min_f32_e32 v5, v4, v25611; VI-SDAG-NEXT:    v_max_f32_e32 v2, v4, v25612; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v35613; VI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v25614; VI-SDAG-NEXT:    flat_store_dword v[0:1], v55615; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5616; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25617; VI-SDAG-NEXT:    s_endpgm5618;5619; VI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5620; VI-GISEL:       ; %bb.0:5621; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245622; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v05623; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5624; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s25625; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s35626; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65627; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5628; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s45629; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s55630; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v65631; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5632; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s65633; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s75634; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v65635; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5636; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc5637; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5638; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc5639; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5640; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc5641; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5642; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05643; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15644; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65645; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5646; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 1.0, v75647; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v25648; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v35649; VI-GISEL-NEXT:    v_min_f32_e32 v5, v4, v25650; VI-GISEL-NEXT:    v_max_f32_e32 v2, v4, v25651; VI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v35652; VI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v25653; VI-GISEL-NEXT:    flat_store_dword v[0:1], v55654; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5655; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25656; VI-GISEL-NEXT:    s_endpgm5657;5658; GFX9-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5659; GFX9:       ; %bb.0:5660; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245661; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05662; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5663; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5664; GFX9-NEXT:    s_waitcnt vmcnt(0)5665; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5666; GFX9-NEXT:    s_waitcnt vmcnt(0)5667; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5668; GFX9-NEXT:    s_waitcnt vmcnt(0)5669; GFX9-NEXT:    v_max_f32_e32 v1, v1, v15670; GFX9-NEXT:    v_max_f32_e32 v2, v2, v25671; GFX9-NEXT:    v_max_f32_e32 v3, v3, v35672; GFX9-NEXT:    v_min_f32_e32 v4, v1, v25673; GFX9-NEXT:    v_max_f32_e32 v1, v1, v25674; GFX9-NEXT:    global_store_dword v[0:1], v4, off5675; GFX9-NEXT:    s_waitcnt vmcnt(0)5676; GFX9-NEXT:    v_min_f32_e32 v1, v1, v35677; GFX9-NEXT:    v_max_f32_e32 v1, v4, v15678; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5679; GFX9-NEXT:    s_endpgm5680;5681; GFX11-LABEL: v_test_safe_med3_f32_pat0_multi_use0:5682; GFX11:       ; %bb.0:5683; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245684; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v05685; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)5686; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v05687; GFX11-NEXT:    s_waitcnt lgkmcnt(0)5688; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5689; GFX11-NEXT:    s_waitcnt vmcnt(0)5690; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5691; GFX11-NEXT:    s_waitcnt vmcnt(0)5692; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5693; GFX11-NEXT:    s_waitcnt vmcnt(0)5694; GFX11-NEXT:    v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v2, v2, v25695; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)5696; GFX11-NEXT:    v_min_f32_e32 v4, v1, v25697; GFX11-NEXT:    v_dual_max_f32 v1, v1, v2 :: v_dual_max_f32 v2, v3, v35698; GFX11-NEXT:    v_minmax_f32 v1, v1, v2, v45699; GFX11-NEXT:    global_store_b32 v[0:1], v4, off dlc5700; GFX11-NEXT:    s_waitcnt_vscnt null, 0x05701; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]5702; GFX11-NEXT:    s_endpgm5703  %tid = call i32 @llvm.amdgcn.workitem.id.x()5704  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5705  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5706  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5707  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5708  %a = load volatile float, ptr addrspace(1) %gep05709  %b = load volatile float, ptr addrspace(1) %gep15710  %c = load volatile float, ptr addrspace(1) %gep25711  %tmp0 = call float @llvm.minnum.f32(float %a, float %b)5712  store volatile float %tmp0, ptr addrspace(1) poison5713  %tmp1 = call float @llvm.maxnum.f32(float %a, float %b)5714  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c)5715  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)5716  store float %med3, ptr addrspace(1) %outgep5717  ret void5718}5719 5720define amdgpu_kernel void @v_test_safe_med3_f32_pat0_multi_use1(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {5721; SI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5722; SI-SDAG:       ; %bb.0:5723; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95724; SI-SDAG-NEXT:    s_mov_b32 s10, 05725; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005726; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05727; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05728; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5729; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5730; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5731; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5732; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5733; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5734; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5735; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5736; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5737; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5738; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5739; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5740; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5741; SI-SDAG-NEXT:    s_mov_b32 s10, -15742; SI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v25743; SI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v35744; SI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v45745; SI-SDAG-NEXT:    v_min_f32_e32 v5, v2, v35746; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v35747; SI-SDAG-NEXT:    buffer_store_dword v2, off, s[8:11], 05748; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0)5749; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v45750; SI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v25751; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645752; SI-SDAG-NEXT:    s_endpgm5753;5754; SI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5755; SI-GISEL:       ; %bb.0:5756; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95757; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05758; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05759; SI-GISEL-NEXT:    s_mov_b32 s10, 05760; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005761; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5762; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5763; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5764; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5765; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5766; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5767; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5768; SI-GISEL-NEXT:    s_mov_b32 s2, -15769; SI-GISEL-NEXT:    s_mov_b32 s3, s115770; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5771; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5772; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5773; SI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v25774; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v35775; SI-GISEL-NEXT:    v_min_f32_e32 v5, v2, v35776; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v35777; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v45778; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[0:3], 05779; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0)5780; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v35781; SI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v25782; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]5783; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645784; SI-GISEL-NEXT:    s_endpgm5785;5786; VI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5787; VI-SDAG:       ; %bb.0:5788; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245789; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v05790; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5791; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s35792; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v65793; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5794; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s55795; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v65796; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5797; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s75798; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v65799; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5800; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc5801; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5802; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc5803; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5804; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc5805; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5806; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s15807; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v65808; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5809; VI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v75810; VI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v25811; VI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v35812; VI-SDAG-NEXT:    v_min_f32_e32 v5, v4, v25813; VI-SDAG-NEXT:    v_max_f32_e32 v2, v4, v25814; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25815; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)5816; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v35817; VI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v25818; VI-SDAG-NEXT:    flat_store_dword v[0:1], v25819; VI-SDAG-NEXT:    s_endpgm5820;5821; VI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5822; VI-GISEL:       ; %bb.0:5823; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x245824; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v05825; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5826; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s25827; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s35828; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65829; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5830; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s45831; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s55832; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v65833; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc5834; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s65835; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s75836; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v65837; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc5838; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc5839; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5840; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc5841; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5842; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc5843; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5844; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s05845; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s15846; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v65847; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc5848; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 1.0, v75849; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v25850; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v35851; VI-GISEL-NEXT:    v_min_f32_e32 v5, v4, v25852; VI-GISEL-NEXT:    v_max_f32_e32 v2, v4, v25853; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25854; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)5855; VI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v35856; VI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v25857; VI-GISEL-NEXT:    flat_store_dword v[0:1], v25858; VI-GISEL-NEXT:    s_endpgm5859;5860; GFX9-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5861; GFX9:       ; %bb.0:5862; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x245863; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v05864; GFX9-NEXT:    s_waitcnt lgkmcnt(0)5865; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc5866; GFX9-NEXT:    s_waitcnt vmcnt(0)5867; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc5868; GFX9-NEXT:    s_waitcnt vmcnt(0)5869; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc5870; GFX9-NEXT:    s_waitcnt vmcnt(0)5871; GFX9-NEXT:    v_max_f32_e32 v1, v1, v15872; GFX9-NEXT:    v_max_f32_e32 v2, v2, v25873; GFX9-NEXT:    v_max_f32_e32 v3, v3, v35874; GFX9-NEXT:    v_min_f32_e32 v4, v1, v25875; GFX9-NEXT:    v_max_f32_e32 v1, v1, v25876; GFX9-NEXT:    global_store_dword v[0:1], v1, off5877; GFX9-NEXT:    s_waitcnt vmcnt(0)5878; GFX9-NEXT:    v_min_f32_e32 v1, v1, v35879; GFX9-NEXT:    v_max_f32_e32 v1, v4, v15880; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]5881; GFX9-NEXT:    s_endpgm5882;5883; GFX11-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5884; GFX11-SDAG:       ; %bb.0:5885; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245886; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v05887; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)5888; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05889; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5890; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5891; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)5892; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5893; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)5894; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5895; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)5896; GFX11-SDAG-NEXT:    v_max_f32_e32 v1, v1, v15897; GFX11-SDAG-NEXT:    v_dual_max_f32 v3, v3, v3 :: v_dual_max_f32 v2, v2, v25898; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)5899; GFX11-SDAG-NEXT:    v_max_f32_e32 v4, v1, v25900; GFX11-SDAG-NEXT:    v_min_f32_e32 v3, v4, v35901; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)5902; GFX11-SDAG-NEXT:    v_minmax_f32 v1, v1, v2, v35903; GFX11-SDAG-NEXT:    global_store_b32 v[0:1], v4, off dlc5904; GFX11-SDAG-NEXT:    s_waitcnt_vscnt null, 0x05905; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]5906; GFX11-SDAG-NEXT:    s_endpgm5907;5908; GFX11-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use1:5909; GFX11-GISEL:       ; %bb.0:5910; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x245911; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v05912; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)5913; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05914; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5915; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc5916; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)5917; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc5918; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)5919; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc5920; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)5921; GFX11-GISEL-NEXT:    v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v2, v2, v25922; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)5923; GFX11-GISEL-NEXT:    v_min_f32_e32 v4, v1, v25924; GFX11-GISEL-NEXT:    v_dual_max_f32 v1, v1, v2 :: v_dual_max_f32 v2, v3, v35925; GFX11-GISEL-NEXT:    v_minmax_f32 v2, v1, v2, v45926; GFX11-GISEL-NEXT:    global_store_b32 v[0:1], v1, off dlc5927; GFX11-GISEL-NEXT:    s_waitcnt_vscnt null, 0x05928; GFX11-GISEL-NEXT:    global_store_b32 v0, v2, s[0:1]5929; GFX11-GISEL-NEXT:    s_endpgm5930  %tid = call i32 @llvm.amdgcn.workitem.id.x()5931  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid5932  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid5933  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid5934  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid5935  %a = load volatile float, ptr addrspace(1) %gep05936  %b = load volatile float, ptr addrspace(1) %gep15937  %c = load volatile float, ptr addrspace(1) %gep25938  %tmp0 = call float @llvm.minnum.f32(float %a, float %b)5939  %tmp1 = call float @llvm.maxnum.f32(float %a, float %b)5940  store volatile float %tmp1, ptr addrspace(1) poison5941  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c)5942  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)5943  store float %med3, ptr addrspace(1) %outgep5944  ret void5945}5946 5947define amdgpu_kernel void @v_test_safe_med3_f32_pat0_multi_use2(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {5948; SI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use2:5949; SI-SDAG:       ; %bb.0:5950; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95951; SI-SDAG-NEXT:    s_mov_b32 s10, 05952; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0005953; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v05954; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 05955; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]5956; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]5957; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)5958; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]5959; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]5960; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]5961; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]5962; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5963; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5964; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc5965; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5966; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc5967; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)5968; SI-SDAG-NEXT:    s_mov_b32 s10, -15969; SI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v25970; SI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v35971; SI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v45972; SI-SDAG-NEXT:    v_min_f32_e32 v5, v2, v35973; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v35974; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v45975; SI-SDAG-NEXT:    buffer_store_dword v2, off, s[8:11], 05976; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0)5977; SI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v25978; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr645979; SI-SDAG-NEXT:    s_endpgm5980;5981; SI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use2:5982; SI-GISEL:       ; %bb.0:5983; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x95984; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v05985; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 05986; SI-GISEL-NEXT:    s_mov_b32 s10, 05987; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0005988; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)5989; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]5990; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc5991; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5992; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]5993; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc5994; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)5995; SI-GISEL-NEXT:    s_mov_b32 s2, -15996; SI-GISEL-NEXT:    s_mov_b32 s3, s115997; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]5998; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc5999; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6000; SI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v26001; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v36002; SI-GISEL-NEXT:    v_min_f32_e32 v5, v2, v36003; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v36004; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v46005; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v36006; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[0:3], 06007; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0)6008; SI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v26009; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6010; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646011; SI-GISEL-NEXT:    s_endpgm6012;6013; VI-SDAG-LABEL: v_test_safe_med3_f32_pat0_multi_use2:6014; VI-SDAG:       ; %bb.0:6015; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246016; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v06017; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6018; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36019; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v66020; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6021; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56022; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v66023; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6024; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76025; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v66026; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6027; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc6028; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6029; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6030; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6031; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc6032; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6033; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16034; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v66035; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6036; VI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v76037; VI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v26038; VI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v36039; VI-SDAG-NEXT:    v_min_f32_e32 v5, v4, v26040; VI-SDAG-NEXT:    v_max_f32_e32 v2, v4, v26041; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v36042; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26043; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6044; VI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v26045; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26046; VI-SDAG-NEXT:    s_endpgm6047;6048; VI-GISEL-LABEL: v_test_safe_med3_f32_pat0_multi_use2:6049; VI-GISEL:       ; %bb.0:6050; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246051; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06052; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6053; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26054; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36055; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66056; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6057; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46058; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56059; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66060; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6061; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66062; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76063; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v66064; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6065; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6066; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6067; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6068; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6069; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc6070; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6071; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06072; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16073; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66074; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6075; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 1.0, v76076; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v26077; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v36078; VI-GISEL-NEXT:    v_min_f32_e32 v5, v4, v26079; VI-GISEL-NEXT:    v_max_f32_e32 v2, v4, v26080; VI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v36081; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26082; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6083; VI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v26084; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26085; VI-GISEL-NEXT:    s_endpgm6086;6087; GFX9-LABEL: v_test_safe_med3_f32_pat0_multi_use2:6088; GFX9:       ; %bb.0:6089; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246090; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v06091; GFX9-NEXT:    s_waitcnt lgkmcnt(0)6092; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc6093; GFX9-NEXT:    s_waitcnt vmcnt(0)6094; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc6095; GFX9-NEXT:    s_waitcnt vmcnt(0)6096; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc6097; GFX9-NEXT:    s_waitcnt vmcnt(0)6098; GFX9-NEXT:    v_max_f32_e32 v1, v1, v16099; GFX9-NEXT:    v_max_f32_e32 v2, v2, v26100; GFX9-NEXT:    v_max_f32_e32 v3, v3, v36101; GFX9-NEXT:    v_min_f32_e32 v4, v1, v26102; GFX9-NEXT:    v_max_f32_e32 v1, v1, v26103; GFX9-NEXT:    v_min_f32_e32 v1, v1, v36104; GFX9-NEXT:    global_store_dword v[0:1], v1, off6105; GFX9-NEXT:    s_waitcnt vmcnt(0)6106; GFX9-NEXT:    v_max_f32_e32 v1, v4, v16107; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]6108; GFX9-NEXT:    s_endpgm6109;6110; GFX11-LABEL: v_test_safe_med3_f32_pat0_multi_use2:6111; GFX11:       ; %bb.0:6112; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246113; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v06114; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6115; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v06116; GFX11-NEXT:    s_waitcnt lgkmcnt(0)6117; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6118; GFX11-NEXT:    s_waitcnt vmcnt(0)6119; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6120; GFX11-NEXT:    s_waitcnt vmcnt(0)6121; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6122; GFX11-NEXT:    s_waitcnt vmcnt(0)6123; GFX11-NEXT:    v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v2, v2, v26124; GFX11-NEXT:    v_max_f32_e32 v3, v3, v36125; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)6126; GFX11-NEXT:    v_maxmin_f32 v3, v1, v2, v36127; GFX11-NEXT:    v_minmax_f32 v1, v1, v2, v36128; GFX11-NEXT:    global_store_b32 v[0:1], v3, off dlc6129; GFX11-NEXT:    s_waitcnt_vscnt null, 0x06130; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]6131; GFX11-NEXT:    s_endpgm6132  %tid = call i32 @llvm.amdgcn.workitem.id.x()6133  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid6134  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid6135  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid6136  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid6137  %a = load volatile float, ptr addrspace(1) %gep06138  %b = load volatile float, ptr addrspace(1) %gep16139  %c = load volatile float, ptr addrspace(1) %gep26140  %tmp0 = call float @llvm.minnum.f32(float %a, float %b)6141  %tmp1 = call float @llvm.maxnum.f32(float %a, float %b)6142  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c)6143  store volatile float %tmp2, ptr addrspace(1) poison6144  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)6145  store float %med3, ptr addrspace(1) %outgep6146  ret void6147}6148 6149define amdgpu_kernel void @v_test_safe_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {6150; SI-SDAG-LABEL: v_test_safe_med3_f32_pat0:6151; SI-SDAG:       ; %bb.0:6152; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96153; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0006154; SI-SDAG-NEXT:    s_mov_b32 s10, 06155; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06156; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 06157; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]6158; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6159; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]6160; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]6161; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6162; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6163; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc6164; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6165; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[6:7]6166; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]6167; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[12:15], 0 addr64 glc6168; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6169; SI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v26170; SI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v36171; SI-SDAG-NEXT:    v_min_f32_e32 v5, v2, v36172; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v36173; SI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v46174; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v36175; SI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v26176; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646177; SI-SDAG-NEXT:    s_endpgm6178;6179; SI-GISEL-LABEL: v_test_safe_med3_f32_pat0:6180; SI-GISEL:       ; %bb.0:6181; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96182; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06183; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 06184; SI-GISEL-NEXT:    s_mov_b32 s10, 06185; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0006186; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6187; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]6188; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6189; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6190; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]6191; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc6192; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6193; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]6194; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc6195; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6196; SI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v26197; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v36198; SI-GISEL-NEXT:    v_min_f32_e32 v5, v2, v36199; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v36200; SI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v46201; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v36202; SI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v26203; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6204; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646205; SI-GISEL-NEXT:    s_endpgm6206;6207; VI-SDAG-LABEL: v_test_safe_med3_f32_pat0:6208; VI-SDAG:       ; %bb.0:6209; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246210; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v4, 2, v06211; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6212; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36213; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v46214; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6215; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56216; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v46217; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6218; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76219; VI-SDAG-NEXT:    flat_load_dword v6, v[0:1] glc6220; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6221; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6222; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6223; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s6, v46224; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v5, vcc6225; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1] glc6226; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6227; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v46228; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16229; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6230; VI-SDAG-NEXT:    v_mul_f32_e32 v4, 1.0, v66231; VI-SDAG-NEXT:    v_mul_f32_e32 v2, 1.0, v26232; VI-SDAG-NEXT:    v_min_f32_e32 v5, v4, v26233; VI-SDAG-NEXT:    v_max_f32_e32 v2, v4, v26234; VI-SDAG-NEXT:    v_mul_f32_e32 v3, 1.0, v36235; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v36236; VI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v26237; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26238; VI-SDAG-NEXT:    s_endpgm6239;6240; VI-GISEL-LABEL: v_test_safe_med3_f32_pat0:6241; VI-GISEL:       ; %bb.0:6242; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246243; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06244; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6245; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26246; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36247; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66248; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6249; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46250; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56251; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66252; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6253; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66254; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76255; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6256; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6257; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6258; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6259; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v4, v66260; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v5, vcc6261; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1] glc6262; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6263; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06264; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16265; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66266; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6267; VI-GISEL-NEXT:    v_mul_f32_e32 v4, 1.0, v76268; VI-GISEL-NEXT:    v_mul_f32_e32 v2, 1.0, v26269; VI-GISEL-NEXT:    v_min_f32_e32 v5, v4, v26270; VI-GISEL-NEXT:    v_max_f32_e32 v2, v4, v26271; VI-GISEL-NEXT:    v_mul_f32_e32 v3, 1.0, v36272; VI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v36273; VI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v26274; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26275; VI-GISEL-NEXT:    s_endpgm6276;6277; GFX9-LABEL: v_test_safe_med3_f32_pat0:6278; GFX9:       ; %bb.0:6279; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246280; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v06281; GFX9-NEXT:    s_waitcnt lgkmcnt(0)6282; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc6283; GFX9-NEXT:    s_waitcnt vmcnt(0)6284; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc6285; GFX9-NEXT:    s_waitcnt vmcnt(0)6286; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc6287; GFX9-NEXT:    s_waitcnt vmcnt(0)6288; GFX9-NEXT:    v_max_f32_e32 v1, v1, v16289; GFX9-NEXT:    v_max_f32_e32 v2, v2, v26290; GFX9-NEXT:    v_min_f32_e32 v4, v1, v26291; GFX9-NEXT:    v_max_f32_e32 v1, v1, v26292; GFX9-NEXT:    v_max_f32_e32 v2, v3, v36293; GFX9-NEXT:    v_min_f32_e32 v1, v1, v26294; GFX9-NEXT:    v_max_f32_e32 v1, v4, v16295; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]6296; GFX9-NEXT:    s_endpgm6297;6298; GFX11-SDAG-LABEL: v_test_safe_med3_f32_pat0:6299; GFX11-SDAG:       ; %bb.0:6300; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246301; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v06302; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)6303; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06304; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6305; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6306; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)6307; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6308; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)6309; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6310; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)6311; GFX11-SDAG-NEXT:    v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v2, v2, v26312; GFX11-SDAG-NEXT:    v_max_f32_e32 v3, v3, v36313; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)6314; GFX11-SDAG-NEXT:    v_maxmin_f32 v3, v1, v2, v36315; GFX11-SDAG-NEXT:    v_minmax_f32 v1, v1, v2, v36316; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]6317; GFX11-SDAG-NEXT:    s_endpgm6318;6319; GFX11-GISEL-LABEL: v_test_safe_med3_f32_pat0:6320; GFX11-GISEL:       ; %bb.0:6321; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246322; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v06323; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)6324; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06325; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6326; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6327; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)6328; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6329; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)6330; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6331; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)6332; GFX11-GISEL-NEXT:    v_dual_max_f32 v1, v1, v1 :: v_dual_max_f32 v2, v2, v26333; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)6334; GFX11-GISEL-NEXT:    v_min_f32_e32 v4, v1, v26335; GFX11-GISEL-NEXT:    v_dual_max_f32 v1, v1, v2 :: v_dual_max_f32 v2, v3, v36336; GFX11-GISEL-NEXT:    v_minmax_f32 v1, v1, v2, v46337; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]6338; GFX11-GISEL-NEXT:    s_endpgm6339  %tid = call i32 @llvm.amdgcn.workitem.id.x()6340  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid6341  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid6342  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid6343  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid6344  %a = load volatile float, ptr addrspace(1) %gep06345  %b = load volatile float, ptr addrspace(1) %gep16346  %c = load volatile float, ptr addrspace(1) %gep26347  %tmp0 = call float @llvm.minnum.f32(float %a, float %b)6348  %tmp1 = call float @llvm.maxnum.f32(float %a, float %b)6349  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c)6350  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)6351  store float %med3, ptr addrspace(1) %outgep6352  ret void6353}6354 6355define amdgpu_kernel void @v_nnan_inputs_missing0_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {6356; SI-SDAG-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6357; SI-SDAG:       ; %bb.0:6358; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96359; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0006360; SI-SDAG-NEXT:    s_mov_b32 s10, 06361; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06362; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 06363; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]6364; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]6365; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6366; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]6367; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]6368; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]6369; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6370; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6371; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc6372; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6373; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc6374; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6375; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]6376; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v26377; SI-SDAG-NEXT:    v_add_f32_e32 v3, 2.0, v36378; SI-SDAG-NEXT:    v_add_f32_e32 v4, 4.0, v46379; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v46380; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646381; SI-SDAG-NEXT:    s_endpgm6382;6383; SI-GISEL-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6384; SI-GISEL:       ; %bb.0:6385; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96386; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06387; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 06388; SI-GISEL-NEXT:    s_mov_b32 s10, 06389; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0006390; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6391; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]6392; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6393; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6394; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]6395; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc6396; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6397; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]6398; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc6399; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6400; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v26401; SI-GISEL-NEXT:    v_add_f32_e32 v3, 2.0, v36402; SI-GISEL-NEXT:    v_add_f32_e32 v4, 4.0, v46403; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v46404; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6405; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646406; SI-GISEL-NEXT:    s_endpgm6407;6408; VI-SDAG-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6409; VI-SDAG:       ; %bb.0:6410; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246411; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v06412; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6413; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36414; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v66415; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6416; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56417; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v66418; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6419; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76420; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v66421; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6422; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc6423; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6424; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6425; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6426; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc6427; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6428; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16429; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v66430; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6431; VI-SDAG-NEXT:    v_add_f32_e32 v4, 1.0, v76432; VI-SDAG-NEXT:    v_add_f32_e32 v2, 2.0, v26433; VI-SDAG-NEXT:    v_add_f32_e32 v3, 4.0, v36434; VI-SDAG-NEXT:    v_med3_f32 v2, v4, v2, v36435; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26436; VI-SDAG-NEXT:    s_endpgm6437;6438; VI-GISEL-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6439; VI-GISEL:       ; %bb.0:6440; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246441; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06442; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6443; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26444; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36445; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66446; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6447; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46448; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56449; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66450; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6451; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66452; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76453; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v66454; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6455; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6456; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6457; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6458; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6459; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc6460; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6461; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06462; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16463; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66464; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6465; VI-GISEL-NEXT:    v_add_f32_e32 v4, 1.0, v76466; VI-GISEL-NEXT:    v_add_f32_e32 v2, 2.0, v26467; VI-GISEL-NEXT:    v_add_f32_e32 v3, 4.0, v36468; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v36469; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26470; VI-GISEL-NEXT:    s_endpgm6471;6472; GFX9-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6473; GFX9:       ; %bb.0:6474; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246475; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v06476; GFX9-NEXT:    s_waitcnt lgkmcnt(0)6477; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc6478; GFX9-NEXT:    s_waitcnt vmcnt(0)6479; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc6480; GFX9-NEXT:    s_waitcnt vmcnt(0)6481; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc6482; GFX9-NEXT:    s_waitcnt vmcnt(0)6483; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v16484; GFX9-NEXT:    v_add_f32_e32 v2, 2.0, v26485; GFX9-NEXT:    v_add_f32_e32 v3, 4.0, v36486; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v36487; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]6488; GFX9-NEXT:    s_endpgm6489;6490; GFX11-LABEL: v_nnan_inputs_missing0_med3_f32_pat0:6491; GFX11:       ; %bb.0:6492; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246493; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v06494; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6495; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v06496; GFX11-NEXT:    s_waitcnt lgkmcnt(0)6497; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6498; GFX11-NEXT:    s_waitcnt vmcnt(0)6499; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6500; GFX11-NEXT:    s_waitcnt vmcnt(0)6501; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6502; GFX11-NEXT:    s_waitcnt vmcnt(0)6503; GFX11-NEXT:    v_dual_add_f32 v1, 1.0, v1 :: v_dual_add_f32 v2, 2.0, v26504; GFX11-NEXT:    v_add_f32_e32 v3, 4.0, v36505; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6506; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v36507; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]6508; GFX11-NEXT:    s_endpgm6509  %tid = call i32 @llvm.amdgcn.workitem.id.x()6510  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid6511  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid6512  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid6513  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid6514  %a = load volatile float, ptr addrspace(1) %gep06515  %b = load volatile float, ptr addrspace(1) %gep16516  %c = load volatile float, ptr addrspace(1) %gep26517 6518  %a.nnan = fadd float %a, 1.06519  %b.nnan = fadd nnan float %b, 2.06520  %c.nnan = fadd nnan float %c, 4.06521 6522  %tmp0 = call float @llvm.minnum.f32(float %a.nnan, float %b.nnan)6523  %tmp1 = call float @llvm.maxnum.f32(float %a.nnan, float %b.nnan)6524  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c.nnan)6525  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)6526  store float %med3, ptr addrspace(1) %outgep6527  ret void6528}6529 6530define amdgpu_kernel void @v_nnan_inputs_missing1_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {6531; SI-SDAG-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6532; SI-SDAG:       ; %bb.0:6533; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96534; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0006535; SI-SDAG-NEXT:    s_mov_b32 s10, 06536; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06537; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 06538; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]6539; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]6540; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6541; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]6542; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]6543; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]6544; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6545; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6546; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc6547; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6548; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc6549; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6550; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]6551; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v26552; SI-SDAG-NEXT:    v_add_f32_e32 v3, 2.0, v36553; SI-SDAG-NEXT:    v_add_f32_e32 v4, 4.0, v46554; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v46555; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646556; SI-SDAG-NEXT:    s_endpgm6557;6558; SI-GISEL-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6559; SI-GISEL:       ; %bb.0:6560; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96561; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06562; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 06563; SI-GISEL-NEXT:    s_mov_b32 s10, 06564; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0006565; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6566; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]6567; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6568; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6569; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]6570; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc6571; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6572; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]6573; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc6574; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6575; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v26576; SI-GISEL-NEXT:    v_add_f32_e32 v3, 2.0, v36577; SI-GISEL-NEXT:    v_add_f32_e32 v4, 4.0, v46578; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v46579; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6580; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646581; SI-GISEL-NEXT:    s_endpgm6582;6583; VI-SDAG-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6584; VI-SDAG:       ; %bb.0:6585; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246586; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v06587; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6588; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36589; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v66590; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6591; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56592; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v66593; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6594; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76595; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v66596; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6597; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc6598; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6599; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6600; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6601; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc6602; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6603; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16604; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v66605; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6606; VI-SDAG-NEXT:    v_add_f32_e32 v4, 1.0, v76607; VI-SDAG-NEXT:    v_add_f32_e32 v2, 2.0, v26608; VI-SDAG-NEXT:    v_add_f32_e32 v3, 4.0, v36609; VI-SDAG-NEXT:    v_med3_f32 v2, v4, v2, v36610; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26611; VI-SDAG-NEXT:    s_endpgm6612;6613; VI-GISEL-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6614; VI-GISEL:       ; %bb.0:6615; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246616; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06617; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6618; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26619; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36620; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66621; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6622; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46623; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56624; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66625; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6626; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66627; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76628; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v66629; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6630; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6631; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6632; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6633; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6634; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc6635; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6636; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06637; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16638; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66639; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6640; VI-GISEL-NEXT:    v_add_f32_e32 v4, 1.0, v76641; VI-GISEL-NEXT:    v_add_f32_e32 v2, 2.0, v26642; VI-GISEL-NEXT:    v_add_f32_e32 v3, 4.0, v36643; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v36644; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26645; VI-GISEL-NEXT:    s_endpgm6646;6647; GFX9-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6648; GFX9:       ; %bb.0:6649; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246650; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v06651; GFX9-NEXT:    s_waitcnt lgkmcnt(0)6652; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc6653; GFX9-NEXT:    s_waitcnt vmcnt(0)6654; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc6655; GFX9-NEXT:    s_waitcnt vmcnt(0)6656; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc6657; GFX9-NEXT:    s_waitcnt vmcnt(0)6658; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v16659; GFX9-NEXT:    v_add_f32_e32 v2, 2.0, v26660; GFX9-NEXT:    v_add_f32_e32 v3, 4.0, v36661; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v36662; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]6663; GFX9-NEXT:    s_endpgm6664;6665; GFX11-LABEL: v_nnan_inputs_missing1_med3_f32_pat0:6666; GFX11:       ; %bb.0:6667; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246668; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v06669; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6670; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v06671; GFX11-NEXT:    s_waitcnt lgkmcnt(0)6672; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6673; GFX11-NEXT:    s_waitcnt vmcnt(0)6674; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6675; GFX11-NEXT:    s_waitcnt vmcnt(0)6676; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6677; GFX11-NEXT:    s_waitcnt vmcnt(0)6678; GFX11-NEXT:    v_dual_add_f32 v1, 1.0, v1 :: v_dual_add_f32 v2, 2.0, v26679; GFX11-NEXT:    v_add_f32_e32 v3, 4.0, v36680; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6681; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v36682; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]6683; GFX11-NEXT:    s_endpgm6684  %tid = call i32 @llvm.amdgcn.workitem.id.x()6685  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid6686  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid6687  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid6688  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid6689  %a = load volatile float, ptr addrspace(1) %gep06690  %b = load volatile float, ptr addrspace(1) %gep16691  %c = load volatile float, ptr addrspace(1) %gep26692 6693  %a.nnan = fadd nnan float %a, 1.06694  %b.nnan = fadd float %b, 2.06695  %c.nnan = fadd nnan float %c, 4.06696 6697  %tmp0 = call float @llvm.minnum.f32(float %a.nnan, float %b.nnan)6698  %tmp1 = call float @llvm.maxnum.f32(float %a.nnan, float %b.nnan)6699  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c.nnan)6700  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)6701  store float %med3, ptr addrspace(1) %outgep6702  ret void6703}6704 6705define amdgpu_kernel void @v_nnan_inputs_missing2_med3_f32_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {6706; SI-SDAG-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6707; SI-SDAG:       ; %bb.0:6708; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96709; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0006710; SI-SDAG-NEXT:    s_mov_b32 s10, 06711; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06712; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 06713; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]6714; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]6715; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6716; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]6717; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]6718; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]6719; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6720; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6721; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc6722; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6723; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc6724; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6725; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]6726; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v26727; SI-SDAG-NEXT:    v_add_f32_e32 v3, 2.0, v36728; SI-SDAG-NEXT:    v_add_f32_e32 v4, 4.0, v46729; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v46730; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646731; SI-SDAG-NEXT:    s_endpgm6732;6733; SI-GISEL-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6734; SI-GISEL:       ; %bb.0:6735; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96736; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06737; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 06738; SI-GISEL-NEXT:    s_mov_b32 s10, 06739; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0006740; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6741; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]6742; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6743; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6744; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]6745; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc6746; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6747; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]6748; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc6749; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6750; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v26751; SI-GISEL-NEXT:    v_add_f32_e32 v3, 2.0, v36752; SI-GISEL-NEXT:    v_add_f32_e32 v4, 4.0, v46753; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v46754; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6755; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646756; SI-GISEL-NEXT:    s_endpgm6757;6758; VI-SDAG-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6759; VI-SDAG:       ; %bb.0:6760; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246761; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v06762; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6763; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36764; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v66765; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6766; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56767; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v66768; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6769; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76770; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v66771; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6772; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc6773; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6774; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6775; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6776; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc6777; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6778; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16779; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v66780; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6781; VI-SDAG-NEXT:    v_add_f32_e32 v4, 1.0, v76782; VI-SDAG-NEXT:    v_add_f32_e32 v2, 2.0, v26783; VI-SDAG-NEXT:    v_add_f32_e32 v3, 4.0, v36784; VI-SDAG-NEXT:    v_med3_f32 v2, v4, v2, v36785; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26786; VI-SDAG-NEXT:    s_endpgm6787;6788; VI-GISEL-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6789; VI-GISEL:       ; %bb.0:6790; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246791; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06792; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6793; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26794; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36795; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66796; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6797; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46798; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56799; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66800; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6801; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66802; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76803; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v66804; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6805; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6806; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6807; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6808; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6809; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc6810; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6811; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06812; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16813; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66814; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6815; VI-GISEL-NEXT:    v_add_f32_e32 v4, 1.0, v76816; VI-GISEL-NEXT:    v_add_f32_e32 v2, 2.0, v26817; VI-GISEL-NEXT:    v_add_f32_e32 v3, 4.0, v36818; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v36819; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26820; VI-GISEL-NEXT:    s_endpgm6821;6822; GFX9-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6823; GFX9:       ; %bb.0:6824; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246825; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v06826; GFX9-NEXT:    s_waitcnt lgkmcnt(0)6827; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc6828; GFX9-NEXT:    s_waitcnt vmcnt(0)6829; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc6830; GFX9-NEXT:    s_waitcnt vmcnt(0)6831; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc6832; GFX9-NEXT:    s_waitcnt vmcnt(0)6833; GFX9-NEXT:    v_add_f32_e32 v1, 1.0, v16834; GFX9-NEXT:    v_add_f32_e32 v2, 2.0, v26835; GFX9-NEXT:    v_add_f32_e32 v3, 4.0, v36836; GFX9-NEXT:    v_med3_f32 v1, v1, v2, v36837; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]6838; GFX9-NEXT:    s_endpgm6839;6840; GFX11-LABEL: v_nnan_inputs_missing2_med3_f32_pat0:6841; GFX11:       ; %bb.0:6842; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x246843; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v06844; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6845; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v06846; GFX11-NEXT:    s_waitcnt lgkmcnt(0)6847; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc6848; GFX11-NEXT:    s_waitcnt vmcnt(0)6849; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc6850; GFX11-NEXT:    s_waitcnt vmcnt(0)6851; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc6852; GFX11-NEXT:    s_waitcnt vmcnt(0)6853; GFX11-NEXT:    v_dual_add_f32 v1, 1.0, v1 :: v_dual_add_f32 v2, 2.0, v26854; GFX11-NEXT:    v_add_f32_e32 v3, 4.0, v36855; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)6856; GFX11-NEXT:    v_med3_f32 v1, v1, v2, v36857; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]6858; GFX11-NEXT:    s_endpgm6859  %tid = call i32 @llvm.amdgcn.workitem.id.x()6860  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid6861  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid6862  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid6863  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid6864  %a = load volatile float, ptr addrspace(1) %gep06865  %b = load volatile float, ptr addrspace(1) %gep16866  %c = load volatile float, ptr addrspace(1) %gep26867 6868  %a.nnan = fadd nnan float %a, 1.06869  %b.nnan = fadd nnan float %b, 2.06870  %c.nnan = fadd float %c, 4.06871 6872  %tmp0 = call float @llvm.minnum.f32(float %a.nnan, float %b.nnan)6873  %tmp1 = call float @llvm.maxnum.f32(float %a.nnan, float %b.nnan)6874  %tmp2 = call float @llvm.minnum.f32(float %tmp1, float %c.nnan)6875  %med3 = call float @llvm.maxnum.f32(float %tmp0, float %tmp2)6876  store float %med3, ptr addrspace(1) %outgep6877  ret void6878}6879 6880define amdgpu_kernel void @v_test_nnan_on_call_med3_f32_pat0_srcmod0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {6881; SI-SDAG-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:6882; SI-SDAG:       ; %bb.0:6883; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96884; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0006885; SI-SDAG-NEXT:    s_mov_b32 s10, 06886; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06887; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 06888; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]6889; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]6890; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6891; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]6892; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]6893; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]6894; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6895; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6896; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc6897; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6898; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc6899; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)6900; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]6901; SI-SDAG-NEXT:    v_med3_f32 v2, -v2, v3, v46902; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646903; SI-SDAG-NEXT:    s_endpgm6904;6905; SI-GISEL-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:6906; SI-GISEL:       ; %bb.0:6907; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x96908; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v06909; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 06910; SI-GISEL-NEXT:    s_mov_b32 s10, 06911; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0006912; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6913; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]6914; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc6915; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6916; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]6917; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc6918; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6919; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]6920; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc6921; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)6922; SI-GISEL-NEXT:    v_mul_f32_e32 v2, -1.0, v26923; SI-GISEL-NEXT:    v_med3_f32 v2, v2, v3, v46924; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]6925; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr646926; SI-GISEL-NEXT:    s_endpgm6927;6928; VI-SDAG-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:6929; VI-SDAG:       ; %bb.0:6930; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246931; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v06932; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6933; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s36934; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v66935; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6936; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s56937; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v66938; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6939; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s76940; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v66941; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6942; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc6943; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6944; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc6945; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6946; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc6947; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)6948; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s16949; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v66950; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6951; VI-SDAG-NEXT:    v_med3_f32 v2, -v7, v2, v36952; VI-SDAG-NEXT:    flat_store_dword v[0:1], v26953; VI-SDAG-NEXT:    s_endpgm6954;6955; VI-GISEL-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:6956; VI-GISEL:       ; %bb.0:6957; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x246958; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v06959; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)6960; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s26961; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s36962; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66963; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6964; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s46965; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s56966; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v66967; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc6968; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s66969; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s76970; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v66971; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc6972; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc6973; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6974; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc6975; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6976; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc6977; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)6978; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s06979; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s16980; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v66981; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc6982; VI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v76983; VI-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v36984; VI-GISEL-NEXT:    flat_store_dword v[0:1], v26985; VI-GISEL-NEXT:    s_endpgm6986;6987; GFX9-SDAG-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:6988; GFX9-SDAG:       ; %bb.0:6989; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x246990; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v06991; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)6992; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc6993; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)6994; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc6995; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)6996; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc6997; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)6998; GFX9-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v36999; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]7000; GFX9-SDAG-NEXT:    s_endpgm7001;7002; GFX9-GISEL-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:7003; GFX9-GISEL:       ; %bb.0:7004; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x247005; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07006; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7007; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc7008; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7009; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc7010; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7011; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc7012; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7013; GFX9-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v17014; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v37015; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]7016; GFX9-GISEL-NEXT:    s_endpgm7017;7018; GFX11-SDAG-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:7019; GFX11-SDAG:       ; %bb.0:7020; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247021; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v07022; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)7023; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07024; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7025; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc7026; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7027; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc7028; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7029; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc7030; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7031; GFX11-SDAG-NEXT:    v_med3_f32 v1, -v1, v2, v37032; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]7033; GFX11-SDAG-NEXT:    s_endpgm7034;7035; GFX11-GISEL-LABEL: v_test_nnan_on_call_med3_f32_pat0_srcmod0:7036; GFX11-GISEL:       ; %bb.0:7037; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247038; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v07039; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)7040; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07041; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7042; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc7043; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7044; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc7045; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7046; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc7047; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7048; GFX11-GISEL-NEXT:    v_max_f32_e64 v1, -v1, -v17049; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)7050; GFX11-GISEL-NEXT:    v_med3_f32 v1, v1, v2, v37051; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]7052; GFX11-GISEL-NEXT:    s_endpgm7053  %tid = call i32 @llvm.amdgcn.workitem.id.x()7054  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid7055  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid7056  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid7057  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid7058  %a = load volatile float, ptr addrspace(1) %gep07059  %b = load volatile float, ptr addrspace(1) %gep17060  %c = load volatile float, ptr addrspace(1) %gep27061  %a.fneg = fsub float -0.0, %a7062  %tmp0 = call nnan float @llvm.minnum.f32(float %a.fneg, float %b)7063  %tmp1 = call nnan float @llvm.maxnum.f32(float %a.fneg, float %b)7064  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)7065  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)7066  store float %med3, ptr addrspace(1) %outgep7067  ret void7068}7069 7070define amdgpu_kernel void @v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {7071; SI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7072; SI-SDAG:       ; %bb.0:7073; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97074; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0007075; SI-SDAG-NEXT:    s_mov_b32 s10, 07076; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07077; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 07078; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]7079; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7080; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]7081; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]7082; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc7083; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7084; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc7085; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7086; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[6:7]7087; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[12:15], 0 addr64 glc7088; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7089; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]7090; SI-SDAG-NEXT:    v_min_f32_e64 v5, -v2, v37091; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v37092; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v47093; SI-SDAG-NEXT:    v_max_f32_e32 v2, v5, v27094; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647095; SI-SDAG-NEXT:    s_endpgm7096;7097; SI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7098; SI-GISEL:       ; %bb.0:7099; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97100; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07101; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 07102; SI-GISEL-NEXT:    s_mov_b32 s10, 07103; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0007104; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7105; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]7106; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc7107; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7108; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]7109; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc7110; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7111; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]7112; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc7113; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7114; SI-GISEL-NEXT:    v_mul_f32_e32 v5, -1.0, v27115; SI-GISEL-NEXT:    v_min_f32_e32 v5, v5, v37116; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v37117; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v47118; SI-GISEL-NEXT:    v_max_f32_e32 v2, v5, v27119; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]7120; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647121; SI-GISEL-NEXT:    s_endpgm7122;7123; VI-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7124; VI-SDAG:       ; %bb.0:7125; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247126; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v4, 2, v07127; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7128; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s37129; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v47130; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7131; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s57132; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v47133; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7134; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s77135; VI-SDAG-NEXT:    flat_load_dword v6, v[0:1] glc7136; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7137; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc7138; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7139; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s6, v47140; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v5, vcc7141; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1] glc7142; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7143; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v47144; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s17145; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7146; VI-SDAG-NEXT:    v_min_f32_e64 v4, -v6, v27147; VI-SDAG-NEXT:    v_max_f32_e32 v2, v6, v27148; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v37149; VI-SDAG-NEXT:    v_max_f32_e32 v2, v4, v27150; VI-SDAG-NEXT:    flat_store_dword v[0:1], v27151; VI-SDAG-NEXT:    s_endpgm7152;7153; VI-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7154; VI-GISEL:       ; %bb.0:7155; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247156; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v07157; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7158; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s27159; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s37160; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67161; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7162; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s47163; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s57164; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v67165; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7166; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s67167; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s77168; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc7169; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7170; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc7171; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7172; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v4, v67173; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v5, vcc7174; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1] glc7175; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7176; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s07177; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s17178; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67179; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7180; VI-GISEL-NEXT:    v_mul_f32_e32 v4, -1.0, v77181; VI-GISEL-NEXT:    v_max_f32_e32 v5, v7, v27182; VI-GISEL-NEXT:    v_min_f32_e32 v2, v4, v27183; VI-GISEL-NEXT:    v_min_f32_e32 v3, v5, v37184; VI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v37185; VI-GISEL-NEXT:    flat_store_dword v[0:1], v27186; VI-GISEL-NEXT:    s_endpgm7187;7188; GFX9-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7189; GFX9-SDAG:       ; %bb.0:7190; GFX9-SDAG-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x247191; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07192; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7193; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[10:11] glc7194; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)7195; GFX9-SDAG-NEXT:    global_load_dword v2, v0, s[12:13] glc7196; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)7197; GFX9-SDAG-NEXT:    global_load_dword v3, v0, s[14:15] glc7198; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)7199; GFX9-SDAG-NEXT:    v_min_f32_e64 v4, -v1, v27200; GFX9-SDAG-NEXT:    v_max_f32_e32 v1, v1, v27201; GFX9-SDAG-NEXT:    v_min_f32_e32 v1, v1, v37202; GFX9-SDAG-NEXT:    v_max_f32_e32 v1, v4, v17203; GFX9-SDAG-NEXT:    global_store_dword v0, v1, s[8:9]7204; GFX9-SDAG-NEXT:    s_endpgm7205;7206; GFX9-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7207; GFX9-GISEL:       ; %bb.0:7208; GFX9-GISEL-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x247209; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07210; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7211; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[10:11] glc7212; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7213; GFX9-GISEL-NEXT:    global_load_dword v2, v0, s[12:13] glc7214; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7215; GFX9-GISEL-NEXT:    global_load_dword v3, v0, s[14:15] glc7216; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)7217; GFX9-GISEL-NEXT:    v_max_f32_e64 v4, -v1, -v17218; GFX9-GISEL-NEXT:    v_max_f32_e32 v1, v1, v27219; GFX9-GISEL-NEXT:    v_min_f32_e32 v2, v4, v27220; GFX9-GISEL-NEXT:    v_min_f32_e32 v1, v1, v37221; GFX9-GISEL-NEXT:    v_max_f32_e32 v1, v2, v17222; GFX9-GISEL-NEXT:    global_store_dword v0, v1, s[8:9]7223; GFX9-GISEL-NEXT:    s_endpgm7224;7225; GFX11-SDAG-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7226; GFX11-SDAG:       ; %bb.0:7227; GFX11-SDAG-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247228; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v07229; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)7230; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07231; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7232; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc7233; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7234; GFX11-SDAG-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc7235; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7236; GFX11-SDAG-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc7237; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7238; GFX11-SDAG-NEXT:    v_maxmin_f32 v3, v1, v2, v37239; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)7240; GFX11-SDAG-NEXT:    v_minmax_f32 v1, -v1, v2, v37241; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]7242; GFX11-SDAG-NEXT:    s_endpgm7243;7244; GFX11-GISEL-LABEL: v_test_global_nnans_med3_f32_pat0_srcmod0_mismatch:7245; GFX11-GISEL:       ; %bb.0:7246; GFX11-GISEL-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247247; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v07248; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)7249; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07250; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7251; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc7252; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7253; GFX11-GISEL-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc7254; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7255; GFX11-GISEL-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc7256; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7257; GFX11-GISEL-NEXT:    v_max_f32_e64 v4, -v1, -v17258; GFX11-GISEL-NEXT:    v_max_f32_e32 v1, v1, v27259; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)7260; GFX11-GISEL-NEXT:    v_min_f32_e32 v4, v4, v27261; GFX11-GISEL-NEXT:    v_minmax_f32 v1, v1, v3, v47262; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]7263; GFX11-GISEL-NEXT:    s_endpgm7264  %tid = call i32 @llvm.amdgcn.workitem.id.x()7265  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid7266  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid7267  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid7268  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid7269  %a = load volatile float, ptr addrspace(1) %gep07270  %b = load volatile float, ptr addrspace(1) %gep17271  %c = load volatile float, ptr addrspace(1) %gep27272  %a.fneg = fsub float -0.0, %a7273  %tmp0 = call nnan float @llvm.minnum.f32(float %a.fneg, float %b)7274  %tmp1 = call nnan float @llvm.maxnum.f32(float %a, float %b)7275  %tmp2 = call nnan float @llvm.minnum.f32(float %tmp1, float %c)7276  %med3 = call nnan float @llvm.maxnum.f32(float %tmp0, float %tmp2)7277  store float %med3, ptr addrspace(1) %outgep7278  ret void7279}7280 7281; A simple min and max is not sufficient7282define amdgpu_kernel void @v_test_global_nnans_min_max_f32(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) #2 {7283; SI-SDAG-LABEL: v_test_global_nnans_min_max_f32:7284; SI-SDAG:       ; %bb.0:7285; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97286; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0007287; SI-SDAG-NEXT:    s_mov_b32 s10, 07288; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07289; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 07290; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]7291; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]7292; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7293; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]7294; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]7295; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]7296; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc7297; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7298; SI-SDAG-NEXT:    buffer_load_dword v3, v[0:1], s[12:15], 0 addr64 glc7299; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7300; SI-SDAG-NEXT:    buffer_load_dword v4, v[0:1], s[16:19], 0 addr64 glc7301; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7302; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]7303; SI-SDAG-NEXT:    v_max_f32_e32 v2, v2, v37304; SI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v47305; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647306; SI-SDAG-NEXT:    s_endpgm7307;7308; SI-GISEL-LABEL: v_test_global_nnans_min_max_f32:7309; SI-GISEL:       ; %bb.0:7310; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97311; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07312; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 07313; SI-GISEL-NEXT:    s_mov_b32 s10, 07314; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0007315; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7316; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]7317; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[8:11], 0 addr64 glc7318; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7319; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]7320; SI-GISEL-NEXT:    buffer_load_dword v3, v[0:1], s[8:11], 0 addr64 glc7321; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7322; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]7323; SI-GISEL-NEXT:    buffer_load_dword v4, v[0:1], s[8:11], 0 addr64 glc7324; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7325; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v37326; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v47327; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]7328; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647329; SI-GISEL-NEXT:    s_endpgm7330;7331; VI-SDAG-LABEL: v_test_global_nnans_min_max_f32:7332; VI-SDAG:       ; %bb.0:7333; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247334; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 2, v07335; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7336; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s37337; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v67338; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7339; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s57340; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v67341; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7342; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s77343; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v67344; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc7345; VI-SDAG-NEXT:    flat_load_dword v7, v[0:1] glc7346; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7347; VI-SDAG-NEXT:    flat_load_dword v2, v[2:3] glc7348; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7349; VI-SDAG-NEXT:    flat_load_dword v3, v[4:5] glc7350; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7351; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s17352; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v67353; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7354; VI-SDAG-NEXT:    v_max_f32_e32 v2, v7, v27355; VI-SDAG-NEXT:    v_min_f32_e32 v2, v2, v37356; VI-SDAG-NEXT:    flat_store_dword v[0:1], v27357; VI-SDAG-NEXT:    s_endpgm7358;7359; VI-GISEL-LABEL: v_test_global_nnans_min_max_f32:7360; VI-GISEL:       ; %bb.0:7361; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247362; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 2, v07363; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7364; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s27365; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s37366; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67367; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7368; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s47369; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s57370; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v67371; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7372; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s67373; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s77374; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v67375; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc7376; VI-GISEL-NEXT:    flat_load_dword v7, v[0:1] glc7377; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7378; VI-GISEL-NEXT:    flat_load_dword v2, v[2:3] glc7379; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7380; VI-GISEL-NEXT:    flat_load_dword v3, v[4:5] glc7381; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7382; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s07383; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s17384; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67385; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7386; VI-GISEL-NEXT:    v_max_f32_e32 v2, v7, v27387; VI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v37388; VI-GISEL-NEXT:    flat_store_dword v[0:1], v27389; VI-GISEL-NEXT:    s_endpgm7390;7391; GFX9-LABEL: v_test_global_nnans_min_max_f32:7392; GFX9:       ; %bb.0:7393; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x247394; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v07395; GFX9-NEXT:    s_waitcnt lgkmcnt(0)7396; GFX9-NEXT:    global_load_dword v1, v0, s[10:11] glc7397; GFX9-NEXT:    s_waitcnt vmcnt(0)7398; GFX9-NEXT:    global_load_dword v2, v0, s[12:13] glc7399; GFX9-NEXT:    s_waitcnt vmcnt(0)7400; GFX9-NEXT:    global_load_dword v3, v0, s[14:15] glc7401; GFX9-NEXT:    s_waitcnt vmcnt(0)7402; GFX9-NEXT:    v_max_f32_e32 v1, v1, v27403; GFX9-NEXT:    v_min_f32_e32 v1, v1, v37404; GFX9-NEXT:    global_store_dword v0, v1, s[8:9]7405; GFX9-NEXT:    s_endpgm7406;7407; GFX11-LABEL: v_test_global_nnans_min_max_f32:7408; GFX11:       ; %bb.0:7409; GFX11-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247410; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v07411; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)7412; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v07413; GFX11-NEXT:    s_waitcnt lgkmcnt(0)7414; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3] glc dlc7415; GFX11-NEXT:    s_waitcnt vmcnt(0)7416; GFX11-NEXT:    global_load_b32 v2, v0, s[4:5] glc dlc7417; GFX11-NEXT:    s_waitcnt vmcnt(0)7418; GFX11-NEXT:    global_load_b32 v3, v0, s[6:7] glc dlc7419; GFX11-NEXT:    s_waitcnt vmcnt(0)7420; GFX11-NEXT:    v_maxmin_f32 v1, v1, v2, v37421; GFX11-NEXT:    global_store_b32 v0, v1, s[0:1]7422; GFX11-NEXT:    s_endpgm7423  %tid = call i32 @llvm.amdgcn.workitem.id.x()7424  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid7425  %gep1 = getelementptr float, ptr addrspace(1) %bptr, i32 %tid7426  %gep2 = getelementptr float, ptr addrspace(1) %cptr, i32 %tid7427  %outgep = getelementptr float, ptr addrspace(1) %out, i32 %tid7428  %a = load volatile float, ptr addrspace(1) %gep07429  %b = load volatile float, ptr addrspace(1) %gep17430  %c = load volatile float, ptr addrspace(1) %gep27431  %max = call nnan float @llvm.maxnum.f32(float %a, float %b)7432  %minmax = call nnan float @llvm.minnum.f32(float %max, float %c)7433  store float %minmax, ptr addrspace(1) %outgep7434  ret void7435}7436 7437define amdgpu_kernel void @v_test_nnan_input_fmed3_r_i_i_f16(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {7438; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7439; SI-SDAG:       ; %bb.0:7440; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x97441; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf0007442; SI-SDAG-NEXT:    s_mov_b32 s6, 07443; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 1, v07444; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 07445; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7446; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]7447; SI-SDAG-NEXT:    buffer_load_ushort v2, v[0:1], s[4:7], 0 addr647448; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]7449; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7450; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v2, v27451; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v27452; SI-SDAG-NEXT:    v_med3_f32 v2, v2, 2.0, 4.07453; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v2, v27454; SI-SDAG-NEXT:    buffer_store_short v2, v[0:1], s[0:3], 0 addr647455; SI-SDAG-NEXT:    s_endpgm7456;7457; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7458; SI-GISEL:       ; %bb.0:7459; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x97460; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 1, v07461; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 07462; SI-GISEL-NEXT:    s_mov_b32 s6, 07463; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf0007464; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7465; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]7466; SI-GISEL-NEXT:    buffer_load_ushort v2, v[0:1], s[4:7], 0 addr647467; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7468; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27469; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v27470; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27471; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27472; SI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v27473; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27474; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27475; SI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v27476; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27477; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]7478; SI-GISEL-NEXT:    buffer_store_short v2, v[0:1], s[0:3], 0 addr647479; SI-GISEL-NEXT:    s_endpgm7480;7481; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7482; VI-SDAG:       ; %bb.0:7483; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247484; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 1, v07485; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7486; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s37487; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v27488; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7489; VI-SDAG-NEXT:    flat_load_ushort v3, v[0:1]7490; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v27491; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s17492; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7493; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7494; VI-SDAG-NEXT:    v_add_f16_e32 v2, 1.0, v37495; VI-SDAG-NEXT:    v_max_f16_e32 v2, 2.0, v27496; VI-SDAG-NEXT:    v_min_f16_e32 v2, 4.0, v27497; VI-SDAG-NEXT:    flat_store_short v[0:1], v27498; VI-SDAG-NEXT:    s_endpgm7499;7500; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7501; VI-GISEL:       ; %bb.0:7502; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247503; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 1, v07504; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7505; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s27506; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s37507; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v27508; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7509; VI-GISEL-NEXT:    flat_load_ushort v3, v[0:1]7510; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s07511; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v27512; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s17513; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7514; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7515; VI-GISEL-NEXT:    v_add_f16_e32 v2, 1.0, v37516; VI-GISEL-NEXT:    v_max_f16_e32 v2, 2.0, v27517; VI-GISEL-NEXT:    v_min_f16_e32 v2, 4.0, v27518; VI-GISEL-NEXT:    flat_store_short v[0:1], v27519; VI-GISEL-NEXT:    s_endpgm7520;7521; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7522; GFX9:       ; %bb.0:7523; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247524; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 1, v07525; GFX9-NEXT:    s_waitcnt lgkmcnt(0)7526; GFX9-NEXT:    global_load_ushort v1, v0, s[2:3]7527; GFX9-NEXT:    s_waitcnt vmcnt(0)7528; GFX9-NEXT:    v_add_f16_e32 v1, 1.0, v17529; GFX9-NEXT:    v_med3_f16 v1, v1, 2.0, 4.07530; GFX9-NEXT:    global_store_short v0, v1, s[0:1]7531; GFX9-NEXT:    s_endpgm7532;7533; GFX11-SDAG-FAKE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7534; GFX11-SDAG-FAKE16:       ; %bb.0:7535; GFX11-SDAG-FAKE16-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247536; GFX11-SDAG-FAKE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07537; GFX11-SDAG-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)7538; GFX11-SDAG-FAKE16-NEXT:    v_lshlrev_b32_e32 v0, 1, v07539; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt lgkmcnt(0)7540; GFX11-SDAG-FAKE16-NEXT:    global_load_u16 v1, v0, s[2:3]7541; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0)7542; GFX11-SDAG-FAKE16-NEXT:    v_add_f16_e32 v1, 1.0, v17543; GFX11-SDAG-FAKE16-NEXT:    v_med3_f16 v1, v1, 2.0, 4.07544; GFX11-SDAG-FAKE16-NEXT:    global_store_b16 v0, v1, s[0:1]7545; GFX11-SDAG-FAKE16-NEXT:    s_endpgm7546;7547; GFX11-GISEL-FAKE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7548; GFX11-GISEL-FAKE16:       ; %bb.0:7549; GFX11-GISEL-FAKE16-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247550; GFX11-GISEL-FAKE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07551; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)7552; GFX11-GISEL-FAKE16-NEXT:    v_lshlrev_b32_e32 v0, 1, v07553; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt lgkmcnt(0)7554; GFX11-GISEL-FAKE16-NEXT:    global_load_u16 v1, v0, s[2:3]7555; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0)7556; GFX11-GISEL-FAKE16-NEXT:    v_add_f16_e32 v1, 1.0, v17557; GFX11-GISEL-FAKE16-NEXT:    v_med3_f16 v1, v1, 2.0, 4.07558; GFX11-GISEL-FAKE16-NEXT:    global_store_b16 v0, v1, s[0:1]7559; GFX11-GISEL-FAKE16-NEXT:    s_endpgm7560;7561; GFX11-SDAG-TRUE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7562; GFX11-SDAG-TRUE16:       ; %bb.0:7563; GFX11-SDAG-TRUE16-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247564; GFX11-SDAG-TRUE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07565; GFX11-SDAG-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)7566; GFX11-SDAG-TRUE16-NEXT:    v_lshlrev_b32_e32 v1, 1, v07567; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt lgkmcnt(0)7568; GFX11-SDAG-TRUE16-NEXT:    global_load_d16_b16 v0, v1, s[2:3]7569; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0)7570; GFX11-SDAG-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l7571; GFX11-SDAG-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, 2.0, 4.07572; GFX11-SDAG-TRUE16-NEXT:    global_store_b16 v1, v0, s[0:1]7573; GFX11-SDAG-TRUE16-NEXT:    s_endpgm7574;7575; GFX11-GISEL-TRUE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16:7576; GFX11-GISEL-TRUE16:       ; %bb.0:7577; GFX11-GISEL-TRUE16-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247578; GFX11-GISEL-TRUE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07579; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_1)7580; GFX11-GISEL-TRUE16-NEXT:    v_lshlrev_b32_e32 v1, 1, v07581; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt lgkmcnt(0)7582; GFX11-GISEL-TRUE16-NEXT:    global_load_d16_b16 v0, v1, s[2:3]7583; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0)7584; GFX11-GISEL-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l7585; GFX11-GISEL-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, 2.0, 4.07586; GFX11-GISEL-TRUE16-NEXT:    global_store_b16 v1, v0, s[0:1]7587; GFX11-GISEL-TRUE16-NEXT:    s_endpgm7588  %tid = call i32 @llvm.amdgcn.workitem.id.x()7589  %gep0 = getelementptr half, ptr addrspace(1) %aptr, i32 %tid7590  %outgep = getelementptr half, ptr addrspace(1) %out, i32 %tid7591  %a = load half, ptr addrspace(1) %gep07592  %a.add = fadd nnan half %a, 1.07593  %max = call half @llvm.maxnum.f16(half %a.add, half 2.0)7594  %med = call half @llvm.minnum.f16(half %max, half 4.0)7595 7596  store half %med, ptr addrspace(1) %outgep7597  ret void7598}7599 7600define amdgpu_kernel void @v_nnan_inputs_med3_f16_pat0(ptr addrspace(1) %out, ptr addrspace(1) %aptr, ptr addrspace(1) %bptr, ptr addrspace(1) %cptr) {7601; SI-SDAG-LABEL: v_nnan_inputs_med3_f16_pat0:7602; SI-SDAG:       ; %bb.0:7603; SI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97604; SI-SDAG-NEXT:    s_mov_b32 s11, 0xf0007605; SI-SDAG-NEXT:    s_mov_b32 s10, 07606; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 1, v07607; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 07608; SI-SDAG-NEXT:    s_mov_b64 s[14:15], s[10:11]7609; SI-SDAG-NEXT:    s_mov_b64 s[18:19], s[10:11]7610; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7611; SI-SDAG-NEXT:    s_mov_b64 s[8:9], s[2:3]7612; SI-SDAG-NEXT:    s_mov_b64 s[12:13], s[4:5]7613; SI-SDAG-NEXT:    s_mov_b64 s[16:17], s[6:7]7614; SI-SDAG-NEXT:    buffer_load_ushort v2, v[0:1], s[8:11], 0 addr64 glc7615; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7616; SI-SDAG-NEXT:    buffer_load_ushort v3, v[0:1], s[12:15], 0 addr64 glc7617; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7618; SI-SDAG-NEXT:    buffer_load_ushort v4, v[0:1], s[16:19], 0 addr64 glc7619; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7620; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[10:11]7621; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v2, v27622; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v3, v37623; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v4, v47624; SI-SDAG-NEXT:    v_add_f32_e32 v2, 1.0, v27625; SI-SDAG-NEXT:    v_add_f32_e32 v3, 2.0, v37626; SI-SDAG-NEXT:    v_add_f32_e32 v4, 4.0, v47627; SI-SDAG-NEXT:    v_med3_f32 v2, v2, v3, v47628; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v2, v27629; SI-SDAG-NEXT:    buffer_store_short v2, v[0:1], s[0:3], 0 addr647630; SI-SDAG-NEXT:    s_endpgm7631;7632; SI-GISEL-LABEL: v_nnan_inputs_med3_f16_pat0:7633; SI-GISEL:       ; %bb.0:7634; SI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x97635; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 1, v07636; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 07637; SI-GISEL-NEXT:    s_mov_b32 s10, 07638; SI-GISEL-NEXT:    s_mov_b32 s11, 0xf0007639; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7640; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[2:3]7641; SI-GISEL-NEXT:    buffer_load_ushort v2, v[0:1], s[8:11], 0 addr64 glc7642; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7643; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[4:5]7644; SI-GISEL-NEXT:    buffer_load_ushort v3, v[0:1], s[8:11], 0 addr64 glc7645; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7646; SI-GISEL-NEXT:    s_mov_b64 s[8:9], s[6:7]7647; SI-GISEL-NEXT:    buffer_load_ushort v4, v[0:1], s[8:11], 0 addr64 glc7648; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7649; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27650; SI-GISEL-NEXT:    v_add_f32_e32 v2, 1.0, v27651; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v3, v37652; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27653; SI-GISEL-NEXT:    v_add_f32_e32 v3, 2.0, v37654; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v4, v47655; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v3, v37656; SI-GISEL-NEXT:    v_add_f32_e32 v4, 4.0, v47657; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27658; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v4, v47659; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v3, v37660; SI-GISEL-NEXT:    v_min_f32_e32 v5, v2, v37661; SI-GISEL-NEXT:    v_max_f32_e32 v2, v2, v37662; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v3, v47663; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v4, v57664; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27665; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27666; SI-GISEL-NEXT:    v_min_f32_e32 v2, v2, v37667; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27668; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v3, v47669; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v2, v27670; SI-GISEL-NEXT:    v_max_f32_e32 v2, v3, v27671; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v2, v27672; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[10:11]7673; SI-GISEL-NEXT:    buffer_store_short v2, v[0:1], s[0:3], 0 addr647674; SI-GISEL-NEXT:    s_endpgm7675;7676; VI-SDAG-LABEL: v_nnan_inputs_med3_f16_pat0:7677; VI-SDAG:       ; %bb.0:7678; VI-SDAG-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247679; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v6, 1, v07680; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7681; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s37682; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v67683; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7684; VI-SDAG-NEXT:    v_mov_b32_e32 v3, s57685; VI-SDAG-NEXT:    v_add_u32_e32 v2, vcc, s4, v67686; VI-SDAG-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7687; VI-SDAG-NEXT:    v_mov_b32_e32 v5, s77688; VI-SDAG-NEXT:    v_add_u32_e32 v4, vcc, s6, v67689; VI-SDAG-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc7690; VI-SDAG-NEXT:    flat_load_ushort v7, v[0:1] glc7691; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7692; VI-SDAG-NEXT:    flat_load_ushort v2, v[2:3] glc7693; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7694; VI-SDAG-NEXT:    flat_load_ushort v3, v[4:5] glc7695; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7696; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s17697; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v67698; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7699; VI-SDAG-NEXT:    v_add_f16_e32 v4, 1.0, v77700; VI-SDAG-NEXT:    v_add_f16_e32 v2, 2.0, v27701; VI-SDAG-NEXT:    v_add_f16_e32 v3, 4.0, v37702; VI-SDAG-NEXT:    v_min_f16_e32 v5, v4, v27703; VI-SDAG-NEXT:    v_max_f16_e32 v2, v4, v27704; VI-SDAG-NEXT:    v_min_f16_e32 v2, v2, v37705; VI-SDAG-NEXT:    v_max_f16_e32 v2, v5, v27706; VI-SDAG-NEXT:    flat_store_short v[0:1], v27707; VI-SDAG-NEXT:    s_endpgm7708;7709; VI-GISEL-LABEL: v_nnan_inputs_med3_f16_pat0:7710; VI-GISEL:       ; %bb.0:7711; VI-GISEL-NEXT:    s_load_dwordx8 s[0:7], s[4:5], 0x247712; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v6, 1, v07713; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7714; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s27715; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s37716; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67717; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7718; VI-GISEL-NEXT:    v_mov_b32_e32 v2, s47719; VI-GISEL-NEXT:    v_mov_b32_e32 v3, s57720; VI-GISEL-NEXT:    v_add_u32_e32 v2, vcc, v2, v67721; VI-GISEL-NEXT:    v_addc_u32_e32 v3, vcc, 0, v3, vcc7722; VI-GISEL-NEXT:    v_mov_b32_e32 v4, s67723; VI-GISEL-NEXT:    v_mov_b32_e32 v5, s77724; VI-GISEL-NEXT:    v_add_u32_e32 v4, vcc, v4, v67725; VI-GISEL-NEXT:    v_addc_u32_e32 v5, vcc, 0, v5, vcc7726; VI-GISEL-NEXT:    flat_load_ushort v7, v[0:1] glc7727; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7728; VI-GISEL-NEXT:    flat_load_ushort v2, v[2:3] glc7729; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7730; VI-GISEL-NEXT:    flat_load_ushort v3, v[4:5] glc7731; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7732; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s07733; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s17734; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v67735; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7736; VI-GISEL-NEXT:    v_add_f16_e32 v4, 1.0, v77737; VI-GISEL-NEXT:    v_add_f16_e32 v2, 2.0, v27738; VI-GISEL-NEXT:    v_add_f16_e32 v3, 4.0, v37739; VI-GISEL-NEXT:    v_min_f16_e32 v5, v4, v27740; VI-GISEL-NEXT:    v_max_f16_e32 v2, v4, v27741; VI-GISEL-NEXT:    v_min_f16_e32 v2, v2, v37742; VI-GISEL-NEXT:    v_max_f16_e32 v2, v5, v27743; VI-GISEL-NEXT:    flat_store_short v[0:1], v27744; VI-GISEL-NEXT:    s_endpgm7745;7746; GFX9-LABEL: v_nnan_inputs_med3_f16_pat0:7747; GFX9:       ; %bb.0:7748; GFX9-NEXT:    s_load_dwordx8 s[8:15], s[4:5], 0x247749; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 1, v07750; GFX9-NEXT:    s_waitcnt lgkmcnt(0)7751; GFX9-NEXT:    global_load_ushort v1, v0, s[10:11] glc7752; GFX9-NEXT:    s_waitcnt vmcnt(0)7753; GFX9-NEXT:    global_load_ushort v2, v0, s[12:13] glc7754; GFX9-NEXT:    s_waitcnt vmcnt(0)7755; GFX9-NEXT:    global_load_ushort v3, v0, s[14:15] glc7756; GFX9-NEXT:    s_waitcnt vmcnt(0)7757; GFX9-NEXT:    v_add_f16_e32 v1, 1.0, v17758; GFX9-NEXT:    v_add_f16_e32 v2, 2.0, v27759; GFX9-NEXT:    v_add_f16_e32 v3, 4.0, v37760; GFX9-NEXT:    v_med3_f16 v1, v1, v2, v37761; GFX9-NEXT:    global_store_short v0, v1, s[8:9]7762; GFX9-NEXT:    s_endpgm7763;7764; GFX11-SDAG-FAKE16-LABEL: v_nnan_inputs_med3_f16_pat0:7765; GFX11-SDAG-FAKE16:       ; %bb.0:7766; GFX11-SDAG-FAKE16-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247767; GFX11-SDAG-FAKE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07768; GFX11-SDAG-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7769; GFX11-SDAG-FAKE16-NEXT:    v_lshlrev_b32_e32 v0, 1, v07770; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt lgkmcnt(0)7771; GFX11-SDAG-FAKE16-NEXT:    global_load_u16 v1, v0, s[2:3] glc dlc7772; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0)7773; GFX11-SDAG-FAKE16-NEXT:    global_load_u16 v2, v0, s[4:5] glc dlc7774; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0)7775; GFX11-SDAG-FAKE16-NEXT:    global_load_u16 v3, v0, s[6:7] glc dlc7776; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0)7777; GFX11-SDAG-FAKE16-NEXT:    v_add_f16_e32 v1, 1.0, v17778; GFX11-SDAG-FAKE16-NEXT:    v_add_f16_e32 v2, 2.0, v27779; GFX11-SDAG-FAKE16-NEXT:    v_add_f16_e32 v3, 4.0, v37780; GFX11-SDAG-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7781; GFX11-SDAG-FAKE16-NEXT:    v_med3_f16 v1, v1, v2, v37782; GFX11-SDAG-FAKE16-NEXT:    global_store_b16 v0, v1, s[0:1]7783; GFX11-SDAG-FAKE16-NEXT:    s_endpgm7784;7785; GFX11-GISEL-FAKE16-LABEL: v_nnan_inputs_med3_f16_pat0:7786; GFX11-GISEL-FAKE16:       ; %bb.0:7787; GFX11-GISEL-FAKE16-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247788; GFX11-GISEL-FAKE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07789; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7790; GFX11-GISEL-FAKE16-NEXT:    v_lshlrev_b32_e32 v0, 1, v07791; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt lgkmcnt(0)7792; GFX11-GISEL-FAKE16-NEXT:    global_load_u16 v1, v0, s[2:3] glc dlc7793; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0)7794; GFX11-GISEL-FAKE16-NEXT:    global_load_u16 v2, v0, s[4:5] glc dlc7795; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0)7796; GFX11-GISEL-FAKE16-NEXT:    global_load_u16 v3, v0, s[6:7] glc dlc7797; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0)7798; GFX11-GISEL-FAKE16-NEXT:    v_add_f16_e32 v1, 1.0, v17799; GFX11-GISEL-FAKE16-NEXT:    v_add_f16_e32 v2, 2.0, v27800; GFX11-GISEL-FAKE16-NEXT:    v_add_f16_e32 v3, 4.0, v37801; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7802; GFX11-GISEL-FAKE16-NEXT:    v_med3_f16 v1, v1, v2, v37803; GFX11-GISEL-FAKE16-NEXT:    global_store_b16 v0, v1, s[0:1]7804; GFX11-GISEL-FAKE16-NEXT:    s_endpgm7805;7806; GFX11-SDAG-TRUE16-LABEL: v_nnan_inputs_med3_f16_pat0:7807; GFX11-SDAG-TRUE16:       ; %bb.0:7808; GFX11-SDAG-TRUE16-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247809; GFX11-SDAG-TRUE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07810; GFX11-SDAG-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7811; GFX11-SDAG-TRUE16-NEXT:    v_lshlrev_b32_e32 v2, 1, v07812; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt lgkmcnt(0)7813; GFX11-SDAG-TRUE16-NEXT:    global_load_d16_b16 v0, v2, s[2:3] glc dlc7814; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0)7815; GFX11-SDAG-TRUE16-NEXT:    global_load_d16_hi_b16 v0, v2, s[4:5] glc dlc7816; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0)7817; GFX11-SDAG-TRUE16-NEXT:    global_load_d16_b16 v1, v2, s[6:7] glc dlc7818; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0)7819; GFX11-SDAG-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l7820; GFX11-SDAG-TRUE16-NEXT:    v_add_f16_e32 v0.h, 2.0, v0.h7821; GFX11-SDAG-TRUE16-NEXT:    v_add_f16_e32 v1.l, 4.0, v1.l7822; GFX11-SDAG-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7823; GFX11-SDAG-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, v0.h, v1.l7824; GFX11-SDAG-TRUE16-NEXT:    global_store_b16 v2, v0, s[0:1]7825; GFX11-SDAG-TRUE16-NEXT:    s_endpgm7826;7827; GFX11-GISEL-TRUE16-LABEL: v_nnan_inputs_med3_f16_pat0:7828; GFX11-GISEL-TRUE16:       ; %bb.0:7829; GFX11-GISEL-TRUE16-NEXT:    s_load_b256 s[0:7], s[4:5], 0x247830; GFX11-GISEL-TRUE16-NEXT:    v_and_b32_e32 v0, 0x3ff, v07831; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7832; GFX11-GISEL-TRUE16-NEXT:    v_lshlrev_b32_e32 v2, 1, v07833; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt lgkmcnt(0)7834; GFX11-GISEL-TRUE16-NEXT:    global_load_d16_b16 v0, v2, s[2:3] glc dlc7835; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0)7836; GFX11-GISEL-TRUE16-NEXT:    global_load_d16_hi_b16 v0, v2, s[4:5] glc dlc7837; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0)7838; GFX11-GISEL-TRUE16-NEXT:    global_load_d16_b16 v1, v2, s[6:7] glc dlc7839; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0)7840; GFX11-GISEL-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l7841; GFX11-GISEL-TRUE16-NEXT:    v_add_f16_e32 v0.h, 2.0, v0.h7842; GFX11-GISEL-TRUE16-NEXT:    v_add_f16_e32 v1.l, 4.0, v1.l7843; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)7844; GFX11-GISEL-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, v0.h, v1.l7845; GFX11-GISEL-TRUE16-NEXT:    global_store_b16 v2, v0, s[0:1]7846; GFX11-GISEL-TRUE16-NEXT:    s_endpgm7847  %tid = call i32 @llvm.amdgcn.workitem.id.x()7848  %gep0 = getelementptr half, ptr addrspace(1) %aptr, i32 %tid7849  %gep1 = getelementptr half, ptr addrspace(1) %bptr, i32 %tid7850  %gep2 = getelementptr half, ptr addrspace(1) %cptr, i32 %tid7851  %outgep = getelementptr half, ptr addrspace(1) %out, i32 %tid7852  %a = load volatile half, ptr addrspace(1) %gep07853  %b = load volatile half, ptr addrspace(1) %gep17854  %c = load volatile half, ptr addrspace(1) %gep27855 7856  %a.nnan = fadd nnan half %a, 1.07857  %b.nnan = fadd nnan half %b, 2.07858  %c.nnan = fadd nnan half %c, 4.07859 7860  %tmp0 = call half @llvm.minnum.f16(half %a.nnan, half %b.nnan)7861  %tmp1 = call half @llvm.maxnum.f16(half %a.nnan, half %b.nnan)7862  %tmp2 = call half @llvm.minnum.f16(half %tmp1, half %c.nnan)7863  %med3 = call half @llvm.maxnum.f16(half %tmp0, half %tmp2)7864  store half %med3, ptr addrspace(1) %outgep7865  ret void7866}7867 7868define amdgpu_kernel void @two_non_inline_constant(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {7869; SI-SDAG-LABEL: two_non_inline_constant:7870; SI-SDAG:       ; %bb.0:7871; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x97872; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf0007873; SI-SDAG-NEXT:    s_mov_b32 s6, 07874; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07875; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 07876; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7877; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]7878; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr647879; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]7880; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)7881; SI-SDAG-NEXT:    v_add_f32_e32 v2, 0.5, v27882; SI-SDAG-NEXT:    v_max_f32_e32 v2, 0x41000000, v27883; SI-SDAG-NEXT:    v_min_f32_e32 v2, 0x41800000, v27884; SI-SDAG-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647885; SI-SDAG-NEXT:    s_endpgm7886;7887; SI-GISEL-LABEL: two_non_inline_constant:7888; SI-GISEL:       ; %bb.0:7889; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x97890; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07891; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 07892; SI-GISEL-NEXT:    s_mov_b32 s6, 07893; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf0007894; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7895; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]7896; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr647897; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)7898; SI-GISEL-NEXT:    v_add_f32_e32 v2, 0.5, v27899; SI-GISEL-NEXT:    v_max_f32_e32 v2, 0x41000000, v27900; SI-GISEL-NEXT:    v_min_f32_e32 v2, 0x41800000, v27901; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]7902; SI-GISEL-NEXT:    buffer_store_dword v2, v[0:1], s[0:3], 0 addr647903; SI-GISEL-NEXT:    s_endpgm7904;7905; VI-SDAG-LABEL: two_non_inline_constant:7906; VI-SDAG:       ; %bb.0:7907; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247908; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v07909; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7910; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s37911; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v27912; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7913; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]7914; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v27915; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s17916; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7917; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)7918; VI-SDAG-NEXT:    v_add_f32_e32 v2, 0.5, v37919; VI-SDAG-NEXT:    v_max_f32_e32 v2, 0x41000000, v27920; VI-SDAG-NEXT:    v_min_f32_e32 v2, 0x41800000, v27921; VI-SDAG-NEXT:    flat_store_dword v[0:1], v27922; VI-SDAG-NEXT:    s_endpgm7923;7924; VI-GISEL-LABEL: two_non_inline_constant:7925; VI-GISEL:       ; %bb.0:7926; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247927; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v07928; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7929; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s27930; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s37931; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v27932; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7933; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]7934; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s07935; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v27936; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s17937; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc7938; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)7939; VI-GISEL-NEXT:    v_add_f32_e32 v2, 0.5, v37940; VI-GISEL-NEXT:    v_max_f32_e32 v2, 0x41000000, v27941; VI-GISEL-NEXT:    v_min_f32_e32 v2, 0x41800000, v27942; VI-GISEL-NEXT:    flat_store_dword v[0:1], v27943; VI-GISEL-NEXT:    s_endpgm7944;7945; GFX9-LABEL: two_non_inline_constant:7946; GFX9:       ; %bb.0:7947; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x247948; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v07949; GFX9-NEXT:    s_waitcnt lgkmcnt(0)7950; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]7951; GFX9-NEXT:    s_waitcnt vmcnt(0)7952; GFX9-NEXT:    v_add_f32_e32 v1, 0.5, v17953; GFX9-NEXT:    v_max_f32_e32 v1, 0x41000000, v17954; GFX9-NEXT:    v_min_f32_e32 v1, 0x41800000, v17955; GFX9-NEXT:    global_store_dword v0, v1, s[0:1]7956; GFX9-NEXT:    s_endpgm7957;7958; GFX11-SDAG-LABEL: two_non_inline_constant:7959; GFX11-SDAG:       ; %bb.0:7960; GFX11-SDAG-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247961; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v07962; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)7963; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v07964; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)7965; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3]7966; GFX11-SDAG-NEXT:    s_mov_b32 s2, 0x410000007967; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)7968; GFX11-SDAG-NEXT:    v_add_f32_e32 v1, 0.5, v17969; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)7970; GFX11-SDAG-NEXT:    v_maxmin_f32 v1, v1, s2, 0x418000007971; GFX11-SDAG-NEXT:    global_store_b32 v0, v1, s[0:1]7972; GFX11-SDAG-NEXT:    s_endpgm7973;7974; GFX11-GISEL-LABEL: two_non_inline_constant:7975; GFX11-GISEL:       ; %bb.0:7976; GFX11-GISEL-NEXT:    s_load_b128 s[0:3], s[4:5], 0x247977; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v07978; GFX11-GISEL-NEXT:    v_mov_b32_e32 v2, 0x418000007979; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)7980; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v07981; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)7982; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3]7983; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)7984; GFX11-GISEL-NEXT:    v_add_f32_e32 v1, 0.5, v17985; GFX11-GISEL-NEXT:    v_maxmin_f32 v1, v1, 0x41000000, v27986; GFX11-GISEL-NEXT:    global_store_b32 v0, v1, s[0:1]7987; GFX11-GISEL-NEXT:    s_endpgm7988  %tid = call i32 @llvm.amdgcn.workitem.id.x()7989  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid7990  %out.gep = getelementptr float, ptr addrspace(1) %out, i32 %tid7991  %a = load float, ptr addrspace(1) %gep07992  %add = fadd nnan float %a, 0.57993  %max = call float @llvm.maxnum.f32(float %add, float 8.0)7994  %med = call float @llvm.minnum.f32(float %max, float 16.0)7995 7996  store float %med, ptr addrspace(1) %out.gep7997  ret void7998}7999 8000; FIXME: Simple stores do not work as a multiple use because they are bitcasted to integer constants.8001define amdgpu_kernel void @one_non_inline_constant(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {8002; SI-SDAG-LABEL: one_non_inline_constant:8003; SI-SDAG:       ; %bb.0:8004; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x98005; SI-SDAG-NEXT:    s_mov_b32 s6, 08006; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf0008007; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v08008; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 08009; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8010; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]8011; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr648012; SI-SDAG-NEXT:    v_mov_b32_e32 v3, 0x418000008013; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]8014; SI-SDAG-NEXT:    s_mov_b32 s6, -18015; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)8016; SI-SDAG-NEXT:    v_add_f32_e32 v4, 0.5, v28017; SI-SDAG-NEXT:    v_add_f32_e32 v2, 0x41800000, v28018; SI-SDAG-NEXT:    v_med3_f32 v3, v4, 1.0, v38019; SI-SDAG-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr648020; SI-SDAG-NEXT:    buffer_store_dword v2, off, s[4:7], 08021; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)8022; SI-SDAG-NEXT:    s_endpgm8023;8024; SI-GISEL-LABEL: one_non_inline_constant:8025; SI-GISEL:       ; %bb.0:8026; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x98027; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v08028; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 08029; SI-GISEL-NEXT:    s_mov_b32 s6, 08030; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf0008031; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8032; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]8033; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr648034; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x418000008035; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]8036; SI-GISEL-NEXT:    s_mov_b32 s6, -18037; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)8038; SI-GISEL-NEXT:    v_add_f32_e32 v4, 0.5, v28039; SI-GISEL-NEXT:    v_add_f32_e32 v2, 0x41800000, v28040; SI-GISEL-NEXT:    v_med3_f32 v3, v4, 1.0, v38041; SI-GISEL-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr648042; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[4:7], 08043; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)8044; SI-GISEL-NEXT:    s_endpgm8045;8046; VI-SDAG-LABEL: one_non_inline_constant:8047; VI-SDAG:       ; %bb.0:8048; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248049; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v08050; VI-SDAG-NEXT:    v_mov_b32_e32 v4, 0x418000008051; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8052; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s38053; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v28054; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8055; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]8056; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s18057; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v28058; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8059; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)8060; VI-SDAG-NEXT:    v_add_f32_e32 v2, 0.5, v38061; VI-SDAG-NEXT:    v_med3_f32 v2, v2, 1.0, v48062; VI-SDAG-NEXT:    v_add_f32_e32 v3, 0x41800000, v38063; VI-SDAG-NEXT:    flat_store_dword v[0:1], v28064; VI-SDAG-NEXT:    flat_store_dword v[0:1], v38065; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)8066; VI-SDAG-NEXT:    s_endpgm8067;8068; VI-GISEL-LABEL: one_non_inline_constant:8069; VI-GISEL:       ; %bb.0:8070; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248071; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v08072; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x418000008073; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8074; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s28075; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s38076; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v28077; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8078; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]8079; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s08080; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s18081; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v28082; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8083; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)8084; VI-GISEL-NEXT:    v_add_f32_e32 v2, 0.5, v38085; VI-GISEL-NEXT:    v_med3_f32 v2, v2, 1.0, v48086; VI-GISEL-NEXT:    v_add_f32_e32 v3, 0x41800000, v38087; VI-GISEL-NEXT:    flat_store_dword v[0:1], v28088; VI-GISEL-NEXT:    flat_store_dword v[0:1], v38089; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)8090; VI-GISEL-NEXT:    s_endpgm8091;8092; GFX9-LABEL: one_non_inline_constant:8093; GFX9:       ; %bb.0:8094; GFX9-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248095; GFX9-NEXT:    v_lshlrev_b32_e32 v0, 2, v08096; GFX9-NEXT:    v_mov_b32_e32 v2, 0x418000008097; GFX9-NEXT:    s_waitcnt lgkmcnt(0)8098; GFX9-NEXT:    global_load_dword v1, v0, s[2:3]8099; GFX9-NEXT:    s_waitcnt vmcnt(0)8100; GFX9-NEXT:    v_add_f32_e32 v3, 0.5, v18101; GFX9-NEXT:    v_add_f32_e32 v1, 0x41800000, v18102; GFX9-NEXT:    v_med3_f32 v2, v3, 1.0, v28103; GFX9-NEXT:    global_store_dword v0, v2, s[0:1]8104; GFX9-NEXT:    global_store_dword v[0:1], v1, off8105; GFX9-NEXT:    s_waitcnt vmcnt(0)8106; GFX9-NEXT:    s_endpgm8107;8108; GFX11-LABEL: one_non_inline_constant:8109; GFX11:       ; %bb.0:8110; GFX11-NEXT:    s_load_b128 s[0:3], s[4:5], 0x248111; GFX11-NEXT:    v_and_b32_e32 v0, 0x3ff, v08112; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8113; GFX11-NEXT:    v_lshlrev_b32_e32 v0, 2, v08114; GFX11-NEXT:    s_waitcnt lgkmcnt(0)8115; GFX11-NEXT:    global_load_b32 v1, v0, s[2:3]8116; GFX11-NEXT:    s_waitcnt vmcnt(0)8117; GFX11-NEXT:    v_add_f32_e32 v2, 0.5, v18118; GFX11-NEXT:    v_add_f32_e32 v1, 0x41800000, v18119; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_2)8120; GFX11-NEXT:    v_med3_f32 v2, v2, 1.0, 0x418000008121; GFX11-NEXT:    global_store_b32 v0, v2, s[0:1]8122; GFX11-NEXT:    global_store_b32 v[0:1], v1, off dlc8123; GFX11-NEXT:    s_waitcnt_vscnt null, 0x08124; GFX11-NEXT:    s_endpgm8125  %tid = call i32 @llvm.amdgcn.workitem.id.x()8126  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid8127  %out.gep = getelementptr float, ptr addrspace(1) %out, i32 %tid8128  %a = load float, ptr addrspace(1) %gep08129  %add = fadd nnan float %a, 0.58130  %max = call float @llvm.maxnum.f32(float %add, float 1.0)8131  %med = call float @llvm.minnum.f32(float %max, float 16.0)8132 8133  store float %med, ptr addrspace(1) %out.gep8134 8135  %extra.use = fadd float %a, 16.08136  store volatile float %extra.use, ptr addrspace(1) poison8137  ret void8138}8139 8140define amdgpu_kernel void @two_non_inline_constant_multi_use(ptr addrspace(1) %out, ptr addrspace(1) %aptr) {8141; SI-SDAG-LABEL: two_non_inline_constant_multi_use:8142; SI-SDAG:       ; %bb.0:8143; SI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x98144; SI-SDAG-NEXT:    s_mov_b32 s6, 08145; SI-SDAG-NEXT:    s_mov_b32 s7, 0xf0008146; SI-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v08147; SI-SDAG-NEXT:    v_mov_b32_e32 v1, 08148; SI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8149; SI-SDAG-NEXT:    s_mov_b64 s[4:5], s[2:3]8150; SI-SDAG-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr648151; SI-SDAG-NEXT:    s_mov_b32 s4, 0x410000008152; SI-SDAG-NEXT:    v_mov_b32_e32 v3, 0x418000008153; SI-SDAG-NEXT:    s_mov_b64 s[2:3], s[6:7]8154; SI-SDAG-NEXT:    s_mov_b32 s6, -18155; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)8156; SI-SDAG-NEXT:    v_add_f32_e32 v4, 0.5, v28157; SI-SDAG-NEXT:    v_add_f32_e32 v5, 0x41800000, v28158; SI-SDAG-NEXT:    v_add_f32_e32 v2, 0x41000000, v28159; SI-SDAG-NEXT:    v_med3_f32 v3, v4, s4, v38160; SI-SDAG-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr648161; SI-SDAG-NEXT:    buffer_store_dword v5, off, s[4:7], 08162; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)8163; SI-SDAG-NEXT:    buffer_store_dword v2, off, s[4:7], 08164; SI-SDAG-NEXT:    s_waitcnt vmcnt(0)8165; SI-SDAG-NEXT:    s_endpgm8166;8167; SI-GISEL-LABEL: two_non_inline_constant_multi_use:8168; SI-GISEL:       ; %bb.0:8169; SI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x98170; SI-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v08171; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 08172; SI-GISEL-NEXT:    s_mov_b32 s6, 08173; SI-GISEL-NEXT:    s_mov_b32 s7, 0xf0008174; SI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8175; SI-GISEL-NEXT:    s_mov_b64 s[4:5], s[2:3]8176; SI-GISEL-NEXT:    buffer_load_dword v2, v[0:1], s[4:7], 0 addr648177; SI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x410000008178; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x418000008179; SI-GISEL-NEXT:    s_mov_b64 s[2:3], s[6:7]8180; SI-GISEL-NEXT:    s_mov_b32 s6, -18181; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)8182; SI-GISEL-NEXT:    v_add_f32_e32 v5, 0.5, v28183; SI-GISEL-NEXT:    v_add_f32_e32 v6, 0x41800000, v28184; SI-GISEL-NEXT:    v_add_f32_e32 v2, 0x41000000, v28185; SI-GISEL-NEXT:    v_med3_f32 v3, v5, v3, v48186; SI-GISEL-NEXT:    buffer_store_dword v3, v[0:1], s[0:3], 0 addr648187; SI-GISEL-NEXT:    buffer_store_dword v6, off, s[4:7], 08188; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)8189; SI-GISEL-NEXT:    buffer_store_dword v2, off, s[4:7], 08190; SI-GISEL-NEXT:    s_waitcnt vmcnt(0)8191; SI-GISEL-NEXT:    s_endpgm8192;8193; VI-SDAG-LABEL: two_non_inline_constant_multi_use:8194; VI-SDAG:       ; %bb.0:8195; VI-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248196; VI-SDAG-NEXT:    v_lshlrev_b32_e32 v2, 2, v08197; VI-SDAG-NEXT:    v_mov_b32_e32 v4, 0x418000008198; VI-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8199; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s38200; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s2, v28201; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8202; VI-SDAG-NEXT:    flat_load_dword v3, v[0:1]8203; VI-SDAG-NEXT:    s_mov_b32 s2, 0x410000008204; VI-SDAG-NEXT:    v_mov_b32_e32 v1, s18205; VI-SDAG-NEXT:    v_add_u32_e32 v0, vcc, s0, v28206; VI-SDAG-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8207; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)8208; VI-SDAG-NEXT:    v_add_f32_e32 v2, 0.5, v38209; VI-SDAG-NEXT:    v_med3_f32 v2, v2, s2, v48210; VI-SDAG-NEXT:    v_add_f32_e32 v5, 0x41800000, v38211; VI-SDAG-NEXT:    v_add_f32_e32 v3, 0x41000000, v38212; VI-SDAG-NEXT:    flat_store_dword v[0:1], v28213; VI-SDAG-NEXT:    flat_store_dword v[0:1], v58214; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)8215; VI-SDAG-NEXT:    flat_store_dword v[0:1], v38216; VI-SDAG-NEXT:    s_waitcnt vmcnt(0)8217; VI-SDAG-NEXT:    s_endpgm8218;8219; VI-GISEL-LABEL: two_non_inline_constant_multi_use:8220; VI-GISEL:       ; %bb.0:8221; VI-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248222; VI-GISEL-NEXT:    v_lshlrev_b32_e32 v2, 2, v08223; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x410000008224; VI-GISEL-NEXT:    v_mov_b32_e32 v5, 0x418000008225; VI-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8226; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s28227; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s38228; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v28229; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8230; VI-GISEL-NEXT:    flat_load_dword v3, v[0:1]8231; VI-GISEL-NEXT:    v_mov_b32_e32 v0, s08232; VI-GISEL-NEXT:    v_mov_b32_e32 v1, s18233; VI-GISEL-NEXT:    v_add_u32_e32 v0, vcc, v0, v28234; VI-GISEL-NEXT:    v_addc_u32_e32 v1, vcc, 0, v1, vcc8235; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)8236; VI-GISEL-NEXT:    v_add_f32_e32 v2, 0.5, v38237; VI-GISEL-NEXT:    v_med3_f32 v2, v2, v4, v58238; VI-GISEL-NEXT:    v_add_f32_e32 v6, 0x41800000, v38239; VI-GISEL-NEXT:    v_add_f32_e32 v3, 0x41000000, v38240; VI-GISEL-NEXT:    flat_store_dword v[0:1], v28241; VI-GISEL-NEXT:    flat_store_dword v[0:1], v68242; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)8243; VI-GISEL-NEXT:    flat_store_dword v[0:1], v38244; VI-GISEL-NEXT:    s_waitcnt vmcnt(0)8245; VI-GISEL-NEXT:    s_endpgm8246;8247; GFX9-SDAG-LABEL: two_non_inline_constant_multi_use:8248; GFX9-SDAG:       ; %bb.0:8249; GFX9-SDAG-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248250; GFX9-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v08251; GFX9-SDAG-NEXT:    v_mov_b32_e32 v2, 0x418000008252; GFX9-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8253; GFX9-SDAG-NEXT:    global_load_dword v1, v0, s[2:3]8254; GFX9-SDAG-NEXT:    s_mov_b32 s2, 0x410000008255; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)8256; GFX9-SDAG-NEXT:    v_add_f32_e32 v3, 0.5, v18257; GFX9-SDAG-NEXT:    v_add_f32_e32 v4, 0x41800000, v18258; GFX9-SDAG-NEXT:    v_add_f32_e32 v1, 0x41000000, v18259; GFX9-SDAG-NEXT:    v_med3_f32 v2, v3, s2, v28260; GFX9-SDAG-NEXT:    global_store_dword v0, v2, s[0:1]8261; GFX9-SDAG-NEXT:    global_store_dword v[0:1], v4, off8262; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)8263; GFX9-SDAG-NEXT:    global_store_dword v[0:1], v1, off8264; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0)8265; GFX9-SDAG-NEXT:    s_endpgm8266;8267; GFX9-GISEL-LABEL: two_non_inline_constant_multi_use:8268; GFX9-GISEL:       ; %bb.0:8269; GFX9-GISEL-NEXT:    s_load_dwordx4 s[0:3], s[4:5], 0x248270; GFX9-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v08271; GFX9-GISEL-NEXT:    v_mov_b32_e32 v2, 0x410000008272; GFX9-GISEL-NEXT:    v_mov_b32_e32 v3, 0x418000008273; GFX9-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8274; GFX9-GISEL-NEXT:    global_load_dword v1, v0, s[2:3]8275; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)8276; GFX9-GISEL-NEXT:    v_add_f32_e32 v4, 0.5, v18277; GFX9-GISEL-NEXT:    v_add_f32_e32 v5, 0x41800000, v18278; GFX9-GISEL-NEXT:    v_add_f32_e32 v1, 0x41000000, v18279; GFX9-GISEL-NEXT:    v_med3_f32 v2, v4, v2, v38280; GFX9-GISEL-NEXT:    global_store_dword v0, v2, s[0:1]8281; GFX9-GISEL-NEXT:    global_store_dword v[0:1], v5, off8282; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)8283; GFX9-GISEL-NEXT:    global_store_dword v[0:1], v1, off8284; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0)8285; GFX9-GISEL-NEXT:    s_endpgm8286;8287; GFX11-SDAG-LABEL: two_non_inline_constant_multi_use:8288; GFX11-SDAG:       ; %bb.0:8289; GFX11-SDAG-NEXT:    s_load_b128 s[0:3], s[4:5], 0x248290; GFX11-SDAG-NEXT:    v_and_b32_e32 v0, 0x3ff, v08291; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)8292; GFX11-SDAG-NEXT:    v_lshlrev_b32_e32 v0, 2, v08293; GFX11-SDAG-NEXT:    s_waitcnt lgkmcnt(0)8294; GFX11-SDAG-NEXT:    global_load_b32 v1, v0, s[2:3]8295; GFX11-SDAG-NEXT:    s_mov_b32 s2, 0x410000008296; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0)8297; GFX11-SDAG-NEXT:    v_add_f32_e32 v2, 0.5, v18298; GFX11-SDAG-NEXT:    v_add_f32_e32 v3, 0x41800000, v18299; GFX11-SDAG-NEXT:    v_add_f32_e32 v1, 0x41000000, v18300; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_3)8301; GFX11-SDAG-NEXT:    v_med3_f32 v2, v2, s2, 0x418000008302; GFX11-SDAG-NEXT:    global_store_b32 v0, v2, s[0:1]8303; GFX11-SDAG-NEXT:    global_store_b32 v[0:1], v3, off dlc8304; GFX11-SDAG-NEXT:    s_waitcnt_vscnt null, 0x08305; GFX11-SDAG-NEXT:    global_store_b32 v[0:1], v1, off dlc8306; GFX11-SDAG-NEXT:    s_waitcnt_vscnt null, 0x08307; GFX11-SDAG-NEXT:    s_endpgm8308;8309; GFX11-GISEL-LABEL: two_non_inline_constant_multi_use:8310; GFX11-GISEL:       ; %bb.0:8311; GFX11-GISEL-NEXT:    s_load_b128 s[0:3], s[4:5], 0x248312; GFX11-GISEL-NEXT:    v_and_b32_e32 v0, 0x3ff, v08313; GFX11-GISEL-NEXT:    v_mov_b32_e32 v2, 0x418000008314; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)8315; GFX11-GISEL-NEXT:    v_lshlrev_b32_e32 v0, 2, v08316; GFX11-GISEL-NEXT:    s_waitcnt lgkmcnt(0)8317; GFX11-GISEL-NEXT:    global_load_b32 v1, v0, s[2:3]8318; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0)8319; GFX11-GISEL-NEXT:    v_add_f32_e32 v3, 0.5, v18320; GFX11-GISEL-NEXT:    v_med3_f32 v2, v3, 0x41000000, v28321; GFX11-GISEL-NEXT:    v_add_f32_e32 v3, 0x41800000, v18322; GFX11-GISEL-NEXT:    v_add_f32_e32 v1, 0x41000000, v18323; GFX11-GISEL-NEXT:    global_store_b32 v0, v2, s[0:1]8324; GFX11-GISEL-NEXT:    global_store_b32 v[0:1], v3, off dlc8325; GFX11-GISEL-NEXT:    s_waitcnt_vscnt null, 0x08326; GFX11-GISEL-NEXT:    global_store_b32 v[0:1], v1, off dlc8327; GFX11-GISEL-NEXT:    s_waitcnt_vscnt null, 0x08328; GFX11-GISEL-NEXT:    s_endpgm8329  %tid = call i32 @llvm.amdgcn.workitem.id.x()8330  %gep0 = getelementptr float, ptr addrspace(1) %aptr, i32 %tid8331  %out.gep = getelementptr float, ptr addrspace(1) %out, i32 %tid8332  %a = load float, ptr addrspace(1) %gep08333  %add = fadd nnan float %a, 0.58334  %max = call float @llvm.maxnum.f32(float %add, float 8.0)8335  %med = call float @llvm.minnum.f32(float %max, float 16.0)8336 8337  store float %med, ptr addrspace(1) %out.gep8338 8339  %extra.use0 = fadd float %a, 16.08340  store volatile float %extra.use0, ptr addrspace(1) poison8341  %extra.use1 = fadd float %a, 8.08342  store volatile float %extra.use1, ptr addrspace(1) poison8343  ret void8344}8345 8346define float @v_test_fmed3_r_i_i_f32_minimumnum_maximumnum(float %a) {8347; SI-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum:8348; SI:       ; %bb.0:8349; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8350; SI-NEXT:    v_mul_f32_e32 v0, 1.0, v08351; SI-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08352; SI-NEXT:    s_setpc_b64 s[30:31]8353;8354; VI-SDAG-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum:8355; VI-SDAG:       ; %bb.0:8356; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8357; VI-SDAG-NEXT:    v_mul_f32_e32 v0, 1.0, v08358; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08359; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8360;8361; VI-GISEL-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum:8362; VI-GISEL:       ; %bb.0:8363; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8364; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 1.0, v08365; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08366; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8367;8368; GFX9-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum:8369; GFX9:       ; %bb.0:8370; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8371; GFX9-NEXT:    v_max_f32_e32 v0, v0, v08372; GFX9-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08373; GFX9-NEXT:    s_setpc_b64 s[30:31]8374;8375; GFX11-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum:8376; GFX11:       ; %bb.0:8377; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8378; GFX11-NEXT:    v_max_f32_e32 v0, v0, v08379; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8380; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08381; GFX11-NEXT:    s_setpc_b64 s[30:31]8382  %max = call float @llvm.maximumnum.f32(float %a, float 2.0)8383  %med = call float @llvm.minimumnum.f32(float %max, float 4.0)8384  ret float %med8385}8386 8387define <2 x float> @v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum(<2 x float> %a) {8388; SI-SDAG-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8389; SI-SDAG:       ; %bb.0:8390; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8391; SI-SDAG-NEXT:    v_mul_f32_e32 v1, 1.0, v18392; SI-SDAG-NEXT:    v_mul_f32_e32 v0, 1.0, v08393; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08394; SI-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08395; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8396;8397; SI-GISEL-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8398; SI-GISEL:       ; %bb.0:8399; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8400; SI-GISEL-NEXT:    v_mul_f32_e32 v0, 1.0, v08401; SI-GISEL-NEXT:    v_mul_f32_e32 v1, 1.0, v18402; SI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08403; SI-GISEL-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08404; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]8405;8406; VI-SDAG-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8407; VI-SDAG:       ; %bb.0:8408; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8409; VI-SDAG-NEXT:    v_mul_f32_e32 v1, 1.0, v18410; VI-SDAG-NEXT:    v_mul_f32_e32 v0, 1.0, v08411; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08412; VI-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08413; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8414;8415; VI-GISEL-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8416; VI-GISEL:       ; %bb.0:8417; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8418; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 1.0, v08419; VI-GISEL-NEXT:    v_mul_f32_e32 v1, 1.0, v18420; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08421; VI-GISEL-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08422; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8423;8424; GFX9-SDAG-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8425; GFX9-SDAG:       ; %bb.0:8426; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8427; GFX9-SDAG-NEXT:    v_max_f32_e32 v1, v1, v18428; GFX9-SDAG-NEXT:    v_max_f32_e32 v0, v0, v08429; GFX9-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08430; GFX9-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08431; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]8432;8433; GFX9-GISEL-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8434; GFX9-GISEL:       ; %bb.0:8435; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8436; GFX9-GISEL-NEXT:    v_max_f32_e32 v0, v0, v08437; GFX9-GISEL-NEXT:    v_max_f32_e32 v1, v1, v18438; GFX9-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08439; GFX9-GISEL-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08440; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]8441;8442; GFX11-LABEL: v_test_fmed3_r_i_i_v2f32_minimumnum_maximumnum:8443; GFX11:       ; %bb.0:8444; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8445; GFX11-NEXT:    v_dual_max_f32 v0, v0, v0 :: v_dual_max_f32 v1, v1, v18446; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)8447; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08448; GFX11-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08449; GFX11-NEXT:    s_setpc_b64 s[30:31]8450  %max = call <2 x float> @llvm.maximumnum.v2f32(<2 x float> %a, <2 x float> splat (float 2.0))8451  %med = call <2 x float> @llvm.minimumnum.v2f32(<2 x float> %max, <2 x float> splat (float 4.0))8452  ret <2 x float> %med8453}8454 8455define { float, float } @v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use(float %a) {8456; SI-SDAG-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8457; SI-SDAG:       ; %bb.0:8458; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8459; SI-SDAG-NEXT:    v_mul_f32_e32 v0, 1.0, v08460; SI-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v08461; SI-SDAG-NEXT:    v_min_f32_e32 v0, 4.0, v18462; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8463;8464; SI-GISEL-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8465; SI-GISEL:       ; %bb.0:8466; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8467; SI-GISEL-NEXT:    v_mul_f32_e32 v0, 1.0, v08468; SI-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08469; SI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08470; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]8471;8472; VI-SDAG-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8473; VI-SDAG:       ; %bb.0:8474; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8475; VI-SDAG-NEXT:    v_mul_f32_e32 v0, 1.0, v08476; VI-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v08477; VI-SDAG-NEXT:    v_min_f32_e32 v0, 4.0, v18478; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8479;8480; VI-GISEL-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8481; VI-GISEL:       ; %bb.0:8482; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8483; VI-GISEL-NEXT:    v_mul_f32_e32 v0, 1.0, v08484; VI-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08485; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08486; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8487;8488; GFX9-SDAG-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8489; GFX9-SDAG:       ; %bb.0:8490; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8491; GFX9-SDAG-NEXT:    v_max_f32_e32 v0, v0, v08492; GFX9-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v08493; GFX9-SDAG-NEXT:    v_min_f32_e32 v0, 4.0, v18494; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]8495;8496; GFX9-GISEL-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8497; GFX9-GISEL:       ; %bb.0:8498; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8499; GFX9-GISEL-NEXT:    v_max_f32_e32 v0, v0, v08500; GFX9-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08501; GFX9-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08502; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]8503;8504; GFX11-SDAG-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8505; GFX11-SDAG:       ; %bb.0:8506; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8507; GFX11-SDAG-NEXT:    v_max_f32_e32 v0, v0, v08508; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)8509; GFX11-SDAG-NEXT:    v_max_f32_e32 v1, 2.0, v08510; GFX11-SDAG-NEXT:    v_min_f32_e32 v0, 4.0, v18511; GFX11-SDAG-NEXT:    s_setpc_b64 s[30:31]8512;8513; GFX11-GISEL-LABEL: v_test_fmed3_r_i_i_f32_minimumnum_maximumnum_multi_use:8514; GFX11-GISEL:       ; %bb.0:8515; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8516; GFX11-GISEL-NEXT:    v_max_f32_e32 v1, v0, v08517; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1)8518; GFX11-GISEL-NEXT:    v_med3_f32 v0, v1, 2.0, 4.08519; GFX11-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v18520; GFX11-GISEL-NEXT:    s_setpc_b64 s[30:31]8521  %max = call float @llvm.maximumnum.f32(float %a, float 2.0)8522  %med = call float @llvm.minimumnum.f32(float %max, float 4.0)8523  %ins.0 = insertvalue { float, float } poison, float %med, 08524  %ins.1 = insertvalue { float, float } %ins.0, float %max, 18525  ret { float, float } %ins.18526}8527 8528define float @v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum(float %a) {8529; SI-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum:8530; SI:       ; %bb.0:8531; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8532; SI-NEXT:    v_add_f32_e32 v0, 1.0, v08533; SI-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08534; SI-NEXT:    s_setpc_b64 s[30:31]8535;8536; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum:8537; VI-SDAG:       ; %bb.0:8538; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8539; VI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08540; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08541; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8542;8543; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum:8544; VI-GISEL:       ; %bb.0:8545; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8546; VI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08547; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08548; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8549;8550; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum:8551; GFX9:       ; %bb.0:8552; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8553; GFX9-NEXT:    v_add_f32_e32 v0, 1.0, v08554; GFX9-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08555; GFX9-NEXT:    s_setpc_b64 s[30:31]8556;8557; GFX11-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_minimumnum_maximumnum:8558; GFX11:       ; %bb.0:8559; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8560; GFX11-NEXT:    v_add_f32_e32 v0, 1.0, v08561; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8562; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08563; GFX11-NEXT:    s_setpc_b64 s[30:31]8564  %a.add = fadd nnan float %a, 1.08565  %max = call float @llvm.maximumnum.f32(float %a.add, float 2.0)8566  %med = call float @llvm.minimumnum.f32(float %max, float 4.0)8567  ret float %med8568}8569 8570define float @v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum(float %a) {8571; SI-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum:8572; SI:       ; %bb.0:8573; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8574; SI-NEXT:    v_add_f32_e32 v0, 1.0, v08575; SI-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08576; SI-NEXT:    s_setpc_b64 s[30:31]8577;8578; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum:8579; VI-SDAG:       ; %bb.0:8580; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8581; VI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08582; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08583; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8584;8585; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum:8586; VI-GISEL:       ; %bb.0:8587; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8588; VI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08589; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08590; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8591;8592; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum:8593; GFX9:       ; %bb.0:8594; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8595; GFX9-NEXT:    v_add_f32_e32 v0, 1.0, v08596; GFX9-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08597; GFX9-NEXT:    s_setpc_b64 s[30:31]8598;8599; GFX11-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minimumnum:8600; GFX11:       ; %bb.0:8601; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8602; GFX11-NEXT:    v_add_f32_e32 v0, 1.0, v08603; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8604; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08605; GFX11-NEXT:    s_setpc_b64 s[30:31]8606  %a.add = fadd nnan float %a, 1.08607  %max = call float @llvm.maximumnum.f32(float %a.add, float 2.0)8608  %med = call float @llvm.minimumnum.f32(float %max, float 4.0)8609  ret float %med8610}8611 8612define float @v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum(float %a) {8613; SI-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum:8614; SI:       ; %bb.0:8615; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8616; SI-NEXT:    v_add_f32_e32 v0, 1.0, v08617; SI-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08618; SI-NEXT:    s_setpc_b64 s[30:31]8619;8620; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum:8621; VI-SDAG:       ; %bb.0:8622; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8623; VI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08624; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08625; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8626;8627; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum:8628; VI-GISEL:       ; %bb.0:8629; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8630; VI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08631; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08632; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8633;8634; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum:8635; GFX9:       ; %bb.0:8636; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8637; GFX9-NEXT:    v_add_f32_e32 v0, 1.0, v08638; GFX9-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08639; GFX9-NEXT:    s_setpc_b64 s[30:31]8640;8641; GFX11-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maxnum_minimumnum:8642; GFX11:       ; %bb.0:8643; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8644; GFX11-NEXT:    v_add_f32_e32 v0, 1.0, v08645; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8646; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08647; GFX11-NEXT:    s_setpc_b64 s[30:31]8648  %a.add = fadd nnan float %a, 1.08649  %max = call float @llvm.maxnum.f32(float %a.add, float 2.0)8650  %med = call float @llvm.minimumnum.f32(float %max, float 4.0)8651  ret float %med8652}8653 8654define float @v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum(float %a) {8655; SI-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum:8656; SI:       ; %bb.0:8657; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8658; SI-NEXT:    v_add_f32_e32 v0, 1.0, v08659; SI-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08660; SI-NEXT:    s_setpc_b64 s[30:31]8661;8662; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum:8663; VI-SDAG:       ; %bb.0:8664; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8665; VI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08666; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08667; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8668;8669; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum:8670; VI-GISEL:       ; %bb.0:8671; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8672; VI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08673; VI-GISEL-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08674; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8675;8676; GFX9-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum:8677; GFX9:       ; %bb.0:8678; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8679; GFX9-NEXT:    v_add_f32_e32 v0, 1.0, v08680; GFX9-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08681; GFX9-NEXT:    s_setpc_b64 s[30:31]8682;8683; GFX11-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximumnum_minnum:8684; GFX11:       ; %bb.0:8685; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8686; GFX11-NEXT:    v_add_f32_e32 v0, 1.0, v08687; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1)8688; GFX11-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08689; GFX11-NEXT:    s_setpc_b64 s[30:31]8690  %a.add = fadd nnan float %a, 1.08691  %max = call float @llvm.maximumnum.f32(float %a.add, float 2.0)8692  %med = call float @llvm.minnum.f32(float %max, float 4.0)8693  ret float %med8694}8695 8696define half @v_test_fmed3_r_i_i_f16_minimumnum_maximumnum(half %a) {8697; SI-SDAG-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8698; SI-SDAG:       ; %bb.0:8699; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8700; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v0, v08701; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v0, v08702; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08703; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8704;8705; SI-GISEL-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8706; SI-GISEL:       ; %bb.0:8707; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8708; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v08709; SI-GISEL-NEXT:    v_max_f32_e32 v0, 2.0, v08710; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v08711; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v08712; SI-GISEL-NEXT:    v_min_f32_e32 v0, 4.0, v08713; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v08714; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]8715;8716; VI-SDAG-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8717; VI-SDAG:       ; %bb.0:8718; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8719; VI-SDAG-NEXT:    v_max_f16_e32 v0, v0, v08720; VI-SDAG-NEXT:    v_max_f16_e32 v0, 2.0, v08721; VI-SDAG-NEXT:    v_min_f16_e32 v0, 4.0, v08722; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8723;8724; VI-GISEL-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8725; VI-GISEL:       ; %bb.0:8726; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8727; VI-GISEL-NEXT:    v_max_f16_e32 v0, v0, v08728; VI-GISEL-NEXT:    v_max_f16_e32 v0, 2.0, v08729; VI-GISEL-NEXT:    v_min_f16_e32 v0, 4.0, v08730; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8731;8732; GFX9-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8733; GFX9:       ; %bb.0:8734; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8735; GFX9-NEXT:    v_max_f16_e32 v0, v0, v08736; GFX9-NEXT:    v_med3_f16 v0, v0, 2.0, 4.08737; GFX9-NEXT:    s_setpc_b64 s[30:31]8738;8739; GFX11-SDAG-FAKE16-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8740; GFX11-SDAG-FAKE16:       ; %bb.0:8741; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8742; GFX11-SDAG-FAKE16-NEXT:    v_max_f16_e32 v0, v0, v08743; GFX11-SDAG-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)8744; GFX11-SDAG-FAKE16-NEXT:    v_med3_f16 v0, v0, 2.0, 4.08745; GFX11-SDAG-FAKE16-NEXT:    s_setpc_b64 s[30:31]8746;8747; GFX11-GISEL-FAKE16-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8748; GFX11-GISEL-FAKE16:       ; %bb.0:8749; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8750; GFX11-GISEL-FAKE16-NEXT:    v_max_f16_e32 v0, v0, v08751; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)8752; GFX11-GISEL-FAKE16-NEXT:    v_med3_f16 v0, v0, 2.0, 4.08753; GFX11-GISEL-FAKE16-NEXT:    s_setpc_b64 s[30:31]8754;8755; GFX11-SDAG-TRUE16-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8756; GFX11-SDAG-TRUE16:       ; %bb.0:8757; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8758; GFX11-SDAG-TRUE16-NEXT:    v_max_f16_e32 v0.l, v0.l, v0.l8759; GFX11-SDAG-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)8760; GFX11-SDAG-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, 2.0, 4.08761; GFX11-SDAG-TRUE16-NEXT:    s_setpc_b64 s[30:31]8762;8763; GFX11-GISEL-TRUE16-LABEL: v_test_fmed3_r_i_i_f16_minimumnum_maximumnum:8764; GFX11-GISEL-TRUE16:       ; %bb.0:8765; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8766; GFX11-GISEL-TRUE16-NEXT:    v_max_f16_e32 v0.l, v0.l, v0.l8767; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)8768; GFX11-GISEL-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, 2.0, 4.08769; GFX11-GISEL-TRUE16-NEXT:    s_setpc_b64 s[30:31]8770  %max = call half @llvm.maximumnum.f16(half %a, half 2.0)8771  %med = call half @llvm.minimumnum.f16(half %max, half 4.0)8772  ret half %med8773}8774 8775define <2 x half> @v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum(<2 x half> %a) {8776; SI-SDAG-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8777; SI-SDAG:       ; %bb.0:8778; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8779; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v0, v08780; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v1, v18781; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v0, v08782; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v1, v18783; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08784; SI-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08785; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8786;8787; SI-GISEL-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8788; SI-GISEL:       ; %bb.0:8789; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8790; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v08791; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v18792; SI-GISEL-NEXT:    v_max_f32_e32 v0, 2.0, v08793; SI-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v18794; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v08795; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v18796; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v08797; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v18798; SI-GISEL-NEXT:    v_min_f32_e32 v0, 4.0, v08799; SI-GISEL-NEXT:    v_min_f32_e32 v1, 4.0, v18800; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v08801; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v18802; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]8803;8804; VI-SDAG-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8805; VI-SDAG:       ; %bb.0:8806; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8807; VI-SDAG-NEXT:    v_max_f16_sdwa v1, v0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_18808; VI-SDAG-NEXT:    v_max_f16_e32 v0, v0, v08809; VI-SDAG-NEXT:    v_max_f16_e32 v1, 2.0, v18810; VI-SDAG-NEXT:    v_max_f16_e32 v0, 2.0, v08811; VI-SDAG-NEXT:    v_mov_b32_e32 v2, 0x44008812; VI-SDAG-NEXT:    v_min_f16_e32 v0, 4.0, v08813; VI-SDAG-NEXT:    v_min_f16_sdwa v1, v1, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD8814; VI-SDAG-NEXT:    v_or_b32_e32 v0, v0, v18815; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8816;8817; VI-GISEL-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8818; VI-GISEL:       ; %bb.0:8819; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8820; VI-GISEL-NEXT:    v_max_f16_e32 v1, v0, v08821; VI-GISEL-NEXT:    v_max_f16_sdwa v0, v0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_18822; VI-GISEL-NEXT:    v_max_f16_e32 v1, 2.0, v18823; VI-GISEL-NEXT:    v_max_f16_e32 v0, 2.0, v08824; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x44008825; VI-GISEL-NEXT:    v_min_f16_e32 v1, 4.0, v18826; VI-GISEL-NEXT:    v_min_f16_sdwa v0, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD8827; VI-GISEL-NEXT:    v_or_b32_e32 v0, v1, v08828; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8829;8830; GFX9-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8831; GFX9:       ; %bb.0:8832; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8833; GFX9-NEXT:    v_pk_max_f16 v0, v0, v08834; GFX9-NEXT:    v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0]8835; GFX9-NEXT:    v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0]8836; GFX9-NEXT:    s_setpc_b64 s[30:31]8837;8838; GFX11-LABEL: v_test_fmed3_r_i_i_v2f16_minimumnum_maximumnum:8839; GFX11:       ; %bb.0:8840; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8841; GFX11-NEXT:    v_pk_max_f16 v0, v0, v08842; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)8843; GFX11-NEXT:    v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0]8844; GFX11-NEXT:    v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0]8845; GFX11-NEXT:    s_setpc_b64 s[30:31]8846  %max = call <2 x half> @llvm.maximumnum.v2f16(<2 x half> %a, <2 x half> splat (half 2.0))8847  %med = call <2 x half> @llvm.minimumnum.v2f16(<2 x half> %max, <2 x half> splat (half 4.0))8848  ret <2 x half> %med8849}8850 8851define double @v_test_fmed3_r_i_i_f64_minimumnum_maximumnum(double %a) {8852; SI-LABEL: v_test_fmed3_r_i_i_f64_minimumnum_maximumnum:8853; SI:       ; %bb.0:8854; SI-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8855; SI-NEXT:    v_max_f64 v[0:1], v[0:1], v[0:1]8856; SI-NEXT:    v_max_f64 v[0:1], v[0:1], 2.08857; SI-NEXT:    v_min_f64 v[0:1], v[0:1], 4.08858; SI-NEXT:    s_setpc_b64 s[30:31]8859;8860; VI-SDAG-LABEL: v_test_fmed3_r_i_i_f64_minimumnum_maximumnum:8861; VI-SDAG:       ; %bb.0:8862; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8863; VI-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], v[0:1]8864; VI-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.08865; VI-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.08866; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8867;8868; VI-GISEL-LABEL: v_test_fmed3_r_i_i_f64_minimumnum_maximumnum:8869; VI-GISEL:       ; %bb.0:8870; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8871; VI-GISEL-NEXT:    v_max_f64 v[0:1], v[0:1], v[0:1]8872; VI-GISEL-NEXT:    v_max_f64 v[0:1], v[0:1], 2.08873; VI-GISEL-NEXT:    v_min_f64 v[0:1], v[0:1], 4.08874; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8875;8876; GFX9-LABEL: v_test_fmed3_r_i_i_f64_minimumnum_maximumnum:8877; GFX9:       ; %bb.0:8878; GFX9-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8879; GFX9-NEXT:    v_max_f64 v[0:1], v[0:1], v[0:1]8880; GFX9-NEXT:    v_max_f64 v[0:1], v[0:1], 2.08881; GFX9-NEXT:    v_min_f64 v[0:1], v[0:1], 4.08882; GFX9-NEXT:    s_setpc_b64 s[30:31]8883;8884; GFX11-LABEL: v_test_fmed3_r_i_i_f64_minimumnum_maximumnum:8885; GFX11:       ; %bb.0:8886; GFX11-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8887; GFX11-NEXT:    v_max_f64 v[0:1], v[0:1], v[0:1]8888; GFX11-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)8889; GFX11-NEXT:    v_max_f64 v[0:1], v[0:1], 2.08890; GFX11-NEXT:    v_min_f64 v[0:1], v[0:1], 4.08891; GFX11-NEXT:    s_setpc_b64 s[30:31]8892  %max = call double @llvm.maximumnum.f64(double %a, double 2.0)8893  %med = call double @llvm.minimumnum.f64(double %max, double 4.0)8894  ret double %med8895}8896 8897define float @v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum(float %a) {8898; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8899; SI-SDAG:       ; %bb.0:8900; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8901; SI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08902; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08903; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8904;8905; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8906; SI-GISEL:       ; %bb.0:8907; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8908; SI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08909; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7fc000008910; SI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v08911; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v08912; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc8913; SI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v08914; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v08915; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc8916; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]8917;8918; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8919; VI-SDAG:       ; %bb.0:8920; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8921; VI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08922; VI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08923; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]8924;8925; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8926; VI-GISEL:       ; %bb.0:8927; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8928; VI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08929; VI-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08930; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7fc000008931; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v08932; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc8933; VI-GISEL-NEXT:    v_min_f32_e32 v1, 4.0, v08934; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v08935; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc8936; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]8937;8938; GFX9-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8939; GFX9-SDAG:       ; %bb.0:8940; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8941; GFX9-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08942; GFX9-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08943; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]8944;8945; GFX9-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8946; GFX9-GISEL:       ; %bb.0:8947; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8948; GFX9-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08949; GFX9-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08950; GFX9-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7fc000008951; GFX9-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v08952; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc8953; GFX9-GISEL-NEXT:    v_min_f32_e32 v1, 4.0, v08954; GFX9-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v08955; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc8956; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]8957;8958; GFX11-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8959; GFX11-SDAG:       ; %bb.0:8960; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8961; GFX11-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08962; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1)8963; GFX11-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08964; GFX11-SDAG-NEXT:    s_setpc_b64 s[30:31]8965;8966; GFX11-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f32_maximum_minimum:8967; GFX11-GISEL:       ; %bb.0:8968; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8969; GFX11-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v08970; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)8971; GFX11-GISEL-NEXT:    v_max_f32_e32 v1, 2.0, v08972; GFX11-GISEL-NEXT:    v_cmp_o_f32_e32 vcc_lo, 2.0, v08973; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0x7fc00000, v1, vcc_lo8974; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)8975; GFX11-GISEL-NEXT:    v_min_f32_e32 v1, 4.0, v08976; GFX11-GISEL-NEXT:    v_cmp_o_f32_e32 vcc_lo, 4.0, v08977; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0x7fc00000, v1, vcc_lo8978; GFX11-GISEL-NEXT:    s_setpc_b64 s[30:31]8979  %a.add = fadd nnan float %a, 1.08980  %max = call float @llvm.maximum.f32(float %a.add, float 2.0)8981  %med = call float @llvm.minimum.f32(float %max, float 4.0)8982  ret float %med8983}8984 8985define <2 x half> @v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum(<2 x half> %a) {8986; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:8987; SI-SDAG:       ; %bb.0:8988; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)8989; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v0, v08990; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v1, v18991; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v0, v08992; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v1, v18993; SI-SDAG-NEXT:    v_add_f32_e32 v1, 1.0, v18994; SI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v08995; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.08996; SI-SDAG-NEXT:    v_med3_f32 v1, v1, 2.0, 4.08997; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]8998;8999; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9000; SI-GISEL:       ; %bb.0:9001; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9002; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09003; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v19004; SI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7fc000009005; SI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v09006; SI-GISEL-NEXT:    v_add_f32_e32 v1, 1.0, v19007; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09008; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v19009; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09010; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v19011; SI-GISEL-NEXT:    v_max_f32_e32 v3, 2.0, v09012; SI-GISEL-NEXT:    v_max_f32_e32 v4, 2.0, v19013; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v09014; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v3, vcc9015; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v19016; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v2, v4, vcc9017; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09018; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v19019; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09020; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v19021; SI-GISEL-NEXT:    v_min_f32_e32 v3, 4.0, v09022; SI-GISEL-NEXT:    v_min_f32_e32 v4, 4.0, v19023; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v09024; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v3, vcc9025; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v19026; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v2, v4, vcc9027; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09028; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v19029; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]9030;9031; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9032; VI-SDAG:       ; %bb.0:9033; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9034; VI-SDAG-NEXT:    v_mov_b32_e32 v2, 0x3c009035; VI-SDAG-NEXT:    v_add_f16_e32 v1, 1.0, v09036; VI-SDAG-NEXT:    v_add_f16_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD9037; VI-SDAG-NEXT:    v_max_f16_e32 v0, 2.0, v09038; VI-SDAG-NEXT:    v_max_f16_e32 v1, 2.0, v19039; VI-SDAG-NEXT:    v_mov_b32_e32 v2, 0x44009040; VI-SDAG-NEXT:    v_min_f16_e32 v1, 4.0, v19041; VI-SDAG-NEXT:    v_min_f16_sdwa v0, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD9042; VI-SDAG-NEXT:    v_or_b32_e32 v0, v1, v09043; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]9044;9045; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9046; VI-GISEL:       ; %bb.0:9047; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9048; VI-GISEL-NEXT:    v_add_f16_e32 v1, 1.0, v09049; VI-GISEL-NEXT:    v_mov_b32_e32 v2, 0x3c009050; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v19051; VI-GISEL-NEXT:    v_add_f16_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD9052; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09053; VI-GISEL-NEXT:    v_mov_b32_e32 v3, 0x7fc000009054; VI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v19055; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v19056; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v3, v2, vcc9057; VI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v09058; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v09059; VI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v19060; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v3, v2, vcc9061; VI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09062; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v1, v19063; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09064; VI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v19065; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v19066; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v3, v2, vcc9067; VI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v09068; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v09069; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v3, v2, vcc9070; VI-GISEL-NEXT:    v_cvt_f16_f32_e32 v1, v19071; VI-GISEL-NEXT:    v_cvt_f16_f32_sdwa v0, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD9072; VI-GISEL-NEXT:    v_or_b32_e32 v0, v1, v09073; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]9074;9075; GFX9-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9076; GFX9-SDAG:       ; %bb.0:9077; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9078; GFX9-SDAG-NEXT:    v_pk_add_f16 v0, v0, 1.0 op_sel_hi:[1,0]9079; GFX9-SDAG-NEXT:    v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0]9080; GFX9-SDAG-NEXT:    v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0]9081; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]9082;9083; GFX9-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9084; GFX9-GISEL:       ; %bb.0:9085; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9086; GFX9-GISEL-NEXT:    v_pk_add_f16 v0, v0, 1.0 op_sel_hi:[1,0]9087; GFX9-GISEL-NEXT:    v_mov_b32_e32 v2, 0x40009088; GFX9-GISEL-NEXT:    v_pk_max_f16 v1, v0, 2.0 op_sel_hi:[1,0]9089; GFX9-GISEL-NEXT:    v_cmp_o_f16_sdwa vcc, v0, v2 src0_sel:WORD_1 src1_sel:DWORD9090; GFX9-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7e009091; GFX9-GISEL-NEXT:    v_cmp_o_f16_e64 s[4:5], 2.0, v09092; GFX9-GISEL-NEXT:    v_cndmask_b32_e64 v0, v2, v1, s[4:5]9093; GFX9-GISEL-NEXT:    v_cndmask_b32_sdwa v1, v2, v1, vcc dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_19094; GFX9-GISEL-NEXT:    v_and_b32_e32 v3, 0xffff, v09095; GFX9-GISEL-NEXT:    v_lshl_or_b32 v3, v1, 16, v39096; GFX9-GISEL-NEXT:    v_pk_min_f16 v3, v3, 4.0 op_sel_hi:[1,0]9097; GFX9-GISEL-NEXT:    v_cmp_o_f16_e64 s[4:5], 4.0, v09098; GFX9-GISEL-NEXT:    v_cmp_o_f16_e32 vcc, 4.0, v19099; GFX9-GISEL-NEXT:    v_cndmask_b32_e64 v0, v2, v3, s[4:5]9100; GFX9-GISEL-NEXT:    v_cndmask_b32_sdwa v1, v2, v3, vcc dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_19101; GFX9-GISEL-NEXT:    v_and_b32_e32 v0, 0xffff, v09102; GFX9-GISEL-NEXT:    v_lshl_or_b32 v0, v1, 16, v09103; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]9104;9105; GFX11-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9106; GFX11-SDAG:       ; %bb.0:9107; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9108; GFX11-SDAG-NEXT:    v_pk_add_f16 v0, v0, 1.0 op_sel_hi:[1,0]9109; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)9110; GFX11-SDAG-NEXT:    v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0]9111; GFX11-SDAG-NEXT:    v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0]9112; GFX11-SDAG-NEXT:    s_setpc_b64 s[30:31]9113;9114; GFX11-GISEL-FAKE16-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9115; GFX11-GISEL-FAKE16:       ; %bb.0:9116; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9117; GFX11-GISEL-FAKE16-NEXT:    v_pk_add_f16 v0, v0, 1.0 op_sel_hi:[1,0]9118; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)9119; GFX11-GISEL-FAKE16-NEXT:    v_pk_max_f16 v1, v0, 2.0 op_sel_hi:[1,0]9120; GFX11-GISEL-FAKE16-NEXT:    v_lshrrev_b32_e32 v2, 16, v09121; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 2.0, v09122; GFX11-GISEL-FAKE16-NEXT:    v_lshrrev_b32_e32 v3, 16, v19123; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v1, vcc_lo9124; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)9125; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 2.0, v29126; GFX11-GISEL-FAKE16-NEXT:    v_and_b32_e32 v2, 0xffff, v09127; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_2)9128; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v1, 0x7e00, v3, vcc_lo9129; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 4.0, v09130; GFX11-GISEL-FAKE16-NEXT:    v_lshl_or_b32 v2, v1, 16, v29131; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)9132; GFX11-GISEL-FAKE16-NEXT:    v_pk_min_f16 v2, v2, 4.0 op_sel_hi:[1,0]9133; GFX11-GISEL-FAKE16-NEXT:    v_lshrrev_b32_e32 v3, 16, v29134; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v2, vcc_lo9135; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 4.0, v19136; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)9137; GFX11-GISEL-FAKE16-NEXT:    v_and_b32_e32 v0, 0xffff, v09138; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v1, 0x7e00, v3, vcc_lo9139; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)9140; GFX11-GISEL-FAKE16-NEXT:    v_lshl_or_b32 v0, v1, 16, v09141; GFX11-GISEL-FAKE16-NEXT:    s_setpc_b64 s[30:31]9142;9143; GFX11-GISEL-TRUE16-LABEL: v_test_nnan_input_fmed3_r_i_i_v2f16_maximum_minimum:9144; GFX11-GISEL-TRUE16:       ; %bb.0:9145; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9146; GFX11-GISEL-TRUE16-NEXT:    v_pk_add_f16 v0, v0, 1.0 op_sel_hi:[1,0]9147; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)9148; GFX11-GISEL-TRUE16-NEXT:    v_pk_max_f16 v1, v0, 2.0 op_sel_hi:[1,0]9149; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 2.0, v0.l9150; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e64 s0, 2.0, v0.h9151; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b16 v0.l, 0x7e00, v1.l, vcc_lo9152; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)9153; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b16 v0.h, 0x7e00, v1.h, s09154; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 4.0, v0.l9155; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)9156; GFX11-GISEL-TRUE16-NEXT:    v_pk_min_f16 v1, v0, 4.0 op_sel_hi:[1,0]9157; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e64 s0, 4.0, v0.h9158; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b16 v0.l, 0x7e00, v1.l, vcc_lo9159; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_2)9160; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b16 v0.h, 0x7e00, v1.h, s09161; GFX11-GISEL-TRUE16-NEXT:    s_setpc_b64 s[30:31]9162  %a.add = fadd nnan <2 x half> %a, splat (half 1.0)9163  %max = call <2 x half> @llvm.maximum.v2f16(<2 x half> %a.add, <2 x half> splat (half 2.0))9164  %med = call <2 x half> @llvm.minimum.v2f16(<2 x half> %max, <2 x half> splat (half 4.0))9165  ret <2 x half> %med9166}9167 9168define half @v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum(half %a) {9169; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9170; SI-SDAG:       ; %bb.0:9171; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9172; SI-SDAG-NEXT:    v_cvt_f16_f32_e32 v0, v09173; SI-SDAG-NEXT:    v_cvt_f32_f16_e32 v0, v09174; SI-SDAG-NEXT:    v_add_f32_e32 v0, 1.0, v09175; SI-SDAG-NEXT:    v_med3_f32 v0, v0, 2.0, 4.09176; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]9177;9178; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9179; SI-GISEL:       ; %bb.0:9180; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9181; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09182; SI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7fc000009183; SI-GISEL-NEXT:    v_add_f32_e32 v0, 1.0, v09184; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09185; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09186; SI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v09187; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v09188; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc9189; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09190; SI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09191; SI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v09192; SI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v09193; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc9194; SI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09195; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]9196;9197; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9198; VI-SDAG:       ; %bb.0:9199; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9200; VI-SDAG-NEXT:    v_add_f16_e32 v0, 1.0, v09201; VI-SDAG-NEXT:    v_max_f16_e32 v0, 2.0, v09202; VI-SDAG-NEXT:    v_min_f16_e32 v0, 4.0, v09203; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]9204;9205; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9206; VI-GISEL:       ; %bb.0:9207; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9208; VI-GISEL-NEXT:    v_add_f16_e32 v0, 1.0, v09209; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09210; VI-GISEL-NEXT:    v_mov_b32_e32 v1, 0x7fc000009211; VI-GISEL-NEXT:    v_max_f32_e32 v2, 2.0, v09212; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 2.0, v09213; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc9214; VI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09215; VI-GISEL-NEXT:    v_cvt_f32_f16_e32 v0, v09216; VI-GISEL-NEXT:    v_min_f32_e32 v2, 4.0, v09217; VI-GISEL-NEXT:    v_cmp_o_f32_e32 vcc, 4.0, v09218; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, v1, v2, vcc9219; VI-GISEL-NEXT:    v_cvt_f16_f32_e32 v0, v09220; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]9221;9222; GFX9-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9223; GFX9-SDAG:       ; %bb.0:9224; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9225; GFX9-SDAG-NEXT:    v_add_f16_e32 v0, 1.0, v09226; GFX9-SDAG-NEXT:    v_med3_f16 v0, v0, 2.0, 4.09227; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]9228;9229; GFX9-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9230; GFX9-GISEL:       ; %bb.0:9231; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9232; GFX9-GISEL-NEXT:    v_add_f16_e32 v0, 1.0, v09233; GFX9-GISEL-NEXT:    v_max_f16_e32 v1, 2.0, v09234; GFX9-GISEL-NEXT:    v_mov_b32_e32 v2, 0x7e009235; GFX9-GISEL-NEXT:    v_cmp_o_f16_e32 vcc, 2.0, v09236; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc9237; GFX9-GISEL-NEXT:    v_min_f16_e32 v1, 4.0, v09238; GFX9-GISEL-NEXT:    v_cmp_o_f16_e32 vcc, 4.0, v09239; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, v2, v1, vcc9240; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]9241;9242; GFX11-SDAG-FAKE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9243; GFX11-SDAG-FAKE16:       ; %bb.0:9244; GFX11-SDAG-FAKE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9245; GFX11-SDAG-FAKE16-NEXT:    v_add_f16_e32 v0, 1.0, v09246; GFX11-SDAG-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)9247; GFX11-SDAG-FAKE16-NEXT:    v_med3_f16 v0, v0, 2.0, 4.09248; GFX11-SDAG-FAKE16-NEXT:    s_setpc_b64 s[30:31]9249;9250; GFX11-GISEL-FAKE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9251; GFX11-GISEL-FAKE16:       ; %bb.0:9252; GFX11-GISEL-FAKE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9253; GFX11-GISEL-FAKE16-NEXT:    v_add_f16_e32 v0, 1.0, v09254; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)9255; GFX11-GISEL-FAKE16-NEXT:    v_max_f16_e32 v1, 2.0, v09256; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 2.0, v09257; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v1, vcc_lo9258; GFX11-GISEL-FAKE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)9259; GFX11-GISEL-FAKE16-NEXT:    v_min_f16_e32 v1, 4.0, v09260; GFX11-GISEL-FAKE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 4.0, v09261; GFX11-GISEL-FAKE16-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v1, vcc_lo9262; GFX11-GISEL-FAKE16-NEXT:    s_setpc_b64 s[30:31]9263;9264; GFX11-SDAG-TRUE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9265; GFX11-SDAG-TRUE16:       ; %bb.0:9266; GFX11-SDAG-TRUE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9267; GFX11-SDAG-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l9268; GFX11-SDAG-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1)9269; GFX11-SDAG-TRUE16-NEXT:    v_med3_f16 v0.l, v0.l, 2.0, 4.09270; GFX11-SDAG-TRUE16-NEXT:    s_setpc_b64 s[30:31]9271;9272; GFX11-GISEL-TRUE16-LABEL: v_test_nnan_input_fmed3_r_i_i_f16_maximum_minimum:9273; GFX11-GISEL-TRUE16:       ; %bb.0:9274; GFX11-GISEL-TRUE16-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9275; GFX11-GISEL-TRUE16-NEXT:    v_add_f16_e32 v0.l, 1.0, v0.l9276; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)9277; GFX11-GISEL-TRUE16-NEXT:    v_max_f16_e32 v0.h, 2.0, v0.l9278; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 2.0, v0.l9279; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b16 v0.l, 0x7e00, v0.h, vcc_lo9280; GFX11-GISEL-TRUE16-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)9281; GFX11-GISEL-TRUE16-NEXT:    v_min_f16_e32 v1.l, 4.0, v0.l9282; GFX11-GISEL-TRUE16-NEXT:    v_cmp_o_f16_e32 vcc_lo, 4.0, v0.l9283; GFX11-GISEL-TRUE16-NEXT:    v_cndmask_b32_e32 v0, 0x7e00, v1, vcc_lo9284; GFX11-GISEL-TRUE16-NEXT:    s_setpc_b64 s[30:31]9285  %a.add = fadd nnan half %a, 1.09286  %max = call half @llvm.maximum.f16(half %a.add, half 2.0)9287  %med = call half @llvm.minimum.f16(half %max, half 4.0)9288  ret half %med9289}9290 9291define double @v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum(double %a) {9292; SI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9293; SI-SDAG:       ; %bb.0:9294; SI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9295; SI-SDAG-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09296; SI-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.09297; SI-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.09298; SI-SDAG-NEXT:    s_setpc_b64 s[30:31]9299;9300; SI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9301; SI-GISEL:       ; %bb.0:9302; SI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9303; SI-GISEL-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09304; SI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7ff800009305; SI-GISEL-NEXT:    v_max_f64 v[2:3], v[0:1], 2.09306; SI-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 2.0, v[0:1]9307; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9308; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9309; SI-GISEL-NEXT:    v_min_f64 v[2:3], v[0:1], 4.09310; SI-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 4.0, v[0:1]9311; SI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9312; SI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9313; SI-GISEL-NEXT:    s_setpc_b64 s[30:31]9314;9315; VI-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9316; VI-SDAG:       ; %bb.0:9317; VI-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9318; VI-SDAG-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09319; VI-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.09320; VI-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.09321; VI-SDAG-NEXT:    s_setpc_b64 s[30:31]9322;9323; VI-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9324; VI-GISEL:       ; %bb.0:9325; VI-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9326; VI-GISEL-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09327; VI-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7ff800009328; VI-GISEL-NEXT:    v_max_f64 v[2:3], v[0:1], 2.09329; VI-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 2.0, v[0:1]9330; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9331; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9332; VI-GISEL-NEXT:    v_min_f64 v[2:3], v[0:1], 4.09333; VI-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 4.0, v[0:1]9334; VI-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9335; VI-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9336; VI-GISEL-NEXT:    s_setpc_b64 s[30:31]9337;9338; GFX9-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9339; GFX9-SDAG:       ; %bb.0:9340; GFX9-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9341; GFX9-SDAG-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09342; GFX9-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.09343; GFX9-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.09344; GFX9-SDAG-NEXT:    s_setpc_b64 s[30:31]9345;9346; GFX9-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9347; GFX9-GISEL:       ; %bb.0:9348; GFX9-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9349; GFX9-GISEL-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09350; GFX9-GISEL-NEXT:    v_mov_b32_e32 v4, 0x7ff800009351; GFX9-GISEL-NEXT:    v_max_f64 v[2:3], v[0:1], 2.09352; GFX9-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 2.0, v[0:1]9353; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9354; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9355; GFX9-GISEL-NEXT:    v_min_f64 v[2:3], v[0:1], 4.09356; GFX9-GISEL-NEXT:    v_cmp_o_f64_e32 vcc, 4.0, v[0:1]9357; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc9358; GFX9-GISEL-NEXT:    v_cndmask_b32_e32 v1, v4, v3, vcc9359; GFX9-GISEL-NEXT:    s_setpc_b64 s[30:31]9360;9361; GFX11-SDAG-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9362; GFX11-SDAG:       ; %bb.0:9363; GFX11-SDAG-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9364; GFX11-SDAG-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09365; GFX11-SDAG-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)9366; GFX11-SDAG-NEXT:    v_max_f64 v[0:1], v[0:1], 2.09367; GFX11-SDAG-NEXT:    v_min_f64 v[0:1], v[0:1], 4.09368; GFX11-SDAG-NEXT:    s_setpc_b64 s[30:31]9369;9370; GFX11-GISEL-LABEL: v_test_nnan_input_fmed3_r_i_i_f64_maximum_minimum:9371; GFX11-GISEL:       ; %bb.0:9372; GFX11-GISEL-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)9373; GFX11-GISEL-NEXT:    v_add_f64 v[0:1], v[0:1], 1.09374; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)9375; GFX11-GISEL-NEXT:    v_max_f64 v[2:3], v[0:1], 2.09376; GFX11-GISEL-NEXT:    v_cmp_o_f64_e32 vcc_lo, 2.0, v[0:1]9377; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc_lo9378; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)9379; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0x7ff80000, v3, vcc_lo9380; GFX11-GISEL-NEXT:    v_min_f64 v[2:3], v[0:1], 4.09381; GFX11-GISEL-NEXT:    v_cmp_o_f64_e32 vcc_lo, 4.0, v[0:1]9382; GFX11-GISEL-NEXT:    s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)9383; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v0, 0, v2, vcc_lo9384; GFX11-GISEL-NEXT:    v_cndmask_b32_e32 v1, 0x7ff80000, v3, vcc_lo9385; GFX11-GISEL-NEXT:    s_setpc_b64 s[30:31]9386  %a.add = fadd nnan double %a, 1.09387  %max = call double @llvm.maximum.f64(double %a.add, double 2.0)9388  %med = call double @llvm.minimum.f64(double %max, double 4.0)9389  ret double %med9390}9391 9392declare i32 @llvm.amdgcn.workitem.id.x() #09393declare float @llvm.fabs.f32(float) #09394declare float @llvm.minnum.f32(float, float) #09395declare float @llvm.maxnum.f32(float, float) #09396declare double @llvm.minnum.f64(double, double) #09397declare double @llvm.maxnum.f64(double, double) #09398declare half @llvm.fabs.f16(half) #09399declare half @llvm.minnum.f16(half, half) #09400declare half @llvm.maxnum.f16(half, half) #09401 9402attributes #0 = { nounwind readnone }9403attributes #2 = { nounwind "no-nans-fp-math"="true" }9404