55 lines · plain
1// RUN: mlir-opt %s -mlir-disable-threading=true -pass-pipeline="builtin.module(func.func(test-matchers))" -o /dev/null 2>&1 | FileCheck %s2 3func.func @test1(%a: f32, %b: f32, %c: f32) {4 %0 = arith.addf %a, %b: f325 %1 = arith.addf %a, %c: f326 %2 = arith.addf %c, %b: f327 %3 = arith.mulf %a, %2: f328 %4 = arith.mulf %3, %1: f329 %5 = arith.mulf %4, %4: f3210 %6 = arith.mulf %5, %5: f3211 return12}13 14// CHECK-LABEL: test115// CHECK: Pattern add(*) matched 3 times16// CHECK: Pattern mul(*) matched 4 times17// CHECK: Pattern add(add(*), *) matched 0 times18// CHECK: Pattern add(*, add(*)) matched 0 times19// CHECK: Pattern mul(add(*), *) matched 0 times20// CHECK: Pattern mul(*, add(*)) matched 2 times21// CHECK: Pattern mul(mul(*), *) matched 3 times22// CHECK: Pattern mul(mul(*), mul(*)) matched 2 times23// CHECK: Pattern mul(mul(mul(*), mul(*)), mul(mul(*), mul(*))) matched 1 times24// CHECK: Pattern mul(mul(mul(mul(*), add(*)), mul(*)), mul(mul(*, add(*)), mul(*, add(*)))) matched 1 times25// CHECK: Pattern add(a, b) matched 1 times26// CHECK: Pattern add(a, c) matched 1 times27// CHECK: Pattern add(b, a) matched 0 times28// CHECK: Pattern add(c, a) matched 0 times29// CHECK: Pattern mul(a, add(c, b)) matched 1 times30// CHECK: Pattern mul(a, add(b, c)) matched 0 times31// CHECK: Pattern mul(mul(a, *), add(a, c)) matched 1 times32// CHECK: Pattern mul(mul(a, *), add(c, b)) matched 0 times33 34func.func @test2(%a: f32) -> f32 {35 %0 = arith.constant 1.0: f3236 %1 = arith.addf %a, %0: f3237 %2 = arith.mulf %a, %1: f3238 return %2: f3239}40 41// CHECK-LABEL: test242// CHECK: Pattern add(add(a, constant), a) matched and bound constant to: 1.000000e+0043// CHECK: Pattern add(add(a, constant), a) matched44 45func.func @test3(%a: f32) -> f32 {46 %0 = "test.name"() {value = 1.0 : f32} : () -> f3247 %1 = arith.addf %a, %0: f3248 %2 = arith.mulf %a, %1 fastmath<fast>: f3249 return %2: f3250}51 52// CHECK-LABEL: test353// CHECK: Pattern mul(*, add(*, m_Op("test.name"))) matched54// CHECK: Pattern m_Attr("fastmath") matched and bound value to: fast55