From 00cfa747156c8a7bb25be3e6a85272a61b0b15ca Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 6 Dec 2016 21:13:30 +0000 Subject: AMDGPU/SI: Don't move copies of immediates to the VALU Summary: If we write an immediate to a VGPR and then copy the VGPR to an SGPR, we can replace the copy with a S_MOV_B32 sgpr, imm, rather than moving the copy to the SALU. Reviewers: arsenm Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, llvm-commits, tony-tye Differential Revision: https://reviews.llvm.org/D27272 llvm-svn: 288849 --- llvm/test/CodeGen/AMDGPU/salu-to-valu.ll | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/AMDGPU/salu-to-valu.ll b/llvm/test/CodeGen/AMDGPU/salu-to-valu.ll index ff013060dce..37083fbbd3c 100644 --- a/llvm/test/CodeGen/AMDGPU/salu-to-valu.ll +++ b/llvm/test/CodeGen/AMDGPU/salu-to-valu.ll @@ -478,5 +478,30 @@ bb4: br label %bb1 } +; GCN-LABEL: {{^}}phi_imm_in_sgprs +; GCN: s_movk_i32 [[A:s[0-9]+]], 0x400 +; GCN: s_movk_i32 [[B:s[0-9]+]], 0x400 +; GCN: [[LOOP_LABEL:[0-9a-zA-Z_]+]]: +; GCN: s_xor_b32 [[B]], [[B]], [[A]] +; GCN: s_cbranch_scc{{[01]}} [[LOOP_LABEL]] +define void @phi_imm_in_sgprs(i32 addrspace(3)* %out, i32 %cond) { +entry: + br label %loop + +loop: + %i = phi i32 [0, %entry], [%i.add, %loop] + %offset = phi i32 [1024, %entry], [%offset.xor, %loop] + %offset.xor = xor i32 %offset, 1024 + %offset.i = add i32 %offset.xor, %i + %ptr = getelementptr i32, i32 addrspace(3)* %out, i32 %offset.i + store i32 0, i32 addrspace(3)* %ptr + %i.add = add i32 %i, 1 + %cmp = icmp ult i32 %i.add, %cond + br i1 %cmp, label %loop, label %exit + +exit: + ret void +} + attributes #0 = { nounwind readnone } attributes #1 = { nounwind } -- cgit v1.2.3