brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 4f71959 Raw
167 lines · plain
1; RUN: opt -mtriple=aarch64 -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 < %s -S | FileCheck %s2 3; The following tests contain loops for which SCEV cannot determine the backedge4; taken count. This is because the backedge taken condition is produced by an5; icmp with one of the sides being a loop varying non-AddRec expression.6; However, there is a possibility to normalize this to an AddRec expression7; using SCEV predicates. This allows us to compute a 'guarded' backedge count.8; The Loop Vectorizer is able to version to loop in order to use this guarded9; backedge count and vectorize more loops.10 11 12; CHECK-LABEL: test_sge13; CHECK-LABEL: vector.scevcheck14; CHECK-LABEL: vector.body15define void @test_sge(ptr noalias %A,16                      ptr noalias %B,17                      ptr noalias %C, i32 %N) {18entry:19  %cmp13 = icmp eq i32 %N, 020  br i1 %cmp13, label %for.end, label %for.body.preheader21 22for.body.preheader:23  br label %for.body24 25for.body:26  %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ 0, %for.body.preheader ]27  %indvars.next = add i16 %indvars.iv, 128  %indvars.ext = zext i16 %indvars.iv to i3229 30  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext31  %0 = load i32, ptr %arrayidx, align 432  %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext33  %1 = load i32, ptr %arrayidx3, align 434 35  %mul4 = mul i32 %1, %036 37  %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext38  store i32 %mul4, ptr %arrayidx7, align 439 40  %exitcond = icmp sge i32 %indvars.ext, %N41  br i1 %exitcond, label %for.end.loopexit, label %for.body42 43for.end.loopexit:44  br label %for.end45 46for.end:47  ret void48}49 50; CHECK-LABEL: test_uge51; CHECK-LABEL: vector.scevcheck52; CHECK-LABEL: vector.body53define void @test_uge(ptr noalias %A,54                      ptr noalias %B,55                      ptr noalias %C, i32 %N, i32 %Offset) {56entry:57  %cmp13 = icmp eq i32 %N, 058  br i1 %cmp13, label %for.end, label %for.body.preheader59 60for.body.preheader:61  br label %for.body62 63for.body:64  %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ 0, %for.body.preheader ]65  %indvars.next = add i16 %indvars.iv, 166 67  %indvars.ext = sext i16 %indvars.iv to i3268  %indvars.access = add i32 %Offset, %indvars.ext69 70  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.access71  %0 = load i32, ptr %arrayidx, align 472  %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.access73  %1 = load i32, ptr %arrayidx3, align 474 75  %mul4 = add i32 %1, %076 77  %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.access78  store i32 %mul4, ptr %arrayidx7, align 479 80  %exitcond = icmp uge i32 %indvars.ext, %N81  br i1 %exitcond, label %for.end.loopexit, label %for.body82 83for.end.loopexit:84  br label %for.end85 86for.end:87  ret void88}89 90; CHECK-LABEL: test_ule91; CHECK-LABEL: vector.scevcheck92; CHECK-LABEL: vector.body93define void @test_ule(ptr noalias %A,94                      ptr noalias %B,95                      ptr noalias %C, i32 %N,96                      i16 %M) {97entry:98  %cmp13 = icmp eq i32 %N, 099  br i1 %cmp13, label %for.end, label %for.body.preheader100 101for.body.preheader:102  br label %for.body103 104for.body:105  %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ %M, %for.body.preheader ]106  %indvars.next = sub i16 %indvars.iv, 1107  %indvars.ext = zext i16 %indvars.iv to i32108 109  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext110  %0 = load i32, ptr %arrayidx, align 4111  %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext112  %1 = load i32, ptr %arrayidx3, align 4113 114  %mul4 = mul i32 %1, %0115 116  %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext117  store i32 %mul4, ptr %arrayidx7, align 4118 119  %exitcond = icmp ule i32 %indvars.ext, %N120  br i1 %exitcond, label %for.end.loopexit, label %for.body121 122for.end.loopexit:123  br label %for.end124 125for.end:126  ret void127}128 129; CHECK-LABEL: test_sle130; CHECK-LABEL: vector.scevcheck131; CHECK-LABEL: vector.body132define void @test_sle(ptr noalias %A,133                   ptr noalias %B,134                   ptr noalias %C, i32 %N,135                   i16 %M) {136entry:137  %cmp13 = icmp eq i32 %N, 0138  br i1 %cmp13, label %for.end, label %for.body.preheader139 140for.body.preheader:141  br label %for.body142 143for.body:144  %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ %M, %for.body.preheader ]145  %indvars.next = sub i16 %indvars.iv, 1146  %indvars.ext = sext i16 %indvars.iv to i32147 148  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext149  %0 = load i32, ptr %arrayidx, align 4150  %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext151  %1 = load i32, ptr %arrayidx3, align 4152 153  %mul4 = mul i32 %1, %0154 155  %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext156  store i32 %mul4, ptr %arrayidx7, align 4157 158  %exitcond = icmp sle i32 %indvars.ext, %N159  br i1 %exitcond, label %for.end.loopexit, label %for.body160 161for.end.loopexit:162  br label %for.end163 164for.end:165  ret void166}167