Home | History | Annotate | Download | only in LoopInterchange
      1 ; REQUIRES: asserts
      2 ; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -verify-loop-info \
      3 ; RUN:     -S -debug 2>&1 | FileCheck %s
      4 
      5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      6 target triple = "x86_64-unknown-linux-gnu"
      7 
      8 @A = common global [100 x [100 x i32]] zeroinitializer
      9 @B = common global [100 x i32] zeroinitializer
     10 
     11 ;; Loops should not be interchanged in this case as it is not legal due to dependency.
     12 ;;  for(int j=0;j<99;j++)
     13 ;;   for(int i=0;i<99;i++)
     14 ;;       A[j][i+1] = A[j+1][i]+k;
     15 
     16 ; CHECK: Not interchanging loops. Cannot prove legality.
     17 
     18 define void @interchange_04(i32 %k){
     19 entry:
     20   br label %for.cond1.preheader
     21 
     22 for.cond1.preheader:
     23   %indvars.iv23 = phi i64 [ 0, %entry ], [ %indvars.iv.next24, %for.inc12 ]
     24   %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
     25   br label %for.body3
     26 
     27 for.body3:
     28   %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body3 ]
     29   %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next24, i64 %indvars.iv
     30   %0 = load i32, i32* %arrayidx5
     31   %add6 = add nsw i32 %0, %k
     32   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
     33   %arrayidx11 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv23, i64 %indvars.iv.next
     34   store i32 %add6, i32* %arrayidx11
     35   %exitcond = icmp eq i64 %indvars.iv.next, 99
     36   br i1 %exitcond, label %for.inc12, label %for.body3
     37 
     38 for.inc12:
     39   %exitcond25 = icmp eq i64 %indvars.iv.next24, 99
     40   br i1 %exitcond25, label %for.end14, label %for.cond1.preheader
     41 
     42 for.end14:
     43   ret void
     44 }
     45