Files
clang-p2996/flang/test/Fir/select.fir
Andrzej Warzynski cc3c6b6109 [flang][driver] Make flang-new -fc1 accept MLIR files
This relatively small change will allow Flang's frontend driver,
`flang-new -fc1`, to consume and parse MLIR files.  Semantically (i.e.
from user's perspective) this is identical to reading LLVM IR files.

Two file extensions are associated with MLIR files: .fir and .mlir. Note
that reading MLIR files makes only sense when running one of the
code-generation actions, i.e. when using one of the following action
flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc.

The majority of tests that required `tco` to run are updated to also run
with `flang-new -fc1`. A few tests are updated to use `fir-opt` instead
of `tco` (that's the preferred choice when testing a particular MLIR
pass). basic-program.fir is not updated as that test is intended to
verify the behaviour of `tco` specifically.

Differential Revision: https://reviews.llvm.org/D126890
2022-06-10 10:58:54 +00:00

70 lines
1.8 KiB
Plaintext

// Test lowering FIR to LLVM IR of fir.select{|_rank|_case}
// RUN: tco %s | FileCheck %s
// RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
// CHECK-LABEL: @f
func.func @f(%a : i32) -> i32 {
%1 = arith.constant 1 : i32
%2 = arith.constant 42 : i32
// CHECK: switch i32 %{{.*}}, label %{{.*}} [
// CHECK: i32 1, label %{{.*}}
// CHECK: ]
fir.select %a : i32 [1, ^bb2(%1:i32), unit, ^bb3(%2:i32)]
^bb2(%3 : i32) :
return %3 : i32
^bb3(%4 : i32) :
%5 = arith.addi %4, %4 : i32
// CHECK: ret i32
return %5 : i32
}
// CHECK-LABEL: @g
func.func @g(%a : i32) -> i32 {
%1 = arith.constant 1 : i32
%2 = arith.constant 42 : i32
// CHECK: switch i32 %{{.*}}, label %{{.*}} [
// CHECK: i32 1, label %{{.*}}
// CHECK: i32 -1, label %{{.*}}
// CHECK: ]
fir.select_rank %a : i32 [1, ^bb2(%1:i32), -1, ^bb4, unit, ^bb3(%2:i32)]
^bb2(%3 : i32) :
return %3 : i32
^bb3(%4 : i32) :
%5 = arith.addi %4, %4 : i32
return %5 : i32
^bb4:
// CHECK: ret i32
return %a : i32
}
// CHECK-LABEL: @h
func.func @h(%a : i32) -> i32 {
%1 = arith.constant 1 : i32
%2 = arith.constant 42 : i32
%b1 = arith.constant 4 : i32
%b2 = arith.constant 14 : i32
%b3 = arith.constant 82 : i32
%b4 = arith.constant 96 : i32
// CHECK-DAG: icmp eq i32 %{{.*}}, 1
// CHECK-DAG: icmp sle i32 4, %{{.*}}
// CHECK-DAG: icmp sle i32 %{{.*}}, 14
// CHECK-DAG: icmp sle i32 82, %{{.*}}
// CHECK-DAG: icmp sle i32 %{{.*}}, 96
fir.select_case %a : i32 [#fir.point, %1, ^bb2(%1:i32), #fir.lower, %b1, ^bb4, #fir.upper, %b2, ^bb6, #fir.interval, %b3, %b4, ^bb5, unit, ^bb3(%2:i32)]
^bb2(%3 : i32) :
return %3 : i32
^bb3(%4 : i32) :
%5 = arith.addi %4, %4 : i32
cf.br ^bb2(%5 : i32)
^bb4:
return %a : i32
^bb5:
return %1 : i32
^bb6:
%x = arith.addi %b4, %b3 : i32
// CHECK: ret i32
return %x : i32
}