1 ; RUN: opt < %s -passes=slsr,nary-reassociate -S | FileCheck %s
2 ; RUN: opt < %s -passes=slsr -S | opt -passes='nary-reassociate' -S | FileCheck %s
3 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefix=PTX
5 target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
8 ; foo((a + b * 2) + c);
9 ; foo((a + b * 3) + c);
17 define void @nary_reassociate_after_slsr(i32 %a, i32 %b, i32 %c) {
18 ; CHECK-LABEL: @nary_reassociate_after_slsr(
19 ; PTX-LABEL: .visible .func nary_reassociate_after_slsr(
20 ; PTX: ld.param.u32 [[b:%r[0-9]+]], [nary_reassociate_after_slsr_param_1];
22 %abc = add i32 %ab, %c
23 call void @foo(i32 %abc)
24 ; CHECK: call void @foo(i32 %abc)
25 ; PTX: st.param.b32 [param0+0], [[abc:%r[0-9]+]];
28 %ab2 = add i32 %a, %b2
29 %ab2c = add i32 %ab2, %c
30 ; CHECK-NEXT: %ab2c = add i32 %abc, %b
31 ; PTX: add.s32 [[ab2c:%r[0-9]+]], [[abc]], [[b]]
32 call void @foo(i32 %ab2c)
33 ; CHECK-NEXT: call void @foo(i32 %ab2c)
34 ; PTX: st.param.b32 [param0+0], [[ab2c]];
37 %ab3 = add i32 %a, %b3
38 %ab3c = add i32 %ab3, %c
39 ; CHECK-NEXT: %ab3c = add i32 %ab2c, %b
40 ; PTX: add.s32 [[ab3c:%r[0-9]+]], [[ab2c]], [[b]]
41 call void @foo(i32 %ab3c)
42 ; CHECK-NEXT: call void @foo(i32 %ab3c)
43 ; PTX: st.param.b32 [param0+0], [[ab3c]];
48 declare void @foo(i32)