brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 6ed2ecb Raw
51 lines · plain
1! Test that scalar expressions are not hoisted from WHERE loops2! when they do not appear3! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" %s | FileCheck %s4 5subroutine do_not_hoist_div(n, mask, a)6  integer :: a(10), n7  logical :: mask(10)8  where(mask) a=1/n9end subroutine10! CHECK-LABEL:   func.func @_QPdo_not_hoist_div(11! CHECK-NOT:       arith.divsi12! CHECK:           fir.do_loop {{.*}} {13! CHECK:             fir.if {{.*}} {14! CHECK:               arith.divsi15! CHECK:             }16! CHECK:           }17 18subroutine do_not_hoist_optional(n, mask, a)19  integer :: a(10)20  integer, optional :: n21  logical :: mask(10)22  where(mask) a=n23end subroutine24! CHECK-LABEL:   func.func @_QPdo_not_hoist_optional(25! CHECK:           %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}"_QFdo_not_hoist_optionalEn"26! CHECK-NOT:       fir.load %[[VAL_9]]27! CHECK:           fir.do_loop {{.*}} {28! CHECK:             fir.if {{.*}} {29! CHECK:               %[[VAL_15:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<i32>30! CHECK:             }31! CHECK:           }32 33subroutine hoist_function(n, mask, a)34  integer :: a(10, 10)35  integer, optional :: n36  logical :: mask(10, 10)37  forall (i=1:10)38  where(mask(i, :)) a(i,:)=ihoist_me(i)39  end forall40end subroutine41! CHECK-LABEL:   func.func @_QPhoist_function(42! CHECK:           fir.do_loop {{.*}} {43! CHECK:             fir.call @_QPihoist_me44! CHECK:             fir.do_loop {{.*}} {45! CHECK:               fir.if %{{.*}} {46! CHECK-NOT:             fir.call @_QPihoist_me47! CHECK:               }48! CHECK:             }49! CHECK:           }50! CHECK-NOT:       fir.call @_QPihoist_me51