xref: /llvm-project/flang/test/Lower/Intrinsics/ishft.f90 (revision f35f863a88f83332bef9605ef4cfe4f05c066efb)
1! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
2
3! CHECK-LABEL: ishft_test
4function ishft_test(i, j)
5    ! CHECK-DAG: %[[result:.*]] = fir.alloca i32 {bindc_name = "ishft_test"
6    ! CHECK-DAG:  %[[i:.*]] = fir.load %arg0 : !fir.ref<i32>
7    ! CHECK-DAG:  %[[j:.*]] = fir.load %arg1 : !fir.ref<i32>
8    ! CHECK-DAG:  %[[VAL_5:.*]] = arith.constant 32 : i32
9    ! CHECK-DAG:  %[[VAL_6:.*]] = arith.constant 0 : i32
10    ! CHECK-DAG:  %[[VAL_7:.*]] = arith.constant 31 : i32
11    ! CHECK:  %[[VAL_8:.*]] = arith.shrsi %[[j]], %[[VAL_7]] : i32
12    ! CHECK:  %[[VAL_9:.*]] = arith.xori %[[j]], %[[VAL_8]] : i32
13    ! CHECK:  %[[VAL_10:.*]] = arith.subi %[[VAL_9]], %[[VAL_8]] : i32
14    ! CHECK:  %[[VAL_11:.*]] = arith.shli %[[i]], %[[VAL_10]] : i32
15    ! CHECK:  %[[VAL_12:.*]] = arith.shrui %[[i]], %[[VAL_10]] : i32
16    ! CHECK:  %[[VAL_13:.*]] = arith.cmpi sge, %[[VAL_10]], %[[VAL_5]] : i32
17    ! CHECK:  %[[VAL_14:.*]] = arith.cmpi slt, %[[j]], %[[VAL_6]] : i32
18    ! CHECK:  %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[VAL_12]], %[[VAL_11]] : i32
19    ! CHECK:  %[[VAL_16:.*]] = arith.select %[[VAL_13]], %[[VAL_6]], %[[VAL_15]] : i32
20    ! CHECK:  fir.store %[[VAL_16]] to %[[result]] : !fir.ref<i32>
21    ! CHECK:  %[[VAL_17:.*]] = fir.load %[[result]] : !fir.ref<i32>
22    ! CHECK:  return %[[VAL_17]] : i32
23    ishft_test = ishft(i, j)
24  end
25