blob: 5290c4515049eec80e7966830e7b763c25382012 [file] [log] [blame]
Matt Arsenault84db5d92015-07-14 17:57:36 +00001; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs -mattr=+load-store-opt < %s | FileCheck -check-prefix=SI %s
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +00002
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +00003@lds = addrspace(3) global [512 x float] undef, align 4
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +00004
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +00005; SI-LABEL: @simple_write2st64_one_val_f32_0_1
Tom Stellard326d6ec2014-11-05 14:50:53 +00006; SI-DAG: buffer_load_dword [[VAL:v[0-9]+]]
7; SI-DAG: v_lshlrev_b32_e32 [[VPTR:v[0-9]+]], 2, v{{[0-9]+}}
Tom Stellard1f3416a2015-04-08 01:09:19 +00008; SI: ds_write2st64_b32 [[VPTR]], [[VAL]], [[VAL]] offset1:1
Tom Stellard326d6ec2014-11-05 14:50:53 +00009; SI: s_endpgm
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000010define void @simple_write2st64_one_val_f32_0_1(float addrspace(1)* %C, float addrspace(1)* %in) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000011 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000012 %in.gep = getelementptr float, float addrspace(1)* %in, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +000013 %val = load float, float addrspace(1)* %in.gep, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000014 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000015 store float %val, float addrspace(3)* %arrayidx0, align 4
16 %add.x = add nsw i32 %x.i, 64
David Blaikie79e6c742015-02-27 19:29:02 +000017 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000018 store float %val, float addrspace(3)* %arrayidx1, align 4
19 ret void
20}
21
22; SI-LABEL: @simple_write2st64_two_val_f32_2_5
Tom Stellard326d6ec2014-11-05 14:50:53 +000023; SI-DAG: buffer_load_dword [[VAL0:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
Matt Arsenaultfb13b222014-12-03 03:12:13 +000024; SI-DAG: buffer_load_dword [[VAL1:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
Tom Stellard326d6ec2014-11-05 14:50:53 +000025; SI-DAG: v_lshlrev_b32_e32 [[VPTR:v[0-9]+]], 2, v{{[0-9]+}}
Tom Stellardeb05c612015-02-26 17:08:43 +000026; SI: ds_write2st64_b32 [[VPTR]], [[VAL0]], [[VAL1]] offset0:2 offset1:5
Tom Stellard326d6ec2014-11-05 14:50:53 +000027; SI: s_endpgm
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000028define void @simple_write2st64_two_val_f32_2_5(float addrspace(1)* %C, float addrspace(1)* %in) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000029 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000030 %in.gep.0 = getelementptr float, float addrspace(1)* %in, i32 %x.i
31 %in.gep.1 = getelementptr float, float addrspace(1)* %in.gep.0, i32 1
Matt Arsenault44e54832016-04-12 13:38:18 +000032 %val0 = load volatile float, float addrspace(1)* %in.gep.0, align 4
33 %val1 = load volatile float, float addrspace(1)* %in.gep.1, align 4
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000034 %add.x.0 = add nsw i32 %x.i, 128
David Blaikie79e6c742015-02-27 19:29:02 +000035 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x.0
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000036 store float %val0, float addrspace(3)* %arrayidx0, align 4
37 %add.x.1 = add nsw i32 %x.i, 320
David Blaikie79e6c742015-02-27 19:29:02 +000038 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x.1
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000039 store float %val1, float addrspace(3)* %arrayidx1, align 4
40 ret void
41}
42
43; SI-LABEL: @simple_write2st64_two_val_max_offset_f32
Tom Stellard326d6ec2014-11-05 14:50:53 +000044; SI-DAG: buffer_load_dword [[VAL0:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
Matt Arsenaultfb13b222014-12-03 03:12:13 +000045; SI-DAG: buffer_load_dword [[VAL1:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
Tom Stellard326d6ec2014-11-05 14:50:53 +000046; SI-DAG: v_lshlrev_b32_e32 [[VPTR:v[0-9]+]], 2, v{{[0-9]+}}
Tom Stellard1f3416a2015-04-08 01:09:19 +000047; SI: ds_write2st64_b32 [[VPTR]], [[VAL0]], [[VAL1]] offset1:255
Tom Stellard326d6ec2014-11-05 14:50:53 +000048; SI: s_endpgm
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000049define void @simple_write2st64_two_val_max_offset_f32(float addrspace(1)* %C, float addrspace(1)* %in, float addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000050 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000051 %in.gep.0 = getelementptr float, float addrspace(1)* %in, i32 %x.i
52 %in.gep.1 = getelementptr float, float addrspace(1)* %in.gep.0, i32 1
Matt Arsenault44e54832016-04-12 13:38:18 +000053 %val0 = load volatile float, float addrspace(1)* %in.gep.0, align 4
54 %val1 = load volatile float, float addrspace(1)* %in.gep.1, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000055 %arrayidx0 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %x.i
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000056 store float %val0, float addrspace(3)* %arrayidx0, align 4
57 %add.x = add nsw i32 %x.i, 16320
David Blaikie79e6c742015-02-27 19:29:02 +000058 %arrayidx1 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %add.x
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000059 store float %val1, float addrspace(3)* %arrayidx1, align 4
60 ret void
61}
62
63; SI-LABEL: @simple_write2st64_two_val_max_offset_f64
Tom Stellard326d6ec2014-11-05 14:50:53 +000064; SI-DAG: buffer_load_dwordx2 [[VAL0:v\[[0-9]+:[0-9]+\]]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
Matt Arsenaultfb13b222014-12-03 03:12:13 +000065; SI-DAG: buffer_load_dwordx2 [[VAL1:v\[[0-9]+:[0-9]+\]]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000066; SI-DAG: v_add_i32_e32 [[VPTR:v[0-9]+]],
Tom Stellardeb05c612015-02-26 17:08:43 +000067; SI: ds_write2st64_b64 [[VPTR]], [[VAL0]], [[VAL1]] offset0:4 offset1:127
Tom Stellard326d6ec2014-11-05 14:50:53 +000068; SI: s_endpgm
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000069define void @simple_write2st64_two_val_max_offset_f64(double addrspace(1)* %C, double addrspace(1)* %in, double addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000070 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000071 %in.gep.0 = getelementptr double, double addrspace(1)* %in, i32 %x.i
72 %in.gep.1 = getelementptr double, double addrspace(1)* %in.gep.0, i32 1
Matt Arsenault44e54832016-04-12 13:38:18 +000073 %val0 = load volatile double, double addrspace(1)* %in.gep.0, align 8
74 %val1 = load volatile double, double addrspace(1)* %in.gep.1, align 8
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000075 %add.x.0 = add nsw i32 %x.i, 256
David Blaikie79e6c742015-02-27 19:29:02 +000076 %arrayidx0 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %add.x.0
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000077 store double %val0, double addrspace(3)* %arrayidx0, align 8
78 %add.x.1 = add nsw i32 %x.i, 8128
David Blaikie79e6c742015-02-27 19:29:02 +000079 %arrayidx1 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %add.x.1
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000080 store double %val1, double addrspace(3)* %arrayidx1, align 8
81 ret void
82}
83
84; SI-LABEL: @byte_size_only_divisible_64_write2st64_f64
Tom Stellard326d6ec2014-11-05 14:50:53 +000085; SI-NOT: ds_write2st64_b64
Tom Stellard1f3416a2015-04-08 01:09:19 +000086; SI: ds_write2_b64 {{v[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{v\[[0-9]+:[0-9]+\]}} offset1:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000087; SI: s_endpgm
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000088define void @byte_size_only_divisible_64_write2st64_f64(double addrspace(1)* %C, double addrspace(1)* %in, double addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000089 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000090 %in.gep = getelementptr double, double addrspace(1)* %in, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +000091 %val = load double, double addrspace(1)* %in.gep, align 8
David Blaikie79e6c742015-02-27 19:29:02 +000092 %arrayidx0 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %x.i
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000093 store double %val, double addrspace(3)* %arrayidx0, align 8
94 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +000095 %arrayidx1 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %add.x
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000096 store double %val, double addrspace(3)* %arrayidx1, align 8
97 ret void
98}
99
100; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000101declare i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +0000102
103; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000104declare i32 @llvm.amdgcn.workitem.id.y() #1
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +0000105
106attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
107attributes #1 = { nounwind readnone }
Matt Arsenault2aed6ca2015-12-19 01:46:41 +0000108attributes #2 = { convergent nounwind }