diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp index bab83483f3de1..20b5fd94aba94 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp @@ -147,6 +147,9 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::run(MachineFunction &MF) const { // TODO: Test multiple uses for (VNInfo *VNI : LI.vnis()) { + if (VNI->isPHIDef() || VNI->isUnused()) + continue; + MachineInstr *DefMI = LIS.getInstructionFromIndex(VNI->def); // TODO: Handle SplitKit produced copy bundles for partially defined diff --git a/llvm/test/CodeGen/AMDGPU/av-split-dead-valno-crash.ll b/llvm/test/CodeGen/AMDGPU/av-split-dead-valno-crash.ll new file mode 100644 index 0000000000000..89fe0ab526a8a --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/av-split-dead-valno-crash.ll @@ -0,0 +1,211 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -stress-regalloc=18 < %s | FileCheck %s + +define amdgpu_kernel void @vgpr_mfma_pass_av_split_crash(double %arg1, i1 %arg2, i1 %cond.i.i.i2295, ptr addrspace(1) %ptr, ptr %ptr1) #0 { +; CHECK-LABEL: vgpr_mfma_pass_av_split_crash: +; CHECK: ; %bb.0: ; %entry +; CHECK-NEXT: s_load_dword s0, s[4:5], 0x8 +; CHECK-NEXT: s_load_dwordx2 s[10:11], s[4:5], 0x0 +; CHECK-NEXT: s_load_dwordx4 s[12:15], s[4:5], 0x10 +; CHECK-NEXT: v_mov_b32_e32 v1, 0x3e21eeb6 +; CHECK-NEXT: v_mov_b32_e32 v2, 0xa17f65f6 +; CHECK-NEXT: s_waitcnt lgkmcnt(0) +; CHECK-NEXT: s_bitcmp1_b32 s0, 0 +; CHECK-NEXT: s_cselect_b64 s[16:17], -1, 0 +; CHECK-NEXT: s_xor_b64 s[18:19], s[16:17], -1 +; CHECK-NEXT: s_bitcmp1_b32 s0, 8 +; CHECK-NEXT: s_cselect_b64 s[2:3], -1, 0 +; CHECK-NEXT: v_cndmask_b32_e64 v0, 0, 1, s[2:3] +; CHECK-NEXT: s_xor_b64 s[20:21], s[2:3], -1 +; CHECK-NEXT: v_cmp_ne_u32_e64 s[0:1], 1, v0 +; CHECK-NEXT: s_and_b64 s[2:3], exec, s[2:3] +; CHECK-NEXT: v_mov_b32_e32 v0, 0x9037ab78 +; CHECK-NEXT: v_mov_b32_e32 v3, 0xbe927e4f +; CHECK-NEXT: v_mov_b32_e32 v4, 0x19f4ec90 +; CHECK-NEXT: v_mov_b32_e32 v5, 0x3efa01a0 +; CHECK-NEXT: v_mov_b32_e32 v6, 0x16c16967 +; CHECK-NEXT: v_mov_b32_e32 v7, 0xbf56c16c +; CHECK-NEXT: v_mov_b32_e32 v8, 0x69efb384 +; CHECK-NEXT: v_mov_b32_e32 v9, 0x3f4b2bb0 +; CHECK-NEXT: v_mov_b32_e32 v10, 0xa57d9582 +; CHECK-NEXT: v_mov_b32_e32 v11, 0xbf8c6ea4 +; CHECK-NEXT: v_mov_b32_e32 v12, 0xe82d3ff0 +; CHECK-NEXT: v_mov_b32_e32 v13, 0xbfa59976 +; CHECK-NEXT: v_mov_b32_e32 v14, 0x8427b883 +; CHECK-NEXT: v_mov_b32_e32 v15, 0x3fae1bb4 +; CHECK-NEXT: s_mov_b64 s[22:23], 0 +; CHECK-NEXT: v_mov_b32_e32 v16, 0x57b87036 +; CHECK-NEXT: v_mov_b32_e32 v17, 0x3fb3b136 +; CHECK-NEXT: s_and_b64 s[4:5], exec, s[16:17] +; CHECK-NEXT: v_mov_b32_e32 v18, 0x55555523 +; CHECK-NEXT: v_mov_b32_e32 v19, 0xbfd55555 +; CHECK-NEXT: s_and_b64 s[6:7], exec, s[18:19] +; CHECK-NEXT: v_mov_b32_e32 v20, 0 +; CHECK-NEXT: ; implicit-def: $agpr0_agpr1 +; CHECK-NEXT: ; implicit-def: $vgpr22_vgpr23 +; CHECK-NEXT: s_branch .LBB0_2 +; CHECK-NEXT: .LBB0_1: ; %Flow9 +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: s_andn2_b64 vcc, exec, s[24:25] +; CHECK-NEXT: s_cbranch_vccz .LBB0_17 +; CHECK-NEXT: .LBB0_2: ; %._crit_edge1942.i.i.i3548 +; CHECK-NEXT: ; =>This Loop Header: Depth=1 +; CHECK-NEXT: ; Child Loop BB0_6 Depth 2 +; CHECK-NEXT: s_and_b64 vcc, exec, s[0:1] +; CHECK-NEXT: s_cbranch_vccnz .LBB0_9 +; CHECK-NEXT: ; %bb.3: ; %.preheader1868.i.i.i3244 +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: s_mov_b64 vcc, s[4:5] +; CHECK-NEXT: s_cbranch_vccz .LBB0_10 +; CHECK-NEXT: ; %bb.4: ; %.preheader1855.i.i.i3329.preheader +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_mov_b64_e32 v[24:25], s[14:15] +; CHECK-NEXT: flat_load_dwordx2 v[24:25], v[24:25] +; CHECK-NEXT: v_mov_b64_e32 v[26:27], v[0:1] +; CHECK-NEXT: v_mov_b64_e32 v[28:29], v[2:3] +; CHECK-NEXT: v_mov_b64_e32 v[30:31], v[16:17] +; CHECK-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0) +; CHECK-NEXT: v_fmac_f64_e32 v[26:27], 0, v[24:25] +; CHECK-NEXT: v_fmac_f64_e32 v[28:29], 0, v[26:27] +; CHECK-NEXT: v_mov_b64_e32 v[26:27], v[4:5] +; CHECK-NEXT: v_fmac_f64_e32 v[26:27], 0, v[28:29] +; CHECK-NEXT: v_mov_b64_e32 v[28:29], v[6:7] +; CHECK-NEXT: v_fmac_f64_e32 v[28:29], 0, v[26:27] +; CHECK-NEXT: v_mov_b64_e32 v[26:27], v[8:9] +; CHECK-NEXT: v_fmac_f64_e32 v[26:27], 0, v[28:29] +; CHECK-NEXT: v_mov_b64_e32 v[28:29], v[10:11] +; CHECK-NEXT: v_fmac_f64_e32 v[28:29], 0, v[26:27] +; CHECK-NEXT: v_mov_b64_e32 v[26:27], v[12:13] +; CHECK-NEXT: v_fmac_f64_e32 v[26:27], 0, v[28:29] +; CHECK-NEXT: v_mov_b64_e32 v[28:29], v[14:15] +; CHECK-NEXT: v_fmac_f64_e32 v[28:29], 0, v[26:27] +; CHECK-NEXT: v_fmac_f64_e32 v[30:31], 0, v[28:29] +; CHECK-NEXT: v_mov_b64_e32 v[26:27], v[18:19] +; CHECK-NEXT: v_fmac_f64_e32 v[26:27], 0, v[30:31] +; CHECK-NEXT: v_mov_b64_e32 v[30:31], 0 +; CHECK-NEXT: s_branch .LBB0_6 +; CHECK-NEXT: .LBB0_5: ; %Flow +; CHECK-NEXT: ; in Loop: Header=BB0_6 Depth=2 +; CHECK-NEXT: s_and_b64 vcc, exec, s[8:9] +; CHECK-NEXT: s_cbranch_vccnz .LBB0_11 +; CHECK-NEXT: .LBB0_6: ; %.preheader1855.i.i.i3329 +; CHECK-NEXT: ; Parent Loop BB0_2 Depth=1 +; CHECK-NEXT: ; => This Inner Loop Header: Depth=2 +; CHECK-NEXT: v_mov_b64_e32 v[28:29], v[30:31] +; CHECK-NEXT: s_mov_b64 s[24:25], -1 +; CHECK-NEXT: s_mov_b64 s[8:9], -1 +; CHECK-NEXT: s_mov_b64 vcc, s[2:3] +; CHECK-NEXT: ; implicit-def: $vgpr30_vgpr31 +; CHECK-NEXT: s_cbranch_vccz .LBB0_5 +; CHECK-NEXT: ; %bb.7: ; %.lr.ph2070.i.i.i3291 +; CHECK-NEXT: ; in Loop: Header=BB0_6 Depth=2 +; CHECK-NEXT: v_accvgpr_read_b32 v31, a1 +; CHECK-NEXT: v_accvgpr_read_b32 v30, a0 +; CHECK-NEXT: s_mov_b64 s[8:9], s[18:19] +; CHECK-NEXT: s_mov_b64 vcc, s[6:7] +; CHECK-NEXT: s_cbranch_vccz .LBB0_5 +; CHECK-NEXT: ; %bb.8: ; %.preheader1856.preheader.i.i.i3325 +; CHECK-NEXT: ; in Loop: Header=BB0_6 Depth=2 +; CHECK-NEXT: s_mov_b64 s[24:25], 0 +; CHECK-NEXT: v_mov_b64_e32 v[30:31], v[26:27] +; CHECK-NEXT: s_mov_b64 s[8:9], 0 +; CHECK-NEXT: s_branch .LBB0_5 +; CHECK-NEXT: .LBB0_9: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_mov_b64_e32 v[24:25], s[10:11] +; CHECK-NEXT: v_accvgpr_write_b32 a0, v24 +; CHECK-NEXT: s_mov_b64 s[22:23], 0 +; CHECK-NEXT: v_accvgpr_write_b32 a1, v25 +; CHECK-NEXT: s_mov_b64 s[8:9], s[20:21] +; CHECK-NEXT: s_branch .LBB0_15 +; CHECK-NEXT: .LBB0_10: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: s_mov_b64 s[8:9], -1 +; CHECK-NEXT: v_mov_b64_e32 v[22:23], 0 +; CHECK-NEXT: s_branch .LBB0_15 +; CHECK-NEXT: .LBB0_11: ; %loop.exit.guard +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: s_and_b64 vcc, exec, s[24:25] +; CHECK-NEXT: s_cbranch_vccz .LBB0_13 +; CHECK-NEXT: ; %bb.12: ; %._crit_edge2105.i.i.i2330.loopexit +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_cmp_nlg_f64_e64 s[8:9], 0, v[28:29] +; CHECK-NEXT: v_accvgpr_write_b32 a0, v24 +; CHECK-NEXT: v_cndmask_b32_e64 v23, v23, 0, s[16:17] +; CHECK-NEXT: v_cndmask_b32_e64 v26, 0, 1, s[8:9] +; CHECK-NEXT: v_mov_b32_e32 v27, v26 +; CHECK-NEXT: s_and_b64 s[8:9], exec, s[16:17] +; CHECK-NEXT: v_cndmask_b32_e64 v22, v22, 0, s[16:17] +; CHECK-NEXT: global_store_dwordx2 v20, v[26:27], s[12:13] +; CHECK-NEXT: s_cselect_b32 s23, s23, 0 +; CHECK-NEXT: s_cselect_b32 s22, s22, 0 +; CHECK-NEXT: s_mov_b64 s[8:9], -1 +; CHECK-NEXT: s_branch .LBB0_14 +; CHECK-NEXT: .LBB0_13: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_accvgpr_write_b32 a0, v24 +; CHECK-NEXT: s_mov_b64 s[8:9], 0 +; CHECK-NEXT: v_mov_b64_e32 v[22:23], 0 +; CHECK-NEXT: .LBB0_14: ; %Flow6 +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_accvgpr_write_b32 a1, v25 +; CHECK-NEXT: .LBB0_15: ; %Flow6 +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: s_mov_b64 s[24:25], -1 +; CHECK-NEXT: s_and_b64 vcc, exec, s[8:9] +; CHECK-NEXT: s_cbranch_vccz .LBB0_1 +; CHECK-NEXT: ; %bb.16: ; %._crit_edge2105.i.i.i2330 +; CHECK-NEXT: ; in Loop: Header=BB0_2 Depth=1 +; CHECK-NEXT: v_mov_b32_e32 v21, v20 +; CHECK-NEXT: s_mov_b64 s[24:25], 0 +; CHECK-NEXT: global_store_dwordx2 v20, v[20:21], s[12:13] +; CHECK-NEXT: s_branch .LBB0_1 +; CHECK-NEXT: .LBB0_17: ; %DummyReturnBlock +; CHECK-NEXT: s_endpgm +entry: + br label %._crit_edge1942.i.i.i3548 + +._crit_edge1942.i.i.i3548: ; preds = %._crit_edge2105.i.i.i2330, %entry + %.sroa.02591.0.i.i.i226323 = phi double [ poison, %entry ], [ %.sroa.02591.3.i.i.i2301, %._crit_edge2105.i.i.i2330 ] + %.sroa.3.0.i.i.i2270 = phi double [ poison, %entry ], [ %.sroa.3.3.i.i.i2308, %._crit_edge2105.i.i.i2330 ] + %.014942244.i.i.i2280 = phi double [ 0.000000e+00, %entry ], [ %.31497.i.i.i2317, %._crit_edge2105.i.i.i2330 ] + br i1 %cond.i.i.i2295, label %.preheader1868.i.i.i3244, label %._crit_edge2105.i.i.i2330 + +.preheader1868.i.i.i3244: ; preds = %._crit_edge1942.i.i.i3548 + %i = load double, ptr %ptr1, align 8 + %i3 = call double @llvm.fma.f64(double %i, double 0.000000e+00, double 0x3E21EEB69037AB78) + %i4 = call double @llvm.fma.f64(double 0.000000e+00, double %i3, double 0xBE927E4FA17F65F6) + %i5 = call double @llvm.fma.f64(double 0.000000e+00, double %i4, double 0x3EFA01A019F4EC90) + %i6 = call double @llvm.fma.f64(double 0.000000e+00, double %i5, double 0xBF56C16C16C16967) + %spec.select.i.i.i3288 = select i1 %arg2, double 0.000000e+00, double %.sroa.3.0.i.i.i2270 + br i1 %arg2, label %.preheader1855.i.i.i3329, label %._crit_edge2105.i.i.i2330 + +.lr.ph2070.i.i.i3291: ; preds = %.preheader1855.i.i.i3329 + br i1 %arg2, label %.preheader1855.i.i.i3329, label %.preheader1856.preheader.i.i.i3325 + +.preheader1856.preheader.i.i.i3325: ; preds = %.lr.ph2070.i.i.i3291 + %i11 = call double @llvm.fma.f64(double 0.000000e+00, double %i6, double 0x3F4B2BB069EFB384) + %i14 = call double @llvm.fma.f64(double 0.000000e+00, double %i11, double 0xBF8C6EA4A57D9582) + %i18 = call double @llvm.fma.f64(double 0.000000e+00, double %i14, double 0xBFA59976E82D3FF0) + %i21 = call double @llvm.fma.f64(double 0.000000e+00, double %i18, double 0x3FAE1BB48427B883) + %i23 = call double @llvm.fma.f64(double 0.000000e+00, double %i21, double 0x3FB3B13657B87036) + %i28 = call double @llvm.fma.f64(double 0.000000e+00, double %i23, double 0xBFD5555555555523) + br label %.preheader1855.i.i.i3329 + +.preheader1855.i.i.i3329: ; preds = %.preheader1856.preheader.i.i.i3325, %.lr.ph2070.i.i.i3291, %.preheader1868.i.i.i3244 + %.sroa.02591.4.i.i.i3335 = phi double [ %i28, %.preheader1856.preheader.i.i.i3325 ], [ %.sroa.02591.0.i.i.i226323, %.lr.ph2070.i.i.i3291 ], [ 0.000000e+00, %.preheader1868.i.i.i3244 ] + %.21496.ph.i.i.i3348 = select i1 %arg2, double %.014942244.i.i.i2280, double 0.000000e+00 + %i31 = fcmp one double %.sroa.02591.4.i.i.i3335, 0.000000e+00 + %i32 = select i1 %i31, <2 x i32> zeroinitializer, <2 x i32> splat (i32 1) + store <2 x i32> %i32, ptr addrspace(1) %ptr, align 8 + br i1 %cond.i.i.i2295, label %.lr.ph2070.i.i.i3291, label %._crit_edge2105.i.i.i2330 + +._crit_edge2105.i.i.i2330: ; preds = %.preheader1855.i.i.i3329, %.preheader1868.i.i.i3244, %._crit_edge1942.i.i.i3548 + %.sroa.02591.3.i.i.i2301 = phi double [ %.sroa.02591.0.i.i.i226323, %.preheader1868.i.i.i3244 ], [ %arg1, %._crit_edge1942.i.i.i3548 ], [ %i, %.preheader1855.i.i.i3329 ] + %.sroa.3.3.i.i.i2308 = phi double [ 0.000000e+00, %.preheader1868.i.i.i3244 ], [ %.sroa.3.0.i.i.i2270, %._crit_edge1942.i.i.i3548 ], [ %spec.select.i.i.i3288, %.preheader1855.i.i.i3329 ] + %.31497.i.i.i2317 = phi double [ %.014942244.i.i.i2280, %.preheader1868.i.i.i3244 ], [ 0.000000e+00, %._crit_edge1942.i.i.i3548 ], [ %.21496.ph.i.i.i3348, %.preheader1855.i.i.i3329 ] + store double 0.000000e+00, ptr addrspace(1) %ptr, align 8 + br label %._crit_edge1942.i.i.i3548 +} + +declare double @llvm.fma.f64(double, double, double) #1 + +attributes #0 = { "amdgpu-waves-per-eu"="8,8" "target-cpu"="gfx942" } +attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }