brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 03be264 Raw
58 lines · plain
1// RUN: fir-opt %s --fir-to-scf | FileCheck %s2 3// CHECK-LABEL:   func.func @test_only(4// CHECK-SAME:      %[[ARG0:.*]]: i1, %[[ARG1:.*]]: i32) {5// CHECK:           scf.if %[[ARG0]] {6// CHECK:             %[[VAL_1:.*]] = arith.addi %[[ARG1]], %[[ARG1]] : i327// CHECK:           }8// CHECK:           return9// CHECK:         }10func.func @test_only(%arg0 : i1, %arg1 : i32) {11  fir.if %arg0 {12    %0 = arith.addi %arg1, %arg1 : i3213  }14  return15}16 17// CHECK-LABEL:   func.func @test_else()   {18// CHECK:           %[[VAL_1:.*]] = arith.constant false19// CHECK:           %[[VAL_2:.*]] = arith.constant 2 : i3220// CHECK:           scf.if %[[VAL_1]] {21// CHECK:             %[[VAL_3:.*]] = arith.constant 3 : i3222// CHECK:           } else {23// CHECK:             %[[VAL_3:.*]] = arith.constant 3 : i3224// CHECK:           }25// CHECK:           return26// CHECK:         }27func.func @test_else()   {28  %false = arith.constant false29  %1 = arith.constant 2 : i3230  fir.if %false {31    %2 = arith.constant 3 : i3232  } else {33    %3 = arith.constant 3 : i3234  }35  return36}37 38// CHECK-LABEL:   func.func @test_two_result()  {39// CHECK:           %[[VAL_1:.*]] = arith.constant 2.000000e+00 : f3240// CHECK:           %[[VAL_2:.*]] = arith.constant false41// CHECK:           %[[RES:[0-9]+]]:2 = scf.if %[[VAL_2]] -> (f32, f32) {42// CHECK:             scf.yield %[[VAL_1]], %[[VAL_1]] : f32, f3243// CHECK:           } else {44// CHECK:             scf.yield %[[VAL_1]], %[[VAL_1]] : f32, f3245// CHECK:           }46// CHECK:           return47// CHECK:         }48func.func @test_two_result() {49  %1 = arith.constant 2.0 : f3250  %cmp = arith.constant false51  %x, %y = fir.if %cmp -> (f32, f32) {52    fir.result %1, %1 : f32, f3253  } else {54    fir.result %1, %1 : f32, f3255  }56  return57}58