101 lines · plain
1; Remove 'S' Scalar Dependencies #1193452; Scalar dependencies are not handled correctly, so they were removed to avoid3; miscompiles. The loop nest in this test case used to be interchanged, but it's4; no longer triggering. XFAIL'ing this test to indicate that this test should5; interchanged if scalar deps are handled correctly.6;7; XFAIL: *8 9; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 -verify-dom-info -verify-loop-info -pass-remarks-output=%t -disable-output10; RUN: FileCheck -input-file %t %s11 12target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"13 14@A = common global [100 x [100 x i32]] zeroinitializer15@B = common global [100 x i32] zeroinitializer16@C = common global [100 x [100 x i32]] zeroinitializer17@D = common global [100 x [100 x [100 x i32]]] zeroinitializer18@T = internal global [100 x double] zeroinitializer, align 419@Arr = internal global [1000 x [1000 x i32]] zeroinitializer, align 420 21; Test that a flow dependency in outer loop doesn't prevent interchange in22; loops i and j.23;24; for (int k = 0; k < 100; ++k) {25; T[k] = fn1();26; for (int i = 0; i < 1000; ++i)27; for(int j = 1; j < 1000; ++j)28; Arr[j][i] = Arr[j][i]+k;29; fn2(T[k]);30; }31;32; So, loops InnerLoopId = 2 and OuterLoopId = 1 should be interchanged,33; but not InnerLoopId = 1 and OuterLoopId = 0.34;35; CHECK: --- !Passed36; CHECK-NEXT: Pass: loop-interchange37; CHECK-NEXT: Name: Interchanged38; CHECK-NEXT: Function: interchange_0939; CHECK-NEXT: Args:40; CHECK-NEXT: - String: Loop interchanged with enclosing loop.41; CHECK-NEXT: ...42; CHECK-NEXT: --- !Missed43; CHECK-NEXT: Pass: loop-interchange44; CHECK-NEXT: Name: NotTightlyNested45; CHECK-NEXT: Function: interchange_0946; CHECK-NEXT: Args:47; CHECK-NEXT: - String: Cannot interchange loops because they are not tightly nested.48; CHECK-NEXT: ...49; CHECK-NEXT: --- !Missed50; CHECK-NEXT: Pass: loop-interchange51; CHECK-NEXT: Name: InterchangeNotProfitable52; CHECK-NEXT: Function: interchange_0953; CHECK-NEXT: Args:54; CHECK-NEXT: - String: Interchanging loops is not considered to improve cache locality nor vectorization.55; CHECK-NEXT: ...56 57define void @interchange_09(i32 %k) {58entry:59 br label %for.body60 61for.cond.cleanup: ; preds = %for.cond.cleanup462 ret void63 64for.body: ; preds = %for.cond.cleanup4, %entry65 %indvars.iv45 = phi i64 [ 0, %entry ], [ %indvars.iv.next46, %for.cond.cleanup4 ]66 %call = call double @fn1()67 %arrayidx = getelementptr inbounds [100 x double], ptr @T, i64 0, i64 %indvars.iv4568 store double %call, ptr %arrayidx, align 869 br label %for.cond6.preheader70 71for.cond6.preheader: ; preds = %for.cond.cleanup8, %for.body72 %indvars.iv42 = phi i64 [ 0, %for.body ], [ %indvars.iv.next43, %for.cond.cleanup8 ]73 br label %for.body974 75for.cond.cleanup4: ; preds = %for.cond.cleanup876 %tmp = load double, ptr %arrayidx, align 877 call void @fn2(double %tmp)78 %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 179 %exitcond47 = icmp ne i64 %indvars.iv.next46, 10080 br i1 %exitcond47, label %for.body, label %for.cond.cleanup81 82for.cond.cleanup8: ; preds = %for.body983 %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 184 %exitcond44 = icmp ne i64 %indvars.iv.next43, 100085 br i1 %exitcond44, label %for.cond6.preheader, label %for.cond.cleanup486 87for.body9: ; preds = %for.body9, %for.cond6.preheader88 %indvars.iv = phi i64 [ 1, %for.cond6.preheader ], [ %indvars.iv.next, %for.body9 ]89 %arrayidx13 = getelementptr inbounds [1000 x [1000 x i32]], ptr @Arr, i64 0, i64 %indvars.iv, i64 %indvars.iv4290 %t1 = load i32, ptr %arrayidx13, align 491 %t2 = trunc i64 %indvars.iv45 to i3292 %add = add nsw i32 %t1, %t293 store i32 %add, ptr %arrayidx13, align 494 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 195 %exitcond = icmp ne i64 %indvars.iv.next, 100096 br i1 %exitcond, label %for.body9, label %for.cond.cleanup897}98 99declare double @fn1() readnone100declare void @fn2(double) readnone101