xref: /llvm-project/llvm/test/Transforms/LICM/allow-speculation-option.ll (revision edc1bcfc24e2a676e013775eb71a951e49b9d4f1)
1; RUN: opt -passes='loop-mssa(licm<allowspeculation>)' -S %s | FileCheck --check-prefixes=COMMON,SPEC_ON %s
2; RUN: opt -passes='loop-mssa(licm<no-allowspeculation>)' -S %s | FileCheck --check-prefixes=COMMON,SPEC_OFF %s
3; RUN: opt -passes='licm<no-allowspeculation>' -S %s | FileCheck --check-prefixes=COMMON,SPEC_OFF %s
4; RUN: opt -passes='loop-mssa(lnicm<allowspeculation>)' -S %s | FileCheck --check-prefixes=COMMON,SPEC_ON %s
5; RUN: opt -passes='loop-mssa(lnicm<no-allowspeculation>)' -S %s | FileCheck --check-prefixes=COMMON,SPEC_OFF %s
6; RUN: opt -passes='lnicm<no-allowspeculation>' -S %s | FileCheck --check-prefixes=COMMON,SPEC_OFF %s
7
8define void @test(ptr %ptr, i32 %N) {
9; COMMON-LABEL: @test(
10; COMMON-NEXT:  entry:
11; SPEC_ON-NEXT:   [[GEP:%.*]] = getelementptr [10 x i32], ptr [[PTR:%.*]], i32 0, i32 1
12; COMMON-NEXT:    br label [[LOOP_HEADER:%.*]]
13; COMMON:       loop.header:
14; COMMON-NEXT:    [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
15; COMMON-NEXT:    [[CMP:%.*]] = icmp ult i32 [[IV]], [[N:%.*]]
16; COMMON-NEXT:    br i1 [[CMP]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
17; COMMON:       loop.latch:
18; SPEC_OFF-NEXT:  [[GEP:%.*]] = getelementptr [10 x i32], ptr [[PTR:%.*]], i32 0, i32 1
19; COMMON-NEXT:    [[GEP_IV:%.*]] = getelementptr i32, ptr [[GEP]], i32 [[IV]]
20; COMMON-NEXT:    store i32 9999, ptr [[GEP_IV]], align 4
21; COMMON-NEXT:    [[IV_NEXT]] = add i32 [[IV]], 1
22; COMMON-NEXT:    br label [[LOOP_HEADER]]
23; COMMON:       exit:
24; COMMON-NEXT:    ret void
25;
26entry:
27  br label %loop.header
28
29loop.header:
30  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
31  %cmp = icmp ult i32 %iv, %N
32  br i1 %cmp, label %loop.latch, label %exit
33
34loop.latch:
35  %gep = getelementptr [10 x i32], ptr %ptr, i32 0, i32 1
36  %gep.iv = getelementptr i32, ptr %gep, i32 %iv
37  store i32 9999, ptr %gep.iv
38  %iv.next = add i32 %iv, 1
39  br label %loop.header
40
41exit:
42  ret void
43}
44