45 lines · plain
1// RUN: mlir-opt %s -transform-interpreter | FileCheck %s2 3// CHECK-LABEL: func @complex_block_signature_conversion(4// CHECK: %[[cst:.*]] = complex.constant5// CHECK: %[[complex_llvm:.*]] = builtin.unrealized_conversion_cast %[[cst]] : complex<f64> to !llvm.struct<(f64, f64)>6// Note: Some blocks are omitted.7// CHECK: llvm.br ^[[block1:.*]](%[[complex_llvm]]8// CHECK: ^[[block1]](%[[arg:.*]]: !llvm.struct<(f64, f64)>):9// CHECK: %[[cast:.*]] = builtin.unrealized_conversion_cast %[[arg]] : !llvm.struct<(f64, f64)> to complex<f64>10// CHECK: llvm.br ^[[block2:.*]]11// CHECK: ^[[block2]]:12// CHECK: "test.consumer_of_complex"(%[[cast]]) : (complex<f64>) -> ()13func.func @complex_block_signature_conversion() {14 %cst = complex.constant [0.000000e+00, 0.000000e+00] : complex<f64>15 %true = arith.constant true16 %0 = scf.if %true -> complex<f64> {17 scf.yield %cst : complex<f64>18 } else {19 scf.yield %cst : complex<f64>20 }21 22 // Regression test to ensure that the a source materialization is inserted.23 // The operand of "test.consumer_of_complex" must not change.24 "test.consumer_of_complex"(%0) : (complex<f64>) -> ()25 return26}27 28module attributes {transform.with_named_sequence} {29 transform.named_sequence @__transform_main(%toplevel_module: !transform.any_op {transform.readonly}) {30 %func = transform.structured.match ops{["func.func"]} in %toplevel_module31 : (!transform.any_op) -> !transform.any_op32 transform.apply_conversion_patterns to %func {33 transform.apply_conversion_patterns.dialect_to_llvm "cf"34 transform.apply_conversion_patterns.func.func_to_llvm35 transform.apply_conversion_patterns.scf.scf_to_control_flow36 } with type_converter {37 transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter38 } {39 legal_dialects = ["llvm"], 40 partial_conversion41 } : !transform.any_op42 transform.yield43 }44}45