xref: /llvm-project/mlir/test/mlir-query/function-extraction.mlir (revision 58b44c8102afb0e76d1cb70d4a5d089f70d2f657)
1// RUN: mlir-query %s -c "m hasOpName(\"arith.mulf\").extract(\"testmul\")" | FileCheck %s
2
3// CHECK: func.func @testmul({{.*}}) -> (f32, f32, f32) {
4// CHECK:       %[[MUL0:.*]] = arith.mulf {{.*}} : f32
5// CHECK:       %[[MUL1:.*]] = arith.mulf {{.*}}, %[[MUL0]] : f32
6// CHECK:       %[[MUL2:.*]] = arith.mulf {{.*}} : f32
7// CHECK-NEXT:  return %[[MUL0]], %[[MUL1]], %[[MUL2]] : f32, f32, f32
8
9func.func @mixedOperations(%a: f32, %b: f32, %c: f32) -> f32 {
10  %sum0 = arith.addf %a, %b : f32
11  %sub0 = arith.subf %sum0, %c : f32
12  %mul0 = arith.mulf %a, %sub0 : f32
13  %sum1 = arith.addf %b, %c : f32
14  %mul1 = arith.mulf %sum1, %mul0 : f32
15  %sub2 = arith.subf %mul1, %a : f32
16  %sum2 = arith.addf %mul1, %b : f32
17  %mul2 = arith.mulf %sub2, %sum2 : f32
18  return %mul2 : f32
19}
20