brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.3 KiB · 6feaba0 Raw
198 lines · plain
1! Test scheduling of WHERE in lower-hlfir-ordered-assignments pass.2 3! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s4! REQUIRES: asserts5 6subroutine no_conflict(x, y)7  real :: x(:), y(:)8  where (y.gt.0) x = y9end subroutine10 11subroutine fake_conflict(x, y)12  ! The conflict here could be avoided because the read and write are13  ! aligned, so there would not be any read after write at the element14  ! level, but this will require a bit more work to detect this (like15  ! comparing the hlfir.designate operations).16  real :: x(:), y(:)17  where (x.gt.y) x = y18end subroutine19 20subroutine only_once(x, y, z)21  interface22    impure function call_me_only_once()23      logical :: call_me_only_once(10)24    end function25  end interface26  real :: x(:), y(:), z(:)27  where (call_me_only_once())28    x = y29    z = y30  end where31end subroutine32 33subroutine rhs_lhs_conflict(x, y)34  real :: x(:, :), y(:, :)35  where (y.gt.0.) x = transpose(x)36end subroutine37 38subroutine where_construct_no_conflict(x, y, z, mask1, mask2)39  real :: x(:), y(:), z(:)40  logical :: mask1(:), mask2(:)41  where (mask1)42    x = y43  elsewhere (mask2)44    z = y45  end where46end subroutine47 48subroutine where_construct_conflict(x, y)49  real :: x(:, :), y(:, :)50  where (y.gt.0.)51    x = y52  elsewhere (x.gt.0)53    y = x54  end where55end subroutine56 57subroutine where_construct_conflict_2(x, y)58  real :: x(:, :), y(:, :)59  where (x.gt.0.)60    x = y61  elsewhere (y.gt.0)62    y = x63  end where64end subroutine65 66subroutine where_vector_subscript_conflict_1(x, vec1)67  real :: x(10)68  integer :: vec1(10)69  where (x(vec1).lt.0.) x = 42.70end subroutine71 72subroutine where_vector_subscript_conflict_2(x, vec1)73  integer :: x(10)74  real :: y(10)75  where (y(x).lt.0.) x = 076end subroutine77 78subroutine where_in_forall_conflict(x)79  real :: x(:, :)80  forall (i = 1:10)81    where (x(i, :).gt.0) x(:, i) = x(i, :)82  end forall83end subroutine84 85subroutine no_need_to_make_lhs_temp(x, y, i, j)86  integer :: j, i, x(:, :), y(:, :)87  call internal88contains89subroutine internal90  ! The internal procedure context currently gives a hard time to91  ! FIR alias analysis that flags the read of i,j and y as conflicting92  ! with the write to x. But this is not a reason to create a temporary93  ! storage for the LHS: the address is anyway fully computed in94  ! a descriptor (fir.box) before assigning any element of x.95 96  ! Note that the where mask is also saved while there is no real97  ! need to: it is addressing x elements in the same order as they98  ! are being assigned. But this will require more work in the99  ! conflict analysis to prove that the lowered DAG of `x(:, y(i, j))`100  ! are the same and that the access to this designator is done in the101  ! same ordered inside the mask and LHS.102  where (x(:, y(i, j)) == y(i, j))  x(:, y(i, j)) = 42103end subroutine104end subroutine105 106subroutine where_construct_unknown_conflict(x, mask)107  real :: x(:)108  logical :: mask(:)109  interface110     real function f()111     end function f112  end interface113  where (mask) x = f()114end subroutine115 116subroutine elsewhere_construct_unknown_conflict(x, y, mask1, mask2)117  real :: x(:), y(:)118  logical :: mask1(:), mask2(:)119  interface120     real function f()121     end function f122  end interface123  where (mask1)124     x = 1.0125  elsewhere (mask2)126     y = f()127  end where128end subroutine129 130!CHECK-LABEL: ------------ scheduling where in _QPno_conflict ------------131!CHECK-NEXT: run 1 evaluate: where/region_assign1132!CHECK-LABEL: ------------ scheduling where in _QPfake_conflict ------------133!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?xf32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?xf32>>' at index: 0134!CHECK-NEXT: run 1 save    : where/mask135!CHECK-NEXT: run 2 evaluate: where/region_assign1136!CHECK-LABEL: ------------ scheduling where in _QPonly_once ------------137!CHECK-NEXT: unknown effect: %11 = fir.call @_QPcall_me_only_once() fastmath<contract> : () -> !fir.array<10x!fir.logical<4>>138!CHECK-NEXT: saving eval because write effect prevents re-evaluation139!CHECK-NEXT: run 1 save  (w): where/mask140!CHECK-NEXT: run 2 evaluate: where/region_assign1141!CHECK-NEXT: run 3 evaluate: where/region_assign2142!CHECK-LABEL: ------------ scheduling where in _QPrhs_lhs_conflict ------------143!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0144!CHECK-NEXT: run 1 save    : where/region_assign1/rhs145!CHECK-NEXT: run 2 evaluate: where/region_assign1146!CHECK-LABEL: ------------ scheduling where in _QPwhere_construct_no_conflict ------------147!CHECK-NEXT: run 1 evaluate: where/region_assign1148!CHECK-NEXT: run 2 evaluate: where/elsewhere1/region_assign1149!CHECK-LABEL: ------------ scheduling where in _QPwhere_construct_conflict ------------150!CHECK-NEXT: run 1 evaluate: where/region_assign1151!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 1 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 1152!CHECK-NEXT: run 2 save    : where/mask153!CHECK-NEXT: run 3 evaluate: where/elsewhere1/region_assign1154!CHECK-LABEL: ------------ scheduling where in _QPwhere_construct_conflict_2 ------------155!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0156!CHECK-NEXT: run 1 save    : where/mask157!CHECK-NEXT: run 2 evaluate: where/region_assign1158!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 1 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 1159!CHECK-NEXT: run 3 save    : where/elsewhere1/mask160!CHECK-NEXT: run 4 evaluate: where/elsewhere1/region_assign1161!CHECK-LABEL: ------------ scheduling where in _QPwhere_vector_subscript_conflict_1 ------------162!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.ref<!fir.array<10xf32>>' at index: 0 W:<block argument> of type '!fir.ref<!fir.array<10xf32>>' at index: 0163!CHECK-NEXT: run 1 save    : where/mask164!CHECK-NEXT: run 2 evaluate: where/region_assign1165!CHECK-LABEL: ------------ scheduling where in _QPwhere_vector_subscript_conflict_2 ------------166!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.ref<!fir.array<10xi32>>' at index: 0 W:<block argument> of type '!fir.ref<!fir.array<10xi32>>' at index: 0167!CHECK-NEXT: run 1 save    : where/mask168!CHECK-NEXT: run 2 evaluate: where/region_assign1169!CHECK-LABEL: ------------ scheduling forall in _QPwhere_in_forall_conflict ------------170!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0171!CHECK-NEXT: run 1 save    : forall/where1/mask172!CHECK-NEXT: conflict: R/W: <block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0 W:<block argument> of type '!fir.box<!fir.array<?x?xf32>>' at index: 0173!CHECK-NEXT: run 1 save    : forall/where1/region_assign1/rhs174!CHECK-NEXT: run 2 evaluate: forall/where1/region_assign1175!CHECK-LABEL: ------------ scheduling where in _QFno_need_to_make_lhs_tempPinternal ------------176!CHECK-NEXT: conflict: R/W: %{{[0-9]+}} = fir.load %{{[0-9]+}} : !fir.llvm_ptr<!fir.ref<i32>> W:%{{[0-9]+}} = fir.load %{{[0-9]+}} : !fir.ref<!fir.box<!fir.array<?x?xi32>>>177!CHECK-NEXT: run 1 save    : where/mask178!CHECK-NEXT: run 2 evaluate: where/region_assign1179!CHECK-NEXT: ------------ scheduling where in _QPwhere_construct_unknown_conflict ------------180!CHECK-NEXT: unknown effect: %{{.*}} = fir.call @_QPf() fastmath<contract> : () -> f32181!CHECK-NEXT: conflict: R/W: %{{.*}} = hlfir.declare %{{.*}} {uniq_name = "_QFwhere_construct_unknown_conflictEmask"} : (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>) W:<unknown>182!CHECK-NEXT: run 1 save    : where/mask183!CHECK-NEXT: unknown effect: %{{.*}} = fir.call @_QPf() fastmath<contract> : () -> f32184!CHECK-NEXT: saving eval because write effect prevents re-evaluation185!CHECK-NEXT: run 2 save  (w): where/region_assign1/rhs186!CHECK-NEXT: run 3 evaluate: where/region_assign1187!CHECK-NEXT: ------------ scheduling where in _QPelsewhere_construct_unknown_conflict ------------188!CHECK-NEXT: run 1 evaluate: where/region_assign1189!CHECK-NEXT: unknown effect: %{{.*}} = fir.call @_QPf() fastmath<contract> : () -> f32190!CHECK-NEXT: conflict: R/W: %{{.*}} = hlfir.declare %{{.*}} {uniq_name = "_QFelsewhere_construct_unknown_conflictEmask1"} : (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>) W:<unknown>191!CHECK-NEXT: run 2 save    : where/mask192!CHECK-NEXT: conflict: R/W: %{{.*}} = hlfir.declare %{{.*}} {uniq_name = "_QFelsewhere_construct_unknown_conflictEmask2"} : (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.dscope) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>) W:<unknown>193!CHECK-NEXT: run 2 save    : where/elsewhere1/mask194!CHECK-NEXT: unknown effect: %{{.*}} = fir.call @_QPf() fastmath<contract> : () -> f32195!CHECK-NEXT: saving eval because write effect prevents re-evaluation196!CHECK-NEXT: run 3 save  (w): where/elsewhere1/region_assign1/rhs197!CHECK-NEXT: run 4 evaluate: where/elsewhere1/region_assign1198