Files
TheRock/compiler/amd-llvm/mlir/test/Transforms/test-commutativity-utils.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

117 lines
3.5 KiB
MLIR

// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
// CHECK-LABEL: @test_small_pattern_1
func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
// CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
%0 = arith.constant 45 : i32
// CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"
%1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
// CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
%2 = arith.addi %arg0, %arg0 : i32
// CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli
%3 = arith.muli %arg0, %arg0 : i32
// CHECK-NEXT: %[[RESULT:.*]] = "test.op_commutative"(%[[ARITH_ADD]], %[[ARITH_MUL]], %[[TEST_ADD]], %[[ARITH_CONST]])
%result = "test.op_commutative"(%0, %1, %2, %3): (i32, i32, i32, i32) -> i32
// CHECK-NEXT: return %[[RESULT]]
return %result : i32
}
// CHECK-LABEL: @test_small_pattern_2
// CHECK-SAME: (%[[ARG0:.*]]: i32
func.func @test_small_pattern_2(%arg0 : i32) -> i32 {
// CHECK-NEXT: %[[TEST_CONST:.*]] = "test.constant"
%0 = "test.constant"() {value = 0 : i32} : () -> i32
// CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
%1 = arith.constant 0 : i32
// CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
%2 = arith.addi %arg0, %arg0 : i32
// CHECK-NEXT: %[[RESULT:.*]] = "test.op_commutative"(%[[ARG0]], %[[ARITH_ADD]], %[[ARITH_CONST]], %[[TEST_CONST]])
%result = "test.op_commutative"(%0, %1, %2, %arg0): (i32, i32, i32, i32) -> i32
// CHECK-NEXT: return %[[RESULT]]
return %result : i32
}
// CHECK-LABEL: @test_large_pattern
func.func @test_large_pattern(%arg0 : i32, %arg1 : i32) -> i32 {
// CHECK-NEXT: arith.divsi
%0 = arith.divsi %arg0, %arg1 : i32
// CHECK-NEXT: arith.divsi
%1 = arith.divsi %0, %arg0 : i32
// CHECK-NEXT: arith.divsi
%2 = arith.divsi %1, %arg1 : i32
// CHECK-NEXT: arith.addi
%3 = arith.addi %1, %arg1 : i32
// CHECK-NEXT: arith.subi
%4 = arith.subi %2, %3 : i32
// CHECK-NEXT: "test.addi"
%5 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
// CHECK-NEXT: %[[VAL6:.*]] = arith.divsi
%6 = arith.divsi %4, %5 : i32
// CHECK-NEXT: arith.divsi
%7 = arith.divsi %1, %arg1 : i32
// CHECK-NEXT: %[[VAL8:.*]] = arith.muli
%8 = arith.muli %1, %arg1 : i32
// CHECK-NEXT: %[[VAL9:.*]] = arith.subi
%9 = arith.subi %7, %8 : i32
// CHECK-NEXT: "test.addi"
%10 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
// CHECK-NEXT: %[[VAL11:.*]] = arith.divsi
%11 = arith.divsi %9, %10 : i32
// CHECK-NEXT: %[[VAL12:.*]] = arith.divsi
%12 = arith.divsi %6, %arg1 : i32
// CHECK-NEXT: arith.subi
%13 = arith.subi %arg1, %arg0 : i32
// CHECK-NEXT: "test.op_commutative"(%[[VAL12]], %[[VAL12]], %[[VAL8]], %[[VAL9]])
%14 = "test.op_commutative"(%12, %9, %12, %8): (i32, i32, i32, i32) -> i32
// CHECK-NEXT: %[[VAL15:.*]] = arith.divsi
%15 = arith.divsi %13, %14 : i32
// CHECK-NEXT: %[[VAL16:.*]] = arith.addi
%16 = arith.addi %2, %15 : i32
// CHECK-NEXT: arith.subi
%17 = arith.subi %16, %arg1 : i32
// CHECK-NEXT: "test.addi"
%18 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
// CHECK-NEXT: %[[VAL19:.*]] = arith.divsi
%19 = arith.divsi %17, %18 : i32
// CHECK-NEXT: "test.addi"
%20 = "test.addi"(%arg0, %16): (i32, i32) -> i32
// CHECK-NEXT: %[[VAL21:.*]] = arith.divsi
%21 = arith.divsi %17, %20 : i32
// CHECK-NEXT: %[[RESULT:.*]] = "test.op_large_commutative"(%[[VAL16]], %[[VAL19]], %[[VAL19]], %[[VAL21]], %[[VAL6]], %[[VAL11]], %[[VAL15]])
%result = "test.op_large_commutative"(%16, %6, %11, %15, %19, %21, %19): (i32, i32, i32, i32, i32, i32, i32) -> i32
// CHECK-NEXT: return %[[RESULT]]
return %result : i32
}