xref: /llvm-project/mlir/test/Transforms/test-legalize-remapped-value.mlir (revision cda6aa78f8e7346382a204306c4d86ffbab99785)
1// RUN: mlir-opt %s -test-remapped-value | FileCheck %s
2
3// Simple test that exercises ConvertPatternRewriter::getRemappedValue.
4
5// CHECK-LABEL: func @remap_input_1_to_1
6// CHECK-SAME: (%[[ARG:.*]]: i32)
7// CHECK-NEXT: %[[VAL:.*]] = "test.one_variadic_out_one_variadic_in1"(%[[ARG]], %[[ARG]])
8// CHECK-NEXT: "test.one_variadic_out_one_variadic_in1"(%[[VAL]], %[[VAL]])
9
10func.func @remap_input_1_to_1(%arg0: i32) {
11  %0 = "test.one_variadic_out_one_variadic_in1"(%arg0) : (i32) -> i32
12  %1 = "test.one_variadic_out_one_variadic_in1"(%0) : (i32) -> i32
13  "test.return"() : () -> ()
14}
15
16// Test the case where an operation is converted before its operands are.
17
18// CHECK-LABEL: func @remap_unconverted
19// CHECK-NEXT: %[[VAL:.*]] = "test.type_producer"() : () -> f64
20// CHECK-NEXT: "test.type_consumer"(%[[VAL]]) : (f64)
21func.func @remap_unconverted() {
22  %region_result = "test.remapped_value_region"() ({
23    %result = "test.type_producer"() : () -> f32
24    "test.return"(%result) : (f32) -> ()
25  }) : () -> (f32)
26  "test.type_consumer"(%region_result) : (f32) -> ()
27  "test.return"() : () -> ()
28}
29