1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9 %s 3; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji < %s | FileCheck -check-prefixes=GCN,GFX8 %s 4; FIXME: promotion not handled without f16 insts 5 6define half @v_constained_fsub_f16_fpexcept_strict(half %x, half %y) #0 { 7; GCN-LABEL: v_constained_fsub_f16_fpexcept_strict: 8; GCN: ; %bb.0: 9; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 10; GCN-NEXT: v_sub_f16_e32 v0, v0, v1 11; GCN-NEXT: s_setpc_b64 s[30:31] 12 %val = call half @llvm.experimental.constrained.fsub.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 13 ret half %val 14} 15 16define half @v_constained_fsub_f16_fpexcept_ignore(half %x, half %y) #0 { 17; GCN-LABEL: v_constained_fsub_f16_fpexcept_ignore: 18; GCN: ; %bb.0: 19; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 20; GCN-NEXT: v_sub_f16_e32 v0, v0, v1 21; GCN-NEXT: s_setpc_b64 s[30:31] 22 %val = call half @llvm.experimental.constrained.fsub.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") 23 ret half %val 24} 25 26define half @v_constained_fsub_f16_fpexcept_maytrap(half %x, half %y) #0 { 27; GCN-LABEL: v_constained_fsub_f16_fpexcept_maytrap: 28; GCN: ; %bb.0: 29; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 30; GCN-NEXT: v_sub_f16_e32 v0, v0, v1 31; GCN-NEXT: s_setpc_b64 s[30:31] 32 %val = call half @llvm.experimental.constrained.fsub.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.maytrap") 33 ret half %val 34} 35 36define <2 x half> @v_constained_fsub_v2f16_fpexcept_strict(<2 x half> %x, <2 x half> %y) #0 { 37; GFX9-LABEL: v_constained_fsub_v2f16_fpexcept_strict: 38; GFX9: ; %bb.0: 39; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 40; GFX9-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 41; GFX9-NEXT: v_sub_f16_e32 v0, v0, v1 42; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0 43; GFX9-NEXT: v_lshl_or_b32 v0, v2, 16, v0 44; GFX9-NEXT: s_setpc_b64 s[30:31] 45; 46; GFX8-LABEL: v_constained_fsub_v2f16_fpexcept_strict: 47; GFX8: ; %bb.0: 48; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 49; GFX8-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 50; GFX8-NEXT: v_sub_f16_e32 v0, v0, v1 51; GFX8-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 52; GFX8-NEXT: s_setpc_b64 s[30:31] 53 %val = call <2 x half> @llvm.experimental.constrained.fsub.v2f16(<2 x half> %x, <2 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 54 ret <2 x half> %val 55} 56 57define <2 x half> @v_constained_fsub_v2f16_fpexcept_ignore(<2 x half> %x, <2 x half> %y) #0 { 58; GFX9-LABEL: v_constained_fsub_v2f16_fpexcept_ignore: 59; GFX9: ; %bb.0: 60; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 61; GFX9-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 62; GFX9-NEXT: v_sub_f16_e32 v0, v0, v1 63; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0 64; GFX9-NEXT: v_lshl_or_b32 v0, v2, 16, v0 65; GFX9-NEXT: s_setpc_b64 s[30:31] 66; 67; GFX8-LABEL: v_constained_fsub_v2f16_fpexcept_ignore: 68; GFX8: ; %bb.0: 69; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 70; GFX8-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 71; GFX8-NEXT: v_sub_f16_e32 v0, v0, v1 72; GFX8-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 73; GFX8-NEXT: s_setpc_b64 s[30:31] 74 %val = call <2 x half> @llvm.experimental.constrained.fsub.v2f16(<2 x half> %x, <2 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") 75 ret <2 x half> %val 76} 77 78define <2 x half> @v_constained_fsub_v2f16_fpexcept_maytrap(<2 x half> %x, <2 x half> %y) #0 { 79; GFX9-LABEL: v_constained_fsub_v2f16_fpexcept_maytrap: 80; GFX9: ; %bb.0: 81; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 82; GFX9-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 83; GFX9-NEXT: v_sub_f16_e32 v0, v0, v1 84; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0 85; GFX9-NEXT: v_lshl_or_b32 v0, v2, 16, v0 86; GFX9-NEXT: s_setpc_b64 s[30:31] 87; 88; GFX8-LABEL: v_constained_fsub_v2f16_fpexcept_maytrap: 89; GFX8: ; %bb.0: 90; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 91; GFX8-NEXT: v_sub_f16_sdwa v2, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 92; GFX8-NEXT: v_sub_f16_e32 v0, v0, v1 93; GFX8-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 94; GFX8-NEXT: s_setpc_b64 s[30:31] 95 %val = call <2 x half> @llvm.experimental.constrained.fsub.v2f16(<2 x half> %x, <2 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.maytrap") 96 ret <2 x half> %val 97} 98 99define <3 x half> @v_constained_fsub_v3f16_fpexcept_strict(<3 x half> %x, <3 x half> %y) #0 { 100; GFX9-LABEL: v_constained_fsub_v3f16_fpexcept_strict: 101; GFX9: ; %bb.0: 102; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 103; GFX9-NEXT: v_sub_f16_sdwa v4, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 104; GFX9-NEXT: v_sub_f16_e32 v0, v0, v2 105; GFX9-NEXT: v_and_b32_e32 v0, 0xffff, v0 106; GFX9-NEXT: v_lshl_or_b32 v0, v4, 16, v0 107; GFX9-NEXT: v_sub_f16_e32 v1, v1, v3 108; GFX9-NEXT: s_setpc_b64 s[30:31] 109; 110; GFX8-LABEL: v_constained_fsub_v3f16_fpexcept_strict: 111; GFX8: ; %bb.0: 112; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 113; GFX8-NEXT: v_sub_f16_sdwa v4, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 114; GFX8-NEXT: v_sub_f16_e32 v0, v0, v2 115; GFX8-NEXT: v_or_b32_sdwa v0, v0, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 116; GFX8-NEXT: v_sub_f16_e32 v1, v1, v3 117; GFX8-NEXT: s_setpc_b64 s[30:31] 118 %val = call <3 x half> @llvm.experimental.constrained.fsub.v3f16(<3 x half> %x, <3 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 119 ret <3 x half> %val 120} 121 122; FIXME: Scalarized 123define <4 x half> @v_constained_fsub_v4f16_fpexcept_strict(<4 x half> %x, <4 x half> %y) #0 { 124; GFX9-LABEL: v_constained_fsub_v4f16_fpexcept_strict: 125; GFX9: ; %bb.0: 126; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 127; GFX9-NEXT: v_sub_f16_sdwa v4, v1, v3 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 128; GFX9-NEXT: v_sub_f16_sdwa v5, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 129; GFX9-NEXT: v_sub_f16_e32 v0, v0, v2 130; GFX9-NEXT: v_mov_b32_e32 v2, 0xffff 131; GFX9-NEXT: v_sub_f16_e32 v1, v1, v3 132; GFX9-NEXT: v_and_b32_e32 v0, v2, v0 133; GFX9-NEXT: v_and_b32_e32 v1, v2, v1 134; GFX9-NEXT: v_lshl_or_b32 v0, v5, 16, v0 135; GFX9-NEXT: v_lshl_or_b32 v1, v4, 16, v1 136; GFX9-NEXT: s_setpc_b64 s[30:31] 137; 138; GFX8-LABEL: v_constained_fsub_v4f16_fpexcept_strict: 139; GFX8: ; %bb.0: 140; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) 141; GFX8-NEXT: v_sub_f16_sdwa v4, v1, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 142; GFX8-NEXT: v_sub_f16_e32 v1, v1, v3 143; GFX8-NEXT: v_sub_f16_sdwa v5, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1 144; GFX8-NEXT: v_sub_f16_e32 v0, v0, v2 145; GFX8-NEXT: v_or_b32_sdwa v0, v0, v5 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 146; GFX8-NEXT: v_or_b32_sdwa v1, v1, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 147; GFX8-NEXT: s_setpc_b64 s[30:31] 148 %val = call <4 x half> @llvm.experimental.constrained.fsub.v4f16(<4 x half> %x, <4 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 149 ret <4 x half> %val 150} 151 152define amdgpu_ps half @s_constained_fsub_f16_fpexcept_strict(half inreg %x, half inreg %y) #0 { 153; GCN-LABEL: s_constained_fsub_f16_fpexcept_strict: 154; GCN: ; %bb.0: 155; GCN-NEXT: v_mov_b32_e32 v0, s3 156; GCN-NEXT: v_sub_f16_e32 v0, s2, v0 157; GCN-NEXT: ; return to shader part epilog 158 %val = call half @llvm.experimental.constrained.fsub.f16(half %x, half %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 159 ret half %val 160} 161 162define amdgpu_ps <2 x half> @s_constained_fsub_v2f16_fpexcept_strict(<2 x half> inreg %x, <2 x half> inreg %y) #0 { 163; GFX9-LABEL: s_constained_fsub_v2f16_fpexcept_strict: 164; GFX9: ; %bb.0: 165; GFX9-NEXT: v_mov_b32_e32 v1, s3 166; GFX9-NEXT: s_lshr_b32 s0, s3, 16 167; GFX9-NEXT: v_sub_f16_e32 v1, s2, v1 168; GFX9-NEXT: s_lshr_b32 s1, s2, 16 169; GFX9-NEXT: v_mov_b32_e32 v0, s0 170; GFX9-NEXT: v_sub_f16_e32 v0, s1, v0 171; GFX9-NEXT: v_and_b32_e32 v1, 0xffff, v1 172; GFX9-NEXT: v_lshl_or_b32 v0, v0, 16, v1 173; GFX9-NEXT: ; return to shader part epilog 174; 175; GFX8-LABEL: s_constained_fsub_v2f16_fpexcept_strict: 176; GFX8: ; %bb.0: 177; GFX8-NEXT: s_lshr_b32 s0, s3, 16 178; GFX8-NEXT: s_lshr_b32 s1, s2, 16 179; GFX8-NEXT: v_mov_b32_e32 v0, s0 180; GFX8-NEXT: v_mov_b32_e32 v1, s1 181; GFX8-NEXT: v_sub_f16_sdwa v0, v1, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD 182; GFX8-NEXT: v_mov_b32_e32 v1, s3 183; GFX8-NEXT: v_sub_f16_e32 v1, s2, v1 184; GFX8-NEXT: v_or_b32_sdwa v0, v1, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD 185; GFX8-NEXT: ; return to shader part epilog 186 %val = call <2 x half> @llvm.experimental.constrained.fsub.v2f16(<2 x half> %x, <2 x half> %y, metadata !"round.tonearest", metadata !"fpexcept.strict") 187 ret <2 x half> %val 188} 189 190declare half @llvm.experimental.constrained.fsub.f16(half, half, metadata, metadata) #1 191declare <2 x half> @llvm.experimental.constrained.fsub.v2f16(<2 x half>, <2 x half>, metadata, metadata) #1 192declare <3 x half> @llvm.experimental.constrained.fsub.v3f16(<3 x half>, <3 x half>, metadata, metadata) #1 193declare <4 x half> @llvm.experimental.constrained.fsub.v4f16(<4 x half>, <4 x half>, metadata, metadata) #1 194 195attributes #0 = { strictfp } 196attributes #1 = { inaccessiblememonly nounwind willreturn } 197