brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.9 KiB · 82ac429 Raw
248 lines · plain
1; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp -passes=loop-vectorize -tail-predication=enabled -S < %s | \2; RUN:  FileCheck %s3 4target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"5 6; Test that ARMTTIImpl::preferPredicateOverEpilogue triggers tail-folding.7 8define dso_local void @f1(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, ptr noalias nocapture readonly %C, i32 %N) {9; CHECK-LABEL: f1(10; CHECK:       entry:11; CHECK:       @llvm.get.active.lane.mask12; CHECK:       }13entry:14  %cmp8 = icmp sgt i32 %N, 015  br i1 %cmp8, label %for.body.preheader, label %for.cond.cleanup16 17for.body.preheader:                               ; preds = %entry18  br label %for.body19 20for.cond.cleanup.loopexit:                        ; preds = %for.body21  br label %for.cond.cleanup22 23for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry24  ret void25 26for.body:                                         ; preds = %for.body.preheader, %for.body27  %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]28  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %i.0929  %0 = load i32, ptr %arrayidx, align 430  %arrayidx1 = getelementptr inbounds i32, ptr %C, i32 %i.0931  %1 = load i32, ptr %arrayidx1, align 432  %add = add nsw i32 %1, %033  %arrayidx2 = getelementptr inbounds i32, ptr %A, i32 %i.0934  store i32 %add, ptr %arrayidx2, align 435  %inc = add nuw nsw i32 %i.09, 136  %exitcond.not = icmp eq i32 %inc, %N37  br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body38}39 40define dso_local void @f32_reduction(ptr nocapture readonly %Input, i32 %N, ptr nocapture %Output) {41; CHECK-LABEL: f32_reduction(42; CHECK:       vector.body:43; CHECK:       @llvm.masked.load44; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body45entry:46  %cmp6 = icmp eq i32 %N, 047  br i1 %cmp6, label %while.end, label %while.body.preheader48 49while.body.preheader:                             ; preds = %entry50  br label %while.body51 52while.body:                                       ; preds = %while.body.preheader, %while.body53  %blkCnt.09 = phi i32 [ %dec, %while.body ], [ %N, %while.body.preheader ]54  %sum.08 = phi float [ %add, %while.body ], [ 0.000000e+00, %while.body.preheader ]55  %Input.addr.07 = phi ptr [ %incdec.ptr, %while.body ], [ %Input, %while.body.preheader ]56  %incdec.ptr = getelementptr inbounds float, ptr %Input.addr.07, i32 157  %0 = load float, ptr %Input.addr.07, align 458  %add = fadd fast float %0, %sum.0859  %dec = add i32 %blkCnt.09, -160  %cmp = icmp eq i32 %dec, 061  br i1 %cmp, label %while.end.loopexit, label %while.body62 63while.end.loopexit:                               ; preds = %while.body64  %add.lcssa = phi float [ %add, %while.body ]65  br label %while.end66 67while.end:                                        ; preds = %while.end.loopexit, %entry68  %sum.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add.lcssa, %while.end.loopexit ]69  %conv = uitofp i32 %N to float70  %div = fdiv fast float %sum.0.lcssa, %conv71  store float %div, ptr %Output, align 472  ret void73}74 75define dso_local void @f16_reduction(ptr nocapture readonly %Input, i32 %N, ptr nocapture %Output) {76; CHECK-LABEL: f16_reduction(77; CHECK:       vector.body:78; CHECK:       @llvm.masked.load79; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body80entry:81  %cmp6 = icmp eq i32 %N, 082  br i1 %cmp6, label %while.end, label %while.body.preheader83 84while.body.preheader:                             ; preds = %entry85  br label %while.body86 87while.body:                                       ; preds = %while.body.preheader, %while.body88  %blkCnt.09 = phi i32 [ %dec, %while.body ], [ %N, %while.body.preheader ]89  %sum.08 = phi half [ %add, %while.body ], [ 0.000000e+00, %while.body.preheader ]90  %Input.addr.07 = phi ptr [ %incdec.ptr, %while.body ], [ %Input, %while.body.preheader ]91  %incdec.ptr = getelementptr inbounds half, ptr %Input.addr.07, i32 192  %0 = load half, ptr %Input.addr.07, align 293  %add = fadd fast half %0, %sum.0894  %dec = add i32 %blkCnt.09, -195  %cmp = icmp eq i32 %dec, 096  br i1 %cmp, label %while.end.loopexit, label %while.body97 98while.end.loopexit:                               ; preds = %while.body99  %add.lcssa = phi half [ %add, %while.body ]100  br label %while.end101 102while.end:                                        ; preds = %while.end.loopexit, %entry103  %sum.0.lcssa = phi half [ 0.000000e+00, %entry ], [ %add.lcssa, %while.end.loopexit ]104  %conv = uitofp i32 %N to half105  %div = fdiv fast half %sum.0.lcssa, %conv106  store half %div, ptr %Output, align 2107  ret void108}109 110define dso_local void @mixed_f32_i32_reduction(ptr nocapture readonly %fInput, ptr nocapture readonly %iInput, i32 %N, ptr nocapture %fOutput, ptr nocapture %iOutput) {111; CHECK-LABEL: mixed_f32_i32_reduction(112; CHECK:       vector.body:113; CHECK:       @llvm.masked.load114; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body115entry:116  %cmp15 = icmp eq i32 %N, 0117  br i1 %cmp15, label %while.end, label %while.body.preheader118 119while.body.preheader:120  br label %while.body121 122while.body:123  %blkCnt.020 = phi i32 [ %dec, %while.body ], [ %N, %while.body.preheader ]124  %isum.019 = phi i32 [ %add2, %while.body ], [ 0, %while.body.preheader ]125  %fsum.018 = phi float [ %add, %while.body ], [ 0.000000e+00, %while.body.preheader ]126  %fInput.addr.017 = phi ptr [ %incdec.ptr, %while.body ], [ %fInput, %while.body.preheader ]127  %iInput.addr.016 = phi ptr [ %incdec.ptr1, %while.body ], [ %iInput, %while.body.preheader ]128  %incdec.ptr = getelementptr inbounds float, ptr %fInput.addr.017, i32 1129  %incdec.ptr1 = getelementptr inbounds i32, ptr %iInput.addr.016, i32 1130  %0 = load i32, ptr %iInput.addr.016, align 4131  %add2 = add nsw i32 %0, %isum.019132  %1 = load float, ptr %fInput.addr.017, align 4133  %add = fadd fast float %1, %fsum.018134  %dec = add i32 %blkCnt.020, -1135  %cmp = icmp eq i32 %dec, 0136  br i1 %cmp, label %while.end.loopexit, label %while.body137 138while.end.loopexit:139  %add.lcssa = phi float [ %add, %while.body ]140  %add2.lcssa = phi i32 [ %add2, %while.body ]141  %phitmp = sitofp i32 %add2.lcssa to float142  br label %while.end143 144while.end:145  %fsum.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add.lcssa, %while.end.loopexit ]146  %isum.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %phitmp, %while.end.loopexit ]147  %conv = uitofp i32 %N to float148  %div = fdiv fast float %fsum.0.lcssa, %conv149  store float %div, ptr %fOutput, align 4150  %div5 = fdiv fast float %isum.0.lcssa, %conv151  %conv6 = fptosi float %div5 to i32152  store i32 %conv6, ptr %iOutput, align 4153  ret void154}155 156define dso_local i32 @i32_mul_reduction(ptr noalias nocapture readonly %B, i32 %N) {157; CHECK-LABEL: i32_mul_reduction(158; CHECK:       vector.body:159; CHECK:       @llvm.masked.load160; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body161entry:162  %cmp6 = icmp sgt i32 %N, 0163  br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup164 165for.body.preheader:166  br label %for.body167 168for.cond.cleanup.loopexit:169  %mul.lcssa = phi i32 [ %mul, %for.body ]170  br label %for.cond.cleanup171 172for.cond.cleanup:173  %S.0.lcssa = phi i32 [ 1, %entry ], [ %mul.lcssa, %for.cond.cleanup.loopexit ]174  ret i32 %S.0.lcssa175 176for.body:177  %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]178  %S.07 = phi i32 [ %mul, %for.body ], [ 1, %for.body.preheader ]179  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %i.08180  %0 = load i32, ptr %arrayidx, align 4181  %mul = mul nsw i32 %0, %S.07182  %inc = add nuw nsw i32 %i.08, 1183  %exitcond = icmp eq i32 %inc, %N184  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body185}186 187define dso_local i32 @i32_or_reduction(ptr noalias nocapture readonly %B, i32 %N) {188; CHECK-LABEL: i32_or_reduction(189; CHECK:       vector.body:190; CHECK:       @llvm.masked.load191; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body192entry:193  %cmp6 = icmp sgt i32 %N, 0194  br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup195 196for.body.preheader:                               ; preds = %entry197  br label %for.body198 199for.cond.cleanup.loopexit:                        ; preds = %for.body200  %or.lcssa = phi i32 [ %or, %for.body ]201  br label %for.cond.cleanup202 203for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry204  %S.0.lcssa = phi i32 [ 1, %entry ], [ %or.lcssa, %for.cond.cleanup.loopexit ]205  ret i32 %S.0.lcssa206 207for.body:                                         ; preds = %for.body.preheader, %for.body208  %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]209  %S.07 = phi i32 [ %or, %for.body ], [ 1, %for.body.preheader ]210  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %i.08211  %0 = load i32, ptr %arrayidx, align 4212  %or = or i32 %0, %S.07213  %inc = add nuw nsw i32 %i.08, 1214  %exitcond = icmp eq i32 %inc, %N215  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body216}217 218define dso_local i32 @i32_and_reduction(ptr noalias nocapture readonly %A, i32 %N, i32 %S) {219; CHECK-LABEL: i32_and_reduction(220; CHECK:       vector.body:221; CHECK:       @llvm.masked.load222; CHECK:       br i1 %{{.*}}, label {{.*}}, label %vector.body223entry:224  %cmp5 = icmp sgt i32 %N, 0225  br i1 %cmp5, label %for.body.preheader, label %for.cond.cleanup226 227for.body.preheader:                               ; preds = %entry228  br label %for.body229 230for.cond.cleanup.loopexit:                        ; preds = %for.body231  %and.lcssa = phi i32 [ %and, %for.body ]232  br label %for.cond.cleanup233 234for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry235  %S.addr.0.lcssa = phi i32 [ %S, %entry ], [ %and.lcssa, %for.cond.cleanup.loopexit ]236  ret i32 %S.addr.0.lcssa237 238for.body:                                         ; preds = %for.body.preheader, %for.body239  %i.07 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]240  %S.addr.06 = phi i32 [ %and, %for.body ], [ %S, %for.body.preheader ]241  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.07242  %0 = load i32, ptr %arrayidx, align 4243  %and = and i32 %0, %S.addr.06244  %inc = add nuw nsw i32 %i.07, 1245  %exitcond = icmp eq i32 %inc, %N246  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body247}248