]> granicus.if.org Git - llvm/commit
AMDGPU: Remove spurious out branches after a kill
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 24 Jan 2017 22:18:39 +0000 (22:18 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 24 Jan 2017 22:18:39 +0000 (22:18 +0000)
commite8e3365d5266760f3d7ad247f21496bb69cfef39
treecf24e592fcb9f3b5b9588ca5e29ff96c6c845825
parent5acaea1e1cadf64c091c6c34fc02d34bda9ead89
AMDGPU: Remove spurious out branches after a kill

The sequence like this:
  v_cmpx_le_f32_e32 vcc, 0, v0
  s_branch BB0_30
  s_cbranch_execnz BB0_30
  ; BB#29:
  exp null off, off, off, off done vm
  s_endpgm
  BB0_30:
  ; %endif110

is likely wrong. The s_branch instruction will unconditionally jump
to BB0_30 and the skip block (exp done + endpgm) inserted for
performing the kill instruction will never be executed. This results
in a GPU hang with Star Ruler 2.

The s_branch instruction is added during the "Control Flow Optimizer"
pass which seems to re-organize the basic blocks, and we assume
that SI_KILL_TERMINATOR is always the last instruction inside a
basic block. Thus, after inserting a skip block we just go to the
next BB without looking at the subsequent instructions after the
kill, and the s_branch op is never removed.

Instead, we should remove the unconditional out branches and let
skip the two instructions if the exec mask is non-zero.

This patch fixes the GPU hang and doesn't introduce any regressions
with "make check".

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99019

Patch by Samuel Pitoiset <samuel.pitoiset@gmail.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292985 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AMDGPU/SIInsertSkips.cpp
test/CodeGen/AMDGPU/insert-skips-kill-uncond.mir [new file with mode: 0644]