47 lines · plain
1// DEFINE: %{triple} =2// DEFINE: %{check-unroll} = %flang_fc1 -emit-llvm -O1 -vectorize-loops -funroll-loops -mllvm -force-vector-width=2 -triple %{triple} -o- %s | FileCheck %s --check-prefixes=CHECK,UNROLL3// DEFINE: %{check-nounroll} = %flang_fc1 -emit-llvm -O1 -vectorize-loops -mllvm -force-vector-width=2 -triple %{triple} -o- %s | FileCheck %s --check-prefixes=CHECK,NO-UNROLL4 5// REDEFINE: %{triple} = aarch64-unknown-linux-gnu6// RUN: %if aarch64-registered-target %{ %{check-unroll} %}7// RUN: %if aarch64-registered-target %{ %{check-nounroll} %}8 9// REDEFINE: %{triple} = x86_64-unknown-linux-gnu10// RUN: %if x86-registered-target %{ %{check-unroll} %}11// RUN: %if x86-registered-target %{ %{check-nounroll} %}12 13// CHECK-LABEL: @unroll14// CHECK-SAME: (ptr {{[^%]*}}%[[ARG0:.*]])15func.func @unroll(%arg0: !fir.ref<!fir.array<1000 x index>> {fir.bindc_name = "a"}) {16 %scope = fir.dummy_scope : !fir.dscope17 %c1000 = arith.constant 1000 : index18 %shape = fir.shape %c1000 : (index) -> !fir.shape<1>19 %a:2 = hlfir.declare %arg0(%shape) dummy_scope %scope {uniq_name = "unrollEa"} : (!fir.ref<!fir.array<1000xindex>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<1000 x index>>, !fir.ref<!fir.array<1000 x index>>)20 %c1 = arith.constant 1 : index21 fir.do_loop %arg1 = %c1 to %c1000 step %c1 {22 // CHECK: br label %[[BLK:.*]]23 // CHECK: [[BLK]]:24 // CHECK-NEXT: %[[IND:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[NIV:.*]], %[[BLK]] ]25 // CHECK-NEXT: %[[VIND:.*]] = phi <2 x i64> [ <i64 1, i64 2>, %{{.*}} ], [ %[[NVIND:.*]], %[[BLK]] ]26 27 // NO-UNROLL-NEXT: %[[GEP:.*]] = getelementptr i64, ptr %[[ARG0]], i64 %[[IND]]28 // NO-UNROLL-NEXT: store <2 x i64> %[[VIND]], ptr %[[GEP]]29 // NO-UNROLL-NEXT: %[[NIV:.*]] = add nuw i64 %{{.*}}, 230 // NO-UNROLL-NEXT: %[[NVIND]] = add nuw nsw <2 x i64> %[[VIND]], splat (i64 2)31 32 // UNROLL-NEXT: %[[VIND1:.*]] = add <2 x i64> %[[VIND]], splat (i64 2)33 // UNROLL-NEXT: %[[GEP0:.*]] = getelementptr i64, ptr %[[ARG0]], i64 %[[IND]]34 // UNROLL-NEXT: %[[GEP1:.*]] = getelementptr i8, ptr %[[GEP0]], i64 1635 // UNROLL-NEXT: store <2 x i64> %[[VIND]], ptr %[[GEP0]]36 // UNROLL-NEXT: store <2 x i64> %[[VIND1]], ptr %[[GEP1]]37 // UNROLL-NEXT: %[[NIV:.*]] = add nuw i64 %[[IND]], 438 // UNROLL-NEXT: %[[NVIND:.*]] = add <2 x i64> %[[VIND]], splat (i64 4)39 40 // CHECK-NEXT: %[[EXIT:.*]] = icmp eq i64 %[[NIV]], 100041 // CHECK-NEXT: br i1 %[[EXIT]], label %{{.*}}, label %[[BLK]]42 %ai = hlfir.designate %a#0 (%arg1) : (!fir.ref<!fir.array<1000 x index>>, index) -> !fir.ref<index>43 hlfir.assign %arg1 to %ai : index, !fir.ref<index>44 }45 return46}47