1! This test checks lowering of OpenMP DO Directive(Worksharing) for different 2! types of loop iteration variable, lower bound, upper bound, and step. 3 4!REQUIRES: shell 5!RUN: bbc -fopenmp -emit-fir %s -o - 2>&1 | FileCheck %s 6 7!CHECK: OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed into 64 bits. 8 9program wsloop_variable 10 integer(kind=1) :: i1_lb, i1_ub 11 integer(kind=2) :: i2, i2_ub, i2_s 12 integer(kind=4) :: i4_s 13 integer(kind=8) :: i8, i8_s 14 integer(kind=16) :: i16, i16_lb 15 real :: x 16 17!CHECK: [[TMP0:%.*]] = arith.constant 1 : i32 18!CHECK: [[TMP1:%.*]] = arith.constant 100 : i32 19!CHECK: [[TMP2:%.*]] = fir.convert [[TMP0]] : (i32) -> i64 20!CHECK: [[TMP3:%.*]] = fir.convert %{{.*}} : (i8) -> i64 21!CHECK: [[TMP4:%.*]] = fir.convert %{{.*}} : (i16) -> i64 22!CHECK: [[TMP5:%.*]] = fir.convert %{{.*}} : (i128) -> i64 23!CHECK: [[TMP6:%.*]] = fir.convert [[TMP1]] : (i32) -> i64 24!CHECK: [[TMP7:%.*]] = fir.convert %{{.*}} : (i32) -> i64 25!CHECK: omp.wsloop collapse(2) for ([[TMP8:%.*]], [[TMP9:%.*]]) : i64 = ([[TMP2]], [[TMP5]]) to ([[TMP3]], [[TMP6]]) inclusive step ([[TMP4]], [[TMP7]]) { 26!CHECK: [[TMP10:%.*]] = arith.addi [[TMP8]], [[TMP9]] : i64 27!CHECK: [[TMP11:%.*]] = fir.convert [[TMP10]] : (i64) -> f32 28!CHECK: fir.store [[TMP11]] to %{{.*}} : !fir.ref<f32> 29!CHECK: omp.yield 30!CHECK: } 31 32 !$omp do collapse(2) 33 do i2 = 1, i1_ub, i2_s 34 do i8 = i16_lb, 100, i4_s 35 x = i2 + i8 36 end do 37 end do 38 !$omp end do 39 40!CHECK: [[TMP12:%.*]] = arith.constant 1 : i32 41!CHECK: [[TMP13:%.*]] = fir.convert %{{.*}} : (i8) -> i32 42!CHECK: [[TMP14:%.*]] = fir.convert %{{.*}} : (i64) -> i32 43!CHECK: omp.wsloop for ([[TMP15:%.*]]) : i32 = ([[TMP12]]) to ([[TMP13]]) inclusive step ([[TMP14]]) { 44!CHECK: [[TMP16:%.*]] = fir.convert [[TMP15]] : (i32) -> f32 45!CHECK: fir.store [[TMP16]] to %{{.*}} : !fir.ref<f32> 46!CHECK: omp.yield 47!CHECK: } 48 49 !$omp do 50 do i2 = 1, i1_ub, i8_s 51 x = i2 52 end do 53 !$omp end do 54 55!CHECK: [[TMP17:%.*]] = fir.convert %{{.*}} : (i8) -> i64 56!CHECK: [[TMP18:%.*]] = fir.convert %{{.*}} : (i16) -> i64 57!CHECK: [[TMP19:%.*]] = fir.convert %{{.*}} : (i32) -> i64 58!CHECK: omp.wsloop for ([[TMP20:%.*]]) : i64 = ([[TMP17]]) to ([[TMP18]]) inclusive step ([[TMP19]]) { 59!CHECK: [[TMP21:%.*]] = fir.convert [[TMP20]] : (i64) -> f32 60!CHECK: fir.store [[TMP21]] to %{{.*}} : !fir.ref<f32> 61!CHECK: omp.yield 62!CHECK: } 63 64 !$omp do 65 do i16 = i1_lb, i2_ub, i4_s 66 x = i16 67 end do 68 !$omp end do 69 70end program wsloop_variable 71 72!CHECK-LABEL: func.func @_QPwsloop_variable_sub() { 73!CHECK: %[[VAL_0:.*]] = fir.alloca i128 {bindc_name = "i16_lb", uniq_name = "_QFwsloop_variable_subEi16_lb"} 74!CHECK: %[[VAL_1:.*]] = fir.alloca i8 {bindc_name = "i1_ub", uniq_name = "_QFwsloop_variable_subEi1_ub"} 75!CHECK: %[[VAL_2:.*]] = fir.alloca i16 {bindc_name = "i2", uniq_name = "_QFwsloop_variable_subEi2"} 76!CHECK: %[[VAL_3:.*]] = fir.alloca i16 {bindc_name = "i2_s", uniq_name = "_QFwsloop_variable_subEi2_s"} 77!CHECK: %[[VAL_4:.*]] = fir.alloca i32 {bindc_name = "i4_s", uniq_name = "_QFwsloop_variable_subEi4_s"} 78!CHECK: %[[VAL_5:.*]] = fir.alloca i64 {bindc_name = "i8", uniq_name = "_QFwsloop_variable_subEi8"} 79!CHECK: %[[VAL_6:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFwsloop_variable_subEx"} 80!CHECK: %[[VAL_7:.*]] = arith.constant 1 : i32 81!CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_1]] : !fir.ref<i8> 82!CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_3]] : !fir.ref<i16> 83!CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_8]] : (i8) -> i32 84!CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_9]] : (i16) -> i32 85!CHECK: omp.wsloop for (%[[VAL_12:.*]]) : i32 = (%[[VAL_7]]) to (%[[VAL_10]]) inclusive step (%[[VAL_11]]) { 86!CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_0]] : !fir.ref<i128> 87!CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i128) -> index 88!CHECK: %[[VAL_15:.*]] = arith.constant 100 : i32 89!CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index 90!CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32> 91!CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> index 92!CHECK: %[[VAL_19:.*]] = fir.do_loop %[[VAL_20:.*]] = %[[VAL_14]] to %[[VAL_16]] step %[[VAL_18]] -> index { 93!CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (index) -> i64 94!CHECK: fir.store %[[VAL_21]] to %[[VAL_5]] : !fir.ref<i64> 95!CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_12]] : (i32) -> i64 96!CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_5]] : !fir.ref<i64> 97!CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_22]], %[[VAL_23]] : i64 98!CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (i64) -> f32 99!CHECK: fir.store %[[VAL_25]] to %[[VAL_6]] : !fir.ref<f32> 100!CHECK: %[[VAL_26:.*]] = arith.addi %[[VAL_20]], %[[VAL_18]] : index 101!CHECK: fir.result %[[VAL_26]] : index 102!CHECK: } 103!CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_28:.*]] : (index) -> i64 104!CHECK: fir.store %[[VAL_27]] to %[[VAL_5]] : !fir.ref<i64> 105!CHECK: omp.yield 106!CHECK: } 107!CHECK: return 108!CHECK: } 109 110subroutine wsloop_variable_sub 111 integer(kind=1) :: i1_ub 112 integer(kind=2) :: i2, i2_s 113 integer(kind=4) :: i4_s 114 integer(kind=8) :: i8 115 integer(kind=16) :: i16_lb 116 real :: x 117 118 !$omp do 119 do i2 = 1, i1_ub, i2_s 120 do i8 = i16_lb, 100, i4_s 121 x = i2 + i8 122 end do 123 end do 124 !$omp end do 125 126end 127