[AMDGPU] restore r342722 which was reverted with r342743
authorSameer Sahasrabuddhe <sameer.sahasrabuddhe@amd.com>
Tue, 25 Sep 2018 09:39:21 +0000 (09:39 +0000)
committerSameer Sahasrabuddhe <sameer.sahasrabuddhe@amd.com>
Tue, 25 Sep 2018 09:39:21 +0000 (09:39 +0000)
commitb4f2d1cb6820803ec562c75a26c3ec71c8bfea37
tree03f09bd6a8b10c25b34d085c62c255e5de35a834
parent6d92c198ac2fb3c076f41fcc61cf6bae511be7fd
[AMDGPU] restore r342722 which was reverted with r342743

[AMDGPU] lower-switch in preISel as a workaround for legacy DA

Summary:
The default target of the switch instruction may sometimes be an
"unreachable" block, when it is guaranteed that one of the cases is
always taken. The dominator tree concludes that such a switch
instruction does not have an immediate post dominator. This confuses
divergence analysis, which is unable to propagate sync dependence to
the targets of the switch instruction.

As a workaround, the AMDGPU target now invokes lower-switch as a
preISel pass. LowerSwitch is designed to handle the unreachable
default target correctly, allowing the divergence analysis to locate
the correct immediate dominator of the now-lowered switch.

llvm-svn: 342956
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/test/CodeGen/AMDGPU/diverge-switch-default.ll [new file with mode: 0644]