| 1 |
! RUN: bbc --always-execute-loop-body --emit-fir -hlfir=false %s -o - | FileCheck %s |
| 2 |
! RUN: %flang_fc1 -mmlir --always-execute-loop-body -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s |
| 3 |
|
| 4 |
! Given the flag `--always-execute-loop-body` the compiler emits an extra |
| 5 |
! code to change to tripcount, test tries to verify the extra emitted FIR. |
| 6 |
|
| 7 |
! CHECK-LABEL: func @_QPsome |
| 8 |
subroutine some() |
| 9 |
integer :: i |
| 10 |
|
| 11 |
! CHECK: [[tripcount:%[0-9]+]] = arith.divsi |
| 12 |
! CHECK: [[one:%c1_i32[_0-9]*]] = arith.constant 1 : i32 |
| 13 |
! CHECK: [[cmp:%[0-9]+]] = arith.cmpi slt, [[tripcount]], [[one]] : i32 |
| 14 |
! CHECK: [[newtripcount:%[0-9]+]] = arith.select [[cmp]], [[one]], [[tripcount]] : i32 |
| 15 |
! CHECK: fir.store [[newtripcount]] to %{{[0-9]+}} : !fir.ref<i32> |
| 16 |
do i=4,1,1 |
| 17 |
stop 2 |
| 18 |
end do |
| 19 |
return |
| 20 |
end |