2019-07-02 00:49:31 +08:00
|
|
|
// RUN: mlir-opt -test-legalize-patterns %s | FileCheck %s
|
2019-06-12 06:38:13 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: verifyDirectPattern
|
|
|
|
func @verifyDirectPattern() -> i32 {
|
2019-06-26 10:06:06 +08:00
|
|
|
// CHECK-NEXT: "test.legal_op_a"() {status = "Success"}
|
2019-06-12 06:38:13 +08:00
|
|
|
%result = "test.illegal_op_a"() : () -> (i32)
|
|
|
|
return %result : i32
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: verifyLargerBenefit
|
|
|
|
func @verifyLargerBenefit() -> i32 {
|
2019-06-26 10:06:06 +08:00
|
|
|
// CHECK-NEXT: "test.legal_op_a"() {status = "Success"}
|
2019-06-12 06:38:13 +08:00
|
|
|
%result = "test.illegal_op_c"() : () -> (i32)
|
|
|
|
return %result : i32
|
|
|
|
}
|
2019-06-20 04:58:31 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: func @remap_input_1_to_0()
|
|
|
|
func @remap_input_1_to_0(i16)
|
|
|
|
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-LABEL: func @remap_input_1_to_1(%arg0: f64)
|
|
|
|
func @remap_input_1_to_1(%arg0: i64) {
|
|
|
|
// CHECK-NEXT: "test.valid"{{.*}} : (f64)
|
|
|
|
"test.invalid"(%arg0) : (i64) -> ()
|
2019-06-20 04:58:31 +08:00
|
|
|
}
|
|
|
|
|
2019-07-02 01:12:33 +08:00
|
|
|
// CHECK-LABEL: func @remap_input_1_to_N({{.*}}f16, {{.*}}f16)
|
2019-06-22 00:29:46 +08:00
|
|
|
func @remap_input_1_to_N(%arg0: f32) -> f32 {
|
2019-07-02 01:12:33 +08:00
|
|
|
// CHECK-NEXT: "test.return"{{.*}} : (f16, f16) -> ()
|
|
|
|
"test.return"(%arg0) : (f32) -> ()
|
2019-06-22 00:29:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @remap_input_1_to_N_remaining_use(%arg0: f16, %arg1: f16)
|
|
|
|
func @remap_input_1_to_N_remaining_use(%arg0: f32) {
|
|
|
|
// CHECK-NEXT: [[CAST:%.*]] = "test.cast"(%arg0, %arg1) : (f16, f16) -> f32
|
|
|
|
// CHECK-NEXT: "work"([[CAST]]) : (f32) -> ()
|
|
|
|
"work"(%arg0) : (f32) -> ()
|
|
|
|
}
|
|
|
|
|
2019-07-02 00:52:53 +08:00
|
|
|
// CHECK-LABEL: func @remap_input_to_self
|
|
|
|
func @remap_input_to_self(%arg0: index) {
|
|
|
|
// CHECK-NOT: test.cast
|
|
|
|
// CHECK: "work"
|
|
|
|
"work"(%arg0) : (index) -> ()
|
|
|
|
}
|
|
|
|
|
2019-06-20 04:58:31 +08:00
|
|
|
// CHECK-LABEL: func @remap_multi(%arg0: f64, %arg1: f64) -> (f64, f64)
|
|
|
|
func @remap_multi(%arg0: i64, %unused: i16, %arg1: i64) -> (i64, i64) {
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-NEXT: "test.valid"{{.*}} : (f64, f64)
|
|
|
|
"test.invalid"(%arg0, %arg1) : (i64, i64) -> ()
|
2019-06-20 04:58:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @remap_nested
|
|
|
|
func @remap_nested() {
|
|
|
|
// CHECK-NEXT: "foo.region"
|
|
|
|
"foo.region"() ({
|
2019-07-10 01:40:29 +08:00
|
|
|
// CHECK-NEXT: ^bb0(%{{.*}}: f64, %{{.*}}: f64):
|
|
|
|
^bb0(%i0: i64, %unused: i16, %i1: i64):
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-NEXT: "test.valid"{{.*}} : (f64, f64)
|
|
|
|
"test.invalid"(%i0, %i1) : (i64, i64) -> ()
|
2019-06-20 04:58:31 +08:00
|
|
|
}) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @remap_moved_region_args
|
|
|
|
func @remap_moved_region_args() {
|
|
|
|
// CHECK-NEXT: return
|
2019-06-22 00:29:46 +08:00
|
|
|
// CHECK-NEXT: ^bb1(%{{.*}}: f64, %{{.*}}: f64, %{{.*}}: f16, %{{.*}}: f16):
|
|
|
|
// CHECK-NEXT: "test.cast"{{.*}} : (f16, f16) -> f32
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-NEXT: "test.valid"{{.*}} : (f64, f64, f32)
|
2019-06-20 04:58:31 +08:00
|
|
|
"test.region"() ({
|
2019-06-22 00:29:46 +08:00
|
|
|
^bb1(%i0: i64, %unused: i16, %i1: i64, %2: f32):
|
2019-06-29 02:28:30 +08:00
|
|
|
"test.invalid"(%i0, %i1, %2) : (i64, i64, f32) -> ()
|
2019-06-20 04:58:31 +08:00
|
|
|
}) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @remap_drop_region
|
|
|
|
func @remap_drop_region() {
|
|
|
|
// CHECK-NEXT: return
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
"test.drop_op"() ({
|
2019-06-22 00:29:46 +08:00
|
|
|
^bb1(%i0: i64, %unused: i16, %i1: i64, %2: f32):
|
2019-06-29 02:28:30 +08:00
|
|
|
"test.invalid"(%i0, %i1, %2) : (i64, i64, f32) -> ()
|
2019-06-20 04:58:31 +08:00
|
|
|
}) : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-LABEL: func @dropped_input_in_use
|
2019-06-20 04:58:31 +08:00
|
|
|
func @dropped_input_in_use(%arg: i16, %arg2: i64) {
|
2019-06-29 02:28:30 +08:00
|
|
|
// CHECK-NEXT: "test.cast"{{.*}} : () -> i16
|
|
|
|
// CHECK-NEXT: "work"{{.*}} : (i16)
|
2019-06-20 04:58:31 +08:00
|
|
|
"work"(%arg) : (i16) -> ()
|
|
|
|
}
|