brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 51fa646 Raw
118 lines · plain
1; REQUIRES: asserts2; RUN: opt < %s -passes=loop-interchange -verify-dom-info -verify-loop-info -S -debug 2>&1 | FileCheck %s3 4@A = common global [100 x [100 x i64]] zeroinitializer5@N = dso_local local_unnamed_addr global i64 100, align 86 7;  for(int i=0;i<100;i++)8;    for(int j=0;j<i;j++)9;      A[j][i] = A[j][i]+k;10;11; Inner loop induction variable exit condition depends on the12; outer loop induction variable, i.e., triangular loops.13;14; CHECK: Loop structure not understood by pass15; CHECK: Not interchanging loops. Cannot prove legality.16;17define void @interchange_01(i64 %k) {18entry:19  br label %for1.header20 21for1.header:22  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]23  br label %for224 25for2:26  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]27  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i28  %lv = load i64, ptr %arrayidx529  %add = add nsw i64 %lv, %k30  store i64 %add, ptr %arrayidx531  %j.next = add nuw nsw i64 %j, 132  %exitcond = icmp eq i64 %j, %i33  br i1 %exitcond, label %for1.inc10, label %for234 35for1.inc10:36  %i.next = add nuw nsw i64 %i, 137  %exitcond26 = icmp eq i64 %i, 9938  br i1 %exitcond26, label %for.end12, label %for1.header39 40for.end12:41  ret void42}43 44 45;  for(int i=0;i<100;i++)46;    for(int j=0;j+i<100;j++)47;      A[j][i] = A[j][i]+k;48;49; Inner loop induction variable exit condition depends on the50; outer loop induction variable, i.e., triangular loops.51;52; CHECK: Loop structure not understood by pass53; CHECK: Not interchanging loops. Cannot prove legality.54;55define void @interchange_02(i64 %k) {56entry:57  br label %for1.header58 59for1.header:60  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]61  br label %for262 63for2:64  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]65  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i66  %lv = load i64, ptr %arrayidx567  %add = add nsw i64 %lv, %k68  store i64 %add, ptr %arrayidx569  %0 = add nuw nsw i64 %j, %i70  %j.next = add nuw nsw i64 %j, 171  %exitcond = icmp eq i64 %0, 10072  br i1 %exitcond, label %for1.inc10, label %for273 74for1.inc10:75  %i.next = add nuw nsw i64 %i, 176  %exitcond26 = icmp eq i64 %i, 9977  br i1 %exitcond26, label %for.end12, label %for1.header78 79for.end12:80  ret void81}82 83;  for(int i=0;i<100;i++)84;    for(int j=0;i>j;j++)85;      A[j][i] = A[j][i]+k;86;87; Inner loop induction variable exit condition depends on the88; outer loop induction variable, i.e., triangular loops.89; CHECK: Loop structure not understood by pass90; CHECK: Not interchanging loops. Cannot prove legality.91;92define void @interchange_03(i64 %k) {93entry:94  br label %for1.header95 96for1.header:97  %i = phi i64 [ 0, %entry ], [ %i.next, %for1.inc10 ]98  br label %for299 100for2:101  %j = phi i64 [ %j.next, %for2 ], [ 0, %for1.header ]102  %arrayidx5 = getelementptr inbounds [100 x [100 x i64]], ptr @A, i64 0, i64 %j, i64 %i103  %lv = load i64, ptr %arrayidx5104  %add = add nsw i64 %lv, %k105  store i64 %add, ptr %arrayidx5106  %j.next = add nuw nsw i64 %j, 1107  %exitcond = icmp ne i64 %i, %j108  br i1 %exitcond, label %for2, label %for1.inc10109 110for1.inc10:111  %i.next = add nuw nsw i64 %i, 1112  %exitcond26 = icmp eq i64 %i, 99113  br i1 %exitcond26, label %for.end12, label %for1.header114 115for.end12:116  ret void117}118