1 ; RUN: opt < %s -separate-const-offset-from-gep -slsr -gvn -S | FileCheck %s
2 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_35 | FileCheck %s --check-prefix=PTX
3 ; RUN: opt < %s -passes="separate-const-offset-from-gep,slsr,gvn" -S | FileCheck %s
5 target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
6 target triple = "nvptx64-unknown-unknown"
30 define void @slsr_after_reassociate_geps(float* %arr, i32 %i) {
31 ; CHECK-LABEL: @slsr_after_reassociate_geps(
32 ; PTX-LABEL: .visible .func slsr_after_reassociate_geps(
33 ; PTX: ld.param.u64 [[arr:%rd[0-9]+]], [slsr_after_reassociate_geps_param_0];
34 ; PTX: ld.param.u32 [[i:%r[0-9]+]], [slsr_after_reassociate_geps_param_1];
35 %i2 = shl nsw i32 %i, 1
36 %i3 = mul nsw i32 %i, 3
37 %i4 = shl nsw i32 %i, 2
39 %j1 = add nsw i32 %i, 5
40 %p1 = getelementptr inbounds float, float* %arr, i32 %j1
41 ; CHECK: [[b1:%[0-9]+]] = getelementptr float, float* %arr, i64 [[bump:%[0-9]+]]
42 ; PTX: mul.wide.s32 [[i4:%rd[0-9]+]], [[i]], 4;
43 ; PTX: add.s64 [[base1:%rd[0-9]+]], [[arr]], [[i4]];
44 %v1 = load float, float* %p1, align 4
45 ; PTX: ld.f32 {{%f[0-9]+}}, {{\[}}[[base1]]+20];
46 call void @foo(float %v1)
48 %j2 = add nsw i32 %i2, 5
49 %p2 = getelementptr inbounds float, float* %arr, i32 %j2
50 ; CHECK: [[b2:%[0-9]+]] = getelementptr float, float* [[b1]], i64 [[bump]]
51 ; PTX: add.s64 [[base2:%rd[0-9]+]], [[base1]], [[i4]];
52 %v2 = load float, float* %p2, align 4
53 ; PTX: ld.f32 {{%f[0-9]+}}, {{\[}}[[base2]]+20];
54 call void @foo(float %v2)
56 %j3 = add nsw i32 %i3, 5
57 %p3 = getelementptr inbounds float, float* %arr, i32 %j3
58 ; CHECK: [[b3:%[0-9]+]] = getelementptr float, float* [[b2]], i64 [[bump]]
59 ; PTX: add.s64 [[base3:%rd[0-9]+]], [[base2]], [[i4]];
60 %v3 = load float, float* %p3, align 4
61 ; PTX: ld.f32 {{%f[0-9]+}}, {{\[}}[[base3]]+20];
62 call void @foo(float %v3)
64 %j4 = add nsw i32 %i4, 5
65 %p4 = getelementptr inbounds float, float* %arr, i32 %j4
66 ; CHECK: [[b4:%[0-9]+]] = getelementptr float, float* [[b3]], i64 [[bump]]
67 ; PTX: add.s64 [[base4:%rd[0-9]+]], [[base3]], [[i4]];
68 %v4 = load float, float* %p4, align 4
69 ; PTX: ld.f32 {{%f[0-9]+}}, {{\[}}[[base4]]+20];
70 call void @foo(float %v4)
75 declare void @foo(float)