annotate mlir/test/IR/test-matchers.mlir @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
1 // RUN: mlir-opt %s -mlir-disable-threading=true -pass-pipeline="builtin.module(func.func(test-matchers))" -o /dev/null 2>&1 | FileCheck %s
150
anatofuz
parents:
diff changeset
2
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
3 func.func @test1(%a: f32, %b: f32, %c: f32) {
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
4 %0 = arith.addf %a, %b: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
5 %1 = arith.addf %a, %c: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
6 %2 = arith.addf %c, %b: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
7 %3 = arith.mulf %a, %2: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
8 %4 = arith.mulf %3, %1: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
9 %5 = arith.mulf %4, %4: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
10 %6 = arith.mulf %5, %5: f32
150
anatofuz
parents:
diff changeset
11 return
anatofuz
parents:
diff changeset
12 }
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 // CHECK-LABEL: test1
anatofuz
parents:
diff changeset
15 // CHECK: Pattern add(*) matched 3 times
anatofuz
parents:
diff changeset
16 // CHECK: Pattern mul(*) matched 4 times
anatofuz
parents:
diff changeset
17 // CHECK: Pattern add(add(*), *) matched 0 times
anatofuz
parents:
diff changeset
18 // CHECK: Pattern add(*, add(*)) matched 0 times
anatofuz
parents:
diff changeset
19 // CHECK: Pattern mul(add(*), *) matched 0 times
anatofuz
parents:
diff changeset
20 // CHECK: Pattern mul(*, add(*)) matched 2 times
anatofuz
parents:
diff changeset
21 // CHECK: Pattern mul(mul(*), *) matched 3 times
anatofuz
parents:
diff changeset
22 // CHECK: Pattern mul(mul(*), mul(*)) matched 2 times
anatofuz
parents:
diff changeset
23 // CHECK: Pattern mul(mul(mul(*), mul(*)), mul(mul(*), mul(*))) matched 1 times
anatofuz
parents:
diff changeset
24 // CHECK: Pattern mul(mul(mul(mul(*), add(*)), mul(*)), mul(mul(*, add(*)), mul(*, add(*)))) matched 1 times
anatofuz
parents:
diff changeset
25 // CHECK: Pattern add(a, b) matched 1 times
anatofuz
parents:
diff changeset
26 // CHECK: Pattern add(a, c) matched 1 times
anatofuz
parents:
diff changeset
27 // CHECK: Pattern add(b, a) matched 0 times
anatofuz
parents:
diff changeset
28 // CHECK: Pattern add(c, a) matched 0 times
anatofuz
parents:
diff changeset
29 // CHECK: Pattern mul(a, add(c, b)) matched 1 times
anatofuz
parents:
diff changeset
30 // CHECK: Pattern mul(a, add(b, c)) matched 0 times
anatofuz
parents:
diff changeset
31 // CHECK: Pattern mul(mul(a, *), add(a, c)) matched 1 times
anatofuz
parents:
diff changeset
32 // CHECK: Pattern mul(mul(a, *), add(c, b)) matched 0 times
anatofuz
parents:
diff changeset
33
236
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
34 func.func @test2(%a: f32) -> f32 {
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
35 %0 = arith.constant 1.0: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
36 %1 = arith.addf %a, %0: f32
c4bab56944e8 LLVM 16
kono
parents: 173
diff changeset
37 %2 = arith.mulf %a, %1: f32
150
anatofuz
parents:
diff changeset
38 return %2: f32
anatofuz
parents:
diff changeset
39 }
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 // CHECK-LABEL: test2
anatofuz
parents:
diff changeset
42 // CHECK: Pattern add(add(a, constant), a) matched and bound constant to: 1.000000e+00
anatofuz
parents:
diff changeset
43 // CHECK: Pattern add(add(a, constant), a) matched
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
44
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
45 func.func @test3(%a: f32) -> f32 {
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
46 %0 = "test.name"() {value = 1.0 : f32} : () -> f32
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
47 %1 = arith.addf %a, %0: f32
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
48 %2 = arith.mulf %a, %1 fastmath<fast>: f32
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
49 return %2: f32
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
50 }
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
51
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
52 // CHECK-LABEL: test3
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
53 // CHECK: Pattern mul(*, add(*, m_Op("test.name"))) matched
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
54 // CHECK: Pattern m_Attr("fastmath") matched and bound value to: fast