1 ; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,W64 %s
2 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=+wavefrontsize32,-wavefrontsize64 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,W32 %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx1010 -mattr=-wavefrontsize32,+wavefrontsize64 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,W64 %s
5 ; RUN: opt -O3 -S < %s | FileCheck -check-prefixes=OPT,OPT-WXX %s
6 ; RUN: opt -mtriple=amdgcn-- -O3 -S < %s | FileCheck -check-prefixes=OPT,OPT-WXX %s
7 ; RUN: opt -mtriple=amdgcn-- -O3 -mattr=+WavefrontSize32 -S < %s | FileCheck -check-prefixes=OPT,OPT-W32 %s
8 ; RUN: opt -mtriple=amdgcn-- -O3 -mattr=+WavefrontSize64 -S < %s | FileCheck -check-prefixes=OPT,OPT-W64 %s
9 ; RUN: opt -mtriple=amdgcn-- -mcpu=tonga -O3 -S < %s | FileCheck -check-prefixes=OPT,OPT-W64 %s
10 ; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -O3 -mattr=+wavefrontsize32,-wavefrontsize64 -S < %s | FileCheck -check-prefixes=OPT,OPT-W32 %s
11 ; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -O3 -mattr=-wavefrontsize32,+wavefrontsize64 -S < %s | FileCheck -check-prefixes=OPT,OPT-W64 %s
13 ; GCN-LABEL: {{^}}fold_wavefrontsize:
14 ; OPT-LABEL: define amdgpu_kernel void @fold_wavefrontsize(
16 ; W32: v_mov_b32_e32 [[V:v[0-9]+]], 32
17 ; W64: v_mov_b32_e32 [[V:v[0-9]+]], 64
18 ; GCN: store_dword v[{{[0-9:]+}}], [[V]]
20 ; OPT-W32: store i32 32, i32 addrspace(1)* %arg, align 4
21 ; OPT-W64: store i32 64, i32 addrspace(1)* %arg, align 4
22 ; OPT-WXX: %tmp = tail call i32 @llvm.amdgcn.wavefrontsize()
23 ; OPT-WXX: store i32 %tmp, i32 addrspace(1)* %arg, align 4
26 define amdgpu_kernel void @fold_wavefrontsize(i32 addrspace(1)* nocapture %arg) {
28 %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0
29 store i32 %tmp, i32 addrspace(1)* %arg, align 4
33 ; GCN-LABEL: {{^}}fold_and_optimize_wavefrontsize:
34 ; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize(
36 ; W32: v_mov_b32_e32 [[V:v[0-9]+]], 1{{$}}
37 ; W64: v_mov_b32_e32 [[V:v[0-9]+]], 2{{$}}
39 ; GCN: store_dword v[{{[0-9:]+}}], [[V]]
41 ; OPT-W32: store i32 1, i32 addrspace(1)* %arg, align 4
42 ; OPT-W64: store i32 2, i32 addrspace(1)* %arg, align 4
43 ; OPT-WXX: %tmp = tail call i32 @llvm.amdgcn.wavefrontsize()
44 ; OPT-WXX: %tmp1 = icmp ugt i32 %tmp, 32
45 ; OPT-WXX: %tmp2 = select i1 %tmp1, i32 2, i32 1
46 ; OPT-WXX: store i32 %tmp2, i32 addrspace(1)* %arg
49 define amdgpu_kernel void @fold_and_optimize_wavefrontsize(i32 addrspace(1)* nocapture %arg) {
51 %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0
52 %tmp1 = icmp ugt i32 %tmp, 32
53 %tmp2 = select i1 %tmp1, i32 2, i32 1
54 store i32 %tmp2, i32 addrspace(1)* %arg
58 ; GCN-LABEL: {{^}}fold_and_optimize_if_wavefrontsize:
59 ; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize(
62 ; OPT-WXX: %tmp = tail call i32 @llvm.amdgcn.wavefrontsize()
63 ; OPT-WXX: %tmp1 = icmp ugt i32 %tmp, 32
65 ; OPT-W64: store i32 1, i32 addrspace(1)* %arg, align 4
68 define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize(i32 addrspace(1)* nocapture %arg) {
70 %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0
71 %tmp1 = icmp ugt i32 %tmp, 32
72 br i1 %tmp1, label %bb2, label %bb3
75 store i32 1, i32 addrspace(1)* %arg, align 4
78 bb3: ; preds = %bb2, %bb
82 declare i32 @llvm.amdgcn.wavefrontsize() #0
84 attributes #0 = { nounwind readnone speculatable }