Debian Codegraph @

llvm/test/Transforms/LoopInterchange/call-instructions-remarks.ll

raw
1 ; REQUIRES: asserts
2 ; RUN: opt < %s -passes=loop-interchange -pass-remarks-missed='loop-interchange' -pass-remarks-output=%t -S \
3 ; RUN: -verify-dom-info -verify-loop-info 2>&1
4 ; RUN: FileCheck --input-file=%t %s
5
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7
8 @A = common global [100 x [100 x i32]] zeroinitializer
9
10 declare void @foo(i64 %a)
11 declare void @bar(i64 %a) readnone
12
13 ;;--------------------------------------Test case 01------------------------------------
14 ;; Not safe to interchange, because the called function `foo` is not marked as
15 ;; readnone, so it could introduce dependences.
16 ;;
17 ;; for(int i=0;i<100;i++) {
18 ;; for(int j=1;j<100;j++) {
19 ;; foo(i);
20 ;; A[j][i] = A[j][i]+k;
21 ;; }
22 ;; }
23
24 ; CHECK: --- !Missed
25 ; CHECK-NEXT: Pass: loop-interchange
26 ; CHECK-NEXT: Name: CallInst
27 ; CHECK-NEXT: Function: interchange_01
28 ; CHECK-NEXT: Args:
29 ; CHECK-NEXT: - String: Cannot interchange loops due to call instruction.
30
31 define void @interchange_01(i32 %k) {
32 entry:
33 br label %for1.header
34
35 for1.header:
36 %indvars.iv23 = phi i64 [ 0, %entry ], [ %indvars.iv.next24, %for1.inc10 ]
37 br label %for2
38
39 for2:
40 %indvars.iv = phi i64 [ %indvars.iv.next, %for2 ], [ 1, %for1.header ]
41 call void @foo(i64 %indvars.iv23)
42 %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], ptr @A, i64 0, i64 %indvars.iv, i64 %indvars.iv23
43 %lv = load i32, ptr %arrayidx5
44 %add = add nsw i32 %lv, %k
45 store i32 %add, ptr %arrayidx5
46 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
47 %exitcond = icmp eq i64 %indvars.iv, 99
48 br i1 %exitcond, label %for2.loopexit , label %for2
49
50 for2.loopexit:
51 br label %for1.inc10
52
53 for1.inc10:
54 %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
55 %exitcond26 = icmp eq i64 %indvars.iv23, 99
56 br i1 %exitcond26, label %for1.loopexit, label %for1.header
57
58 for1.loopexit:
59 br label %exit
60
61 exit:
62 ret void
63 }