brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · c544f16 Raw
117 lines · plain
1// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s2 3// CHECK-LABEL: @test_small_pattern_14func.func @test_small_pattern_1(%arg0 : i32) -> i32 {5  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant6  %0 = arith.constant 45 : i327 8  // CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"9  %1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i3210 11  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi12  %2 = arith.addi %arg0, %arg0 : i3213 14  // CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli15  %3 = arith.muli %arg0, %arg0 : i3216 17  // CHECK-NEXT: %[[RESULT:.*]] = "test.op_commutative"(%[[ARITH_ADD]], %[[ARITH_MUL]], %[[TEST_ADD]], %[[ARITH_CONST]])18  %result = "test.op_commutative"(%0, %1, %2, %3): (i32, i32, i32, i32) -> i3219 20  // CHECK-NEXT: return %[[RESULT]]21  return %result : i3222}23 24// CHECK-LABEL: @test_small_pattern_225// CHECK-SAME: (%[[ARG0:.*]]: i3226func.func @test_small_pattern_2(%arg0 : i32) -> i32 {27  // CHECK-NEXT: %[[TEST_CONST:.*]] = "test.constant"28  %0 = "test.constant"() {value = 0 : i32} : () -> i3229 30  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant31  %1 = arith.constant 0 : i3232 33  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi34  %2 = arith.addi %arg0, %arg0 : i3235 36  // CHECK-NEXT: %[[RESULT:.*]] = "test.op_commutative"(%[[ARG0]], %[[ARITH_ADD]], %[[ARITH_CONST]], %[[TEST_CONST]])37  %result = "test.op_commutative"(%0, %1, %2, %arg0): (i32, i32, i32, i32) -> i3238 39  // CHECK-NEXT: return %[[RESULT]]40  return %result : i3241}42 43// CHECK-LABEL: @test_large_pattern44func.func @test_large_pattern(%arg0 : i32, %arg1 : i32) -> i32 {45  // CHECK-NEXT: arith.divsi46  %0 = arith.divsi %arg0, %arg1 : i3247 48  // CHECK-NEXT: arith.divsi49  %1 = arith.divsi %0, %arg0 : i3250 51  // CHECK-NEXT: arith.divsi52  %2 = arith.divsi %1, %arg1 : i3253 54  // CHECK-NEXT: arith.addi55  %3 = arith.addi %1, %arg1 : i3256 57  // CHECK-NEXT: arith.subi58  %4 = arith.subi %2, %3 : i3259 60  // CHECK-NEXT: "test.addi"61  %5 = "test.addi"(%arg0, %arg0): (i32, i32) -> i3262 63  // CHECK-NEXT: %[[VAL6:.*]] = arith.divsi64  %6 = arith.divsi %4, %5 : i3265 66  // CHECK-NEXT: arith.divsi67  %7 = arith.divsi %1, %arg1 : i3268 69  // CHECK-NEXT: %[[VAL8:.*]] = arith.muli70  %8 = arith.muli %1, %arg1 : i3271 72  // CHECK-NEXT: %[[VAL9:.*]] = arith.subi73  %9 = arith.subi %7, %8 : i3274 75  // CHECK-NEXT: "test.addi"76  %10 = "test.addi"(%arg0, %arg0): (i32, i32) -> i3277 78  // CHECK-NEXT: %[[VAL11:.*]] = arith.divsi79  %11 = arith.divsi %9, %10 : i3280 81  // CHECK-NEXT: %[[VAL12:.*]] = arith.divsi82  %12 = arith.divsi %6, %arg1 : i3283 84  // CHECK-NEXT: arith.subi85  %13 = arith.subi %arg1, %arg0 : i3286 87  // CHECK-NEXT: "test.op_commutative"(%[[VAL12]], %[[VAL12]], %[[VAL8]], %[[VAL9]])88  %14 = "test.op_commutative"(%12, %9, %12, %8): (i32, i32, i32, i32) -> i3289 90  // CHECK-NEXT: %[[VAL15:.*]] = arith.divsi91  %15 = arith.divsi %13, %14 : i3292 93  // CHECK-NEXT: %[[VAL16:.*]] = arith.addi94  %16 = arith.addi %2, %15 : i3295 96  // CHECK-NEXT: arith.subi97  %17 = arith.subi %16, %arg1 : i3298 99  // CHECK-NEXT: "test.addi"100  %18 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32101 102  // CHECK-NEXT: %[[VAL19:.*]] = arith.divsi103  %19 = arith.divsi %17, %18 : i32104 105  // CHECK-NEXT: "test.addi"106  %20 = "test.addi"(%arg0, %16): (i32, i32) -> i32107 108  // CHECK-NEXT: %[[VAL21:.*]] = arith.divsi109  %21 = arith.divsi %17, %20 : i32110 111  // CHECK-NEXT: %[[RESULT:.*]] = "test.op_large_commutative"(%[[VAL16]], %[[VAL19]], %[[VAL19]], %[[VAL21]], %[[VAL6]], %[[VAL11]], %[[VAL15]])112  %result = "test.op_large_commutative"(%16, %6, %11, %15, %19, %21, %19): (i32, i32, i32, i32, i32, i32, i32) -> i32113 114  // CHECK-NEXT: return %[[RESULT]]115  return %result : i32116}117