brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 071a12c Raw
109 lines · plain
1; RUN: opt < %s -S -passes='loop(loop-flatten),verify' -verify-loop-info -verify-dom-info -verify-scev | FileCheck %s2 3target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"4 5; Test case and IR corresponding to this code:6;7; int k = 0;8; for(int i = 0; i < n; i++)9;   for(int j = 0; j < n; j++) {10;     A[k] = B[k];11;     k++;12;   }13;14; TODO: this case doesn't trigger yet.15;16define dso_local void @v0(i32 %n, ptr nocapture %A, ptr nocapture readonly %B) local_unnamed_addr #0 {17;18; CHECK-LABEL: @v019; CHECK-NOT:   %flatten.tripcount = mul i32 %n, %n20;21entry:22  %cmp21 = icmp sgt i32 %n, 023  br i1 %cmp21, label %for.cond1.preheader.us.preheader, label %for.cond.cleanup24 25for.cond1.preheader.us.preheader:26  br label %for.cond1.preheader.us27 28for.cond1.preheader.us:29  %i.023.us = phi i32 [ %inc8.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]30  %k.022.us = phi i32 [ %inc.us.lcssa, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]31  %0 = add i32 %n, %k.022.us32  br label %for.body4.us33 34for.body4.us:35  %k.119.us = phi i32 [ %k.022.us, %for.cond1.preheader.us ], [ %inc.us, %for.body4.us ]36  %arrayidx.us = getelementptr inbounds i32, ptr %B, i32 %k.119.us37  %1 = load i32, ptr %arrayidx.us, align 438  %arrayidx5.us = getelementptr inbounds i32, ptr %A, i32 %k.119.us39  store i32 %1, ptr %arrayidx5.us, align 440  %inc.us = add i32 %k.119.us, 141  %exitcond = icmp ne i32 %inc.us, %042  br i1 %exitcond, label %for.body4.us, label %for.cond1.for.cond.cleanup3_crit_edge.us43 44for.cond1.for.cond.cleanup3_crit_edge.us:45  %inc.us.lcssa = phi i32 [ %inc.us, %for.body4.us ]46  %inc8.us = add nuw nsw i32 %i.023.us, 147  %cmp.us = icmp slt i32 %inc8.us, %n48  br i1 %cmp.us, label %for.cond1.preheader.us, label %for.cond.cleanup.loopexit49 50for.cond.cleanup.loopexit:51  br label %for.cond.cleanup52 53for.cond.cleanup:54  ret void55}56 57; Test case and IR corresponding to this code:58;59; for(int i = 0; i < n; i++)60;   for(int j = 0; j < n; j++) {61;     int k = i*n+j;62;     A[k] = B[k];63;     k++;64;   }65;66define dso_local void @v1(i32 %n, ptr nocapture %A, ptr nocapture readonly %B) local_unnamed_addr #0 {67;68; CHECK-LABEL: @v169; CHECK:       for.cond1.preheader.us.preheader:70; CHECK:         %flatten.tripcount = mul i32 %n, %n71; CHECK:       for.cond1.for.cond.cleanup3_crit_edge.us:72; CHECK:         %inc8.us = add nuw nsw i32 %i.024.us, 173; CHECK:         %cmp.us = icmp slt i32 %inc8.us, %flatten.tripcount74;75entry:76  %cmp23 = icmp sgt i32 %n, 077  br i1 %cmp23, label %for.cond1.preheader.us.preheader, label %for.cond.cleanup78 79for.cond1.preheader.us.preheader:80  br label %for.cond1.preheader.us81 82for.cond1.preheader.us:83  %i.024.us = phi i32 [ %inc8.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]84  %mul.us = mul nsw i32 %i.024.us, %n85  br label %for.body4.us86 87for.body4.us:88  %j.022.us = phi i32 [ 0, %for.cond1.preheader.us ], [ %inc6.us, %for.body4.us ]89  %add.us = add nsw i32 %j.022.us, %mul.us90  %arrayidx.us = getelementptr inbounds i32, ptr %B, i32 %add.us91  %0 = load i32, ptr %arrayidx.us, align 492  %arrayidx5.us = getelementptr inbounds i32, ptr %A, i32 %add.us93  store i32 %0, ptr %arrayidx5.us, align 494  %inc6.us = add nuw nsw i32 %j.022.us, 195  %exitcond = icmp ne i32 %inc6.us, %n96  br i1 %exitcond, label %for.body4.us, label %for.cond1.for.cond.cleanup3_crit_edge.us97 98for.cond1.for.cond.cleanup3_crit_edge.us:99  %inc8.us = add nuw nsw i32 %i.024.us, 1100  %cmp.us = icmp slt i32 %inc8.us, %n101  br i1 %cmp.us, label %for.cond1.preheader.us, label %for.cond.cleanup.loopexit102 103for.cond.cleanup.loopexit:104  br label %for.cond.cleanup105 106for.cond.cleanup:107  ret void108}109