xref: /llvm-project/llvm/test/Transforms/CodeGenPrepare/LoongArch/splitgep.ll (revision 9d4f7f44b64d87d1068859906f43b7ce03a7388b)
1; RUN: opt --mtriple=loongarch64 -mattr=+d -S --passes='require<profile-summary>,function(codegenprepare)' %s | FileCheck %s
2
3; Check that we have deterministic output
4define void @test(ptr %sp, ptr %t, i32 %n) {
5; CHECK-LABEL: @test(
6; CHECK-NEXT:  entry:
7; CHECK-NEXT:    %splitgep1 = getelementptr i8, ptr %t, i64 80000
8; CHECK-NEXT:    %s = load ptr, ptr %sp
9; CHECK-NEXT:    %splitgep = getelementptr i8, ptr %s, i64 80000
10entry:
11  %s = load ptr, ptr %sp
12  br label %while_cond
13
14while_cond:
15  %phi = phi i32 [ 0, %entry ], [ %i, %while_body ]
16  %gep0 = getelementptr [65536 x i32], ptr %s, i64 0, i64 20000
17  %gep1 = getelementptr [65536 x i32], ptr %s, i64 0, i64 20001
18  %gep2 = getelementptr [65536 x i32], ptr %t, i64 0, i64 20000
19  %gep3 = getelementptr [65536 x i32], ptr %t, i64 0, i64 20001
20  %cmp = icmp slt i32 %phi, %n
21  br i1 %cmp, label %while_body, label %while_end
22
23while_body:
24  %i = add i32 %phi, 1
25  store i32 %i, ptr %gep0
26  store i32 %phi, ptr %gep1
27  store i32 %i, ptr %gep2
28  store i32 %phi, ptr %gep3
29  br label %while_cond
30
31while_end:
32  ret void
33}
34
35