[CI] Add LLVMCPU aarch64 and riscv64 lit tests only if LLVM has the target (#25234)

The tests
- early_data_tiling.mlir, early_data_tiling_convolution.mlir,
early_data_tiling_dynamic.mlir, added in
https://github.com/iree-org/iree/pull/24969
- roundeven_native.mlir, added in
https://github.com/iree-org/iree/pull/25219 (also riscv64), compile for
aarch64.

byo_llvm.sh builds LLVM with only the X86 target, so iree-compile stops
with "createTargetMachine(...) failed" and the tests fail
linux_x64_clang_byollvm job.

Add these tests in the same way as
https://github.com/iree-org/iree/pull/25221: CMake adds them only if
iree_compiler_targeting_iree_arch() is true for their architecture.

Theaarch64 and riscv64 RUN lines move into *_aarch64.mlir and
*_riscv64.mlir files, which copy the IR.

ci-extra: linux_x64_clang_byollvm

---------

Signed-off-by: Tobias Fuchs <fuchs@roofline.ai>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/.github/workflows/ci_linux_x64_clang_byollvm.yml b/.github/workflows/ci_linux_x64_clang_byollvm.yml
index e60de20..4a1c74c 100644
--- a/.github/workflows/ci_linux_x64_clang_byollvm.yml
+++ b/.github/workflows/ci_linux_x64_clang_byollvm.yml
@@ -29,6 +29,16 @@
       - name: Install Python requirements
         run: python3 -m pip install -r ./build_tools/github_actions/ci_requirements.txt
       - name: "Building and testing with bring-your-own-LLVM"
+        env:
+          # TODO: Remove when the ubuntu-24.04 runner image has a kernel with
+          # https://github.com/torvalds/linux/commit/4de32fd05ce9.
+          # On kernel 7.0.0-1017-azure, AppArmor dereferences a NULL pointer
+          # when a confined process writes to a connected AF_UNIX datagram
+          # socket. In this container, that ends the main thread of
+          # socket_tests in UnixDgram_ConnectedLoopback, and the test hangs
+          # until the ctest timeout.
+          IREE_EXTRA_NEWLINE_SEPARATED_CTEST_TESTS_TO_EXCLUDE: |-
+            iree/async/platform/posix/cts/socket_tests
         run: ./build_tools/cmake/build_and_test_byo_llvm.sh
 
       - name: Post to Discord on Failure
diff --git a/compiler/plugins/target/LLVMCPU/test/BUILD.bazel b/compiler/plugins/target/LLVMCPU/test/BUILD.bazel
index b257fde..10e25db 100644
--- a/compiler/plugins/target/LLVMCPU/test/BUILD.bazel
+++ b/compiler/plugins/target/LLVMCPU/test/BUILD.bazel
@@ -4,6 +4,7 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content")
 load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
 load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite")
 
@@ -18,17 +19,25 @@
         # keep sorted
         [
             "early_data_tiling.mlir",
-            "early_data_tiling_convolution.mlir",
-            "early_data_tiling_dynamic.mlir",
+            "early_data_tiling_convolution_x86_64.mlir",
+            "early_data_tiling_dynamic_x86_64.mlir",
+            "early_data_tiling_x86_64.mlir",
             "executable_object_data.mlir",
             "hal_target_device_attributes.mlir",
             "materialize_homogeneous_encodings.mlir",
-            "roundeven_native.mlir",
+            "roundeven_native_x86_64.mlir",
             "smoketest_embedded.mlir",
             "smoketest_system.mlir",
             "vscale_range_validation.mlir",
         ],
         include = ["*.mlir"],
+        exclude = [
+            "early_data_tiling_aarch64.mlir",
+            "early_data_tiling_convolution_aarch64.mlir",
+            "early_data_tiling_dynamic_aarch64.mlir",
+            "roundeven_native_aarch64.mlir",
+            "roundeven_native_riscv64.mlir",
+        ],
     ),
     cfg = "//compiler:lit.cfg.py",
     tools = [
@@ -39,3 +48,64 @@
         "@llvm-project//llvm:not",
     ],
 )
+
+# The tests below compile for other architectures and need the LLVM target of
+# the architecture. CMake adds them only if LLVM_TARGETS_TO_BUILD has the
+# target. The Bazel build always has these targets.
+
+iree_cmake_extra_content(
+    content = """
+iree_compiler_targeting_iree_arch(_IREE_COMPILER_TARGETING_ARM_64 "arm_64")
+if(_IREE_COMPILER_TARGETING_ARM_64)
+""",
+    inline = True,
+)
+
+iree_lit_test_suite(
+    name = "lit_aarch64",
+    srcs = [
+        "early_data_tiling_aarch64.mlir",
+        "early_data_tiling_convolution_aarch64.mlir",
+        "early_data_tiling_dynamic_aarch64.mlir",
+        "roundeven_native_aarch64.mlir",
+    ],
+    cfg = "//compiler:lit.cfg.py",
+    tools = [
+        "//tools:iree-compile",
+        "@llvm-project//lld",
+        "@llvm-project//llvm:FileCheck",
+    ],
+)
+
+iree_cmake_extra_content(
+    content = """
+endif()
+""",
+    inline = True,
+)
+
+iree_cmake_extra_content(
+    content = """
+iree_compiler_targeting_iree_arch(_IREE_COMPILER_TARGETING_RISCV_64 "riscv_64")
+if(_IREE_COMPILER_TARGETING_RISCV_64)
+""",
+    inline = True,
+)
+
+iree_lit_test_suite(
+    name = "lit_riscv64",
+    srcs = ["roundeven_native_riscv64.mlir"],
+    cfg = "//compiler:lit.cfg.py",
+    tools = [
+        "//tools:iree-compile",
+        "@llvm-project//lld",
+        "@llvm-project//llvm:FileCheck",
+    ],
+)
+
+iree_cmake_extra_content(
+    content = """
+endif()
+""",
+    inline = True,
+)
diff --git a/compiler/plugins/target/LLVMCPU/test/CMakeLists.txt b/compiler/plugins/target/LLVMCPU/test/CMakeLists.txt
index 15182a2..d22d764 100644
--- a/compiler/plugins/target/LLVMCPU/test/CMakeLists.txt
+++ b/compiler/plugins/target/LLVMCPU/test/CMakeLists.txt
@@ -15,12 +15,13 @@
     lit
   SRCS
     "early_data_tiling.mlir"
-    "early_data_tiling_convolution.mlir"
-    "early_data_tiling_dynamic.mlir"
+    "early_data_tiling_convolution_x86_64.mlir"
+    "early_data_tiling_dynamic_x86_64.mlir"
+    "early_data_tiling_x86_64.mlir"
     "executable_object_data.mlir"
     "hal_target_device_attributes.mlir"
     "materialize_homogeneous_encodings.mlir"
-    "roundeven_native.mlir"
+    "roundeven_native_x86_64.mlir"
     "smoketest_embedded.mlir"
     "smoketest_system.mlir"
     "vscale_range_validation.mlir"
@@ -32,4 +33,39 @@
     not
 )
 
+iree_compiler_targeting_iree_arch(_IREE_COMPILER_TARGETING_ARM_64 "arm_64")
+if(_IREE_COMPILER_TARGETING_ARM_64)
+
+iree_lit_test_suite(
+  NAME
+    lit_aarch64
+  SRCS
+    "early_data_tiling_aarch64.mlir"
+    "early_data_tiling_convolution_aarch64.mlir"
+    "early_data_tiling_dynamic_aarch64.mlir"
+    "roundeven_native_aarch64.mlir"
+  TOOLS
+    ${IREE_LLD_TARGET}
+    FileCheck
+    iree-compile
+)
+
+endif()
+
+iree_compiler_targeting_iree_arch(_IREE_COMPILER_TARGETING_RISCV_64 "riscv_64")
+if(_IREE_COMPILER_TARGETING_RISCV_64)
+
+iree_lit_test_suite(
+  NAME
+    lit_riscv64
+  SRCS
+    "roundeven_native_riscv64.mlir"
+  TOOLS
+    ${IREE_LLD_TARGET}
+    FileCheck
+    iree-compile
+)
+
+endif()
+
 ### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling.mlir
index febf58a..bcd6b4c 100644
--- a/compiler/plugins/target/LLVMCPU/test/early_data_tiling.mlir
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling.mlir
@@ -1,35 +1,4 @@
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=global-optimization -o %t.global
-// RUN: FileCheck %s --check-prefix=GLOBAL --implicit-check-not=flow.dispatch --implicit-check-not=iree_encoding.set_encoding < %t.global
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=materialized_layout_target --implicit-check-not=linalg.pack
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-dispatch-creation-experimental-set-data-tiling-ops=scaled_matmul --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=linalg.pack
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-dispatch-creation-set-encoding-strategy=padding --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=materialized_layout_target --implicit-check-not=linalg.pack
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-opt-data-tiling --iree-global-opt-data-tiling --iree-dispatch-creation-data-tiling --compile-to=dispatch-creation | FileCheck %s --check-prefix=DISPATCH --implicit-check-not=flow.tensor.encode
-// RUN: iree-compile %t.global --iree-opt-experimental-early-data-tiling --compile-from=global-optimization --compile-to=dispatch-creation | FileCheck %s --check-prefix=DISPATCH --implicit-check-not=flow.tensor.encode
 // RUN: iree-compile %s --iree-hal-target-backends=vmvx --iree-opt-experimental-early-data-tiling --compile-to=dispatch-creation | FileCheck %s --check-prefix=LATE --implicit-check-not=materialized_layout_target
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=global-optimization | FileCheck %s --check-prefix=GLOBAL --implicit-check-not=flow.dispatch --implicit-check-not=iree_encoding.set_encoding
-
-// GLOBAL: iree.encoding.materialized_layout_target =
-// GLOBAL-LABEL: util.func public @matmul_relu
-// GLOBAL: %[[MM:.*]] = linalg.mmt4d
-// GLOBAL: linalg.generic
-// GLOBAL-SAME: ins(%[[MM]] : tensor<{{[0-9]+x[0-9]+x[0-9]+x[0-9]+}}xf32>)
-// GLOBAL: arith.maximumf
-// GLOBAL: linalg.unpack
-
-// UNPACKED-LABEL: util.func public @matmul_relu
-// UNPACKED: linalg.matmul
-// UNPACKED-SAME: tensor<64x128xf32>, tensor<128x64xf32>
-// UNPACKED: arith.maximumf
-
-// DISPATCH: iree.encoding.materialized_layout_target =
-// DISPATCH-LABEL: util.func public @matmul_relu
-// DISPATCH: flow.dispatch.workgroups
-// DISPATCH: linalg.mmt4d
-// DISPATCH-NOT: flow.return
-// DISPATCH: arith.maximumf
-// DISPATCH-NOT: flow.return
-// DISPATCH: linalg.unpack
-// DISPATCH: flow.return
 
 // LATE-LABEL: util.func public @matmul_relu
 // LATE: flow.tensor.encode
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_aarch64.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_aarch64.mlir
new file mode 100644
index 0000000..e29f7f9
--- /dev/null
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_aarch64.mlir
@@ -0,0 +1,46 @@
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=global-optimization -o %t.global
+// RUN: FileCheck %s --check-prefix=GLOBAL --implicit-check-not=flow.dispatch --implicit-check-not=iree_encoding.set_encoding < %t.global
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=materialized_layout_target --implicit-check-not=linalg.pack
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-dispatch-creation-experimental-set-data-tiling-ops=scaled_matmul --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=linalg.pack
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-dispatch-creation-set-encoding-strategy=padding --compile-to=global-optimization | FileCheck %s --check-prefix=UNPACKED --implicit-check-not=materialized_layout_target --implicit-check-not=linalg.pack
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --iree-opt-data-tiling --iree-global-opt-data-tiling --iree-dispatch-creation-data-tiling --compile-to=dispatch-creation | FileCheck %s --check-prefix=DISPATCH --implicit-check-not=flow.tensor.encode
+// RUN: iree-compile %t.global --iree-opt-experimental-early-data-tiling --compile-from=global-optimization --compile-to=dispatch-creation | FileCheck %s --check-prefix=DISPATCH --implicit-check-not=flow.tensor.encode
+
+// GLOBAL: iree.encoding.materialized_layout_target =
+// GLOBAL-LABEL: util.func public @matmul_relu
+// GLOBAL: %[[MM:.*]] = linalg.mmt4d
+// GLOBAL: linalg.generic
+// GLOBAL-SAME: ins(%[[MM]] : tensor<{{[0-9]+x[0-9]+x[0-9]+x[0-9]+}}xf32>)
+// GLOBAL: arith.maximumf
+// GLOBAL: linalg.unpack
+
+// UNPACKED-LABEL: util.func public @matmul_relu
+// UNPACKED: linalg.matmul
+// UNPACKED-SAME: tensor<64x128xf32>, tensor<128x64xf32>
+// UNPACKED: arith.maximumf
+
+// DISPATCH: iree.encoding.materialized_layout_target =
+// DISPATCH-LABEL: util.func public @matmul_relu
+// DISPATCH: flow.dispatch.workgroups
+// DISPATCH: linalg.mmt4d
+// DISPATCH-NOT: flow.return
+// DISPATCH: arith.maximumf
+// DISPATCH-NOT: flow.return
+// DISPATCH: linalg.unpack
+// DISPATCH: flow.return
+
+  func.func @matmul_relu(%lhs: tensor<64x128xf32>, %rhs: tensor<128x64xf32>) -> tensor<64x64xf32> {
+    %zero = arith.constant 0.0 : f32
+    %empty = tensor.empty() : tensor<64x64xf32>
+    %init = linalg.fill ins(%zero : f32) outs(%empty : tensor<64x64xf32>) -> tensor<64x64xf32>
+    %mm = linalg.matmul ins(%lhs, %rhs : tensor<64x128xf32>, tensor<128x64xf32>) outs(%init : tensor<64x64xf32>) -> tensor<64x64xf32>
+    %relu = linalg.generic {
+      indexing_maps = [affine_map<(m, n) -> (m, n)>, affine_map<(m, n) -> (m, n)>],
+      iterator_types = ["parallel", "parallel"]}
+      ins(%mm : tensor<64x64xf32>) outs(%empty : tensor<64x64xf32>) {
+    ^bb0(%value: f32, %unused: f32):
+      %result = arith.maximumf %value, %zero : f32
+      linalg.yield %result : f32
+    } -> tensor<64x64xf32>
+    return %relu : tensor<64x64xf32>
+  }
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_aarch64.mlir
similarity index 95%
rename from compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir
rename to compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_aarch64.mlir
index 42aff58..fcf6b5c 100644
--- a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_aarch64.mlir
@@ -1,6 +1,5 @@
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=dispatch-creation | FileCheck %s
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=executable-targets -o %t
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --compile-to=executable-targets -o %t
 
 // Exercise the existing blocked-convolution family with default CPU codegen.
 // Named N=1 and batchless forms must retain their packed epilogue; dispatch
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_x86_64.mlir
similarity index 63%
copy from compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir
copy to compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_x86_64.mlir
index 42aff58..fb99a92 100644
--- a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution.mlir
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_convolution_x86_64.mlir
@@ -1,27 +1,9 @@
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=dispatch-creation | FileCheck %s
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --compile-to=executable-targets -o %t
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-global-opt-use-im2col-for-convs=false --iree-dispatch-creation-experimental-set-data-tiling-ops=convolution --iree-opt-experimental-early-data-tiling --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --compile-to=executable-targets -o %t
 
 // Exercise the existing blocked-convolution family with default CPU codegen.
 // Named N=1 and batchless forms must retain their packed epilogue; dispatch
 // preprocessing must preserve the canonical loop order used by CPU heuristics.
 
-// CHECK-LABEL: util.func public @blocked_conv_relu
-// CHECK: %[[CONV:.*]] = linalg.generic
-// CHECK-SAME: iterator_types = ["parallel", "parallel", "parallel", "parallel", "reduction", "reduction", "reduction", "parallel", "reduction"]
-// CHECK-SAME: outs(%{{.*}} : tensor<1x1x14x14x8xf32>)
-// CHECK: arith.mulf
-// CHECK: arith.addf
-// CHECK-NOT: flow.return
-// CHECK: %[[RELU:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[CONV]] : tensor<1x1x14x14x8xf32>)
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[COLLAPSED:.*]] = tensor.collapse_shape %[[RELU]]
-// CHECK-SAME: tensor<1x1x14x14x8xf32> into tensor<1x14x14x8xf32>
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[COLLAPSED]] outer_dims_perm = [2, 0, 1] inner_dims_pos = [2]
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @blocked_conv_relu(%lhs: tensor<1x16x16x4xf32>, %rhs: tensor<3x3x4x8xf32>) -> tensor<1x14x14x8xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<1x14x14x8xf32>
@@ -38,19 +20,6 @@
   return %result : tensor<1x14x14x8xf32>
 }
 
-// CHECK-LABEL: util.func public @nchw_stride2_relu
-// CHECK: %[[CONV:.*]] = linalg.generic
-// CHECK-SAME: iterator_types = ["parallel", "parallel", "parallel", "parallel", "reduction", "reduction", "reduction", "parallel", "reduction"]
-// CHECK-SAME: outs(%{{.*}} : tensor<2x2x8x9x8xf32>)
-// CHECK: arith.mulf
-// CHECK: arith.addf
-// CHECK-NOT: flow.return
-// CHECK: %[[RELU:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[CONV]] : tensor<2x2x8x9x8xf32>)
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[RELU]] outer_dims_perm = [0, 1, 2, 3] inner_dims_pos = [1]
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @nchw_stride2_relu(%lhs: tensor<2x7x17x19xf32>, %rhs: tensor<13x7x3x3xf32>) -> tensor<2x13x8x9xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<2x13x8x9xf32>
@@ -67,21 +36,6 @@
   return %result : tensor<2x13x8x9xf32>
 }
 
-// CHECK-LABEL: util.func public @batchless_relu
-// CHECK: %[[CONV:.*]] = linalg.generic
-// CHECK-SAME: iterator_types = ["parallel", "parallel", "parallel", "parallel", "reduction", "reduction", "reduction", "parallel", "reduction"]
-// CHECK-SAME: outs(%{{.*}} : tensor<1x1x14x14x8xf32>)
-// CHECK: arith.mulf
-// CHECK: arith.addf
-// CHECK-NOT: flow.return
-// CHECK: %[[RELU:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[CONV]] : tensor<1x1x14x14x8xf32>)
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[COLLAPSED:.*]] = tensor.collapse_shape %[[RELU]] {{\[\[0, 1\], \[2\], \[3\], \[4\]\]}}
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[COLLAPSED]] outer_dims_perm = [2, 0, 1] inner_dims_pos = [2]
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @batchless_relu(%lhs: tensor<16x16x4xf32>, %rhs: tensor<3x3x4x8xf32>) -> tensor<14x14x8xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<14x14x8xf32>
@@ -105,12 +59,6 @@
   return %result : tensor<14x14x8xf32>
 }
 
-// CHECK-LABEL: util.func public @no_pack_dilated
-// CHECK-NOT: linalg.pack
-// CHECK: linalg.generic
-// CHECK-SAME: tensor<16x16x4xf32>
-// CHECK-NOT: linalg.unpack
-// CHECK: util.return
 func.func @no_pack_dilated(%lhs: tensor<1x16x16x4xf32>, %rhs: tensor<3x3x4x8xf32>) -> tensor<1x12x12x8xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<1x12x12x8xf32>
@@ -127,12 +75,6 @@
   return %result : tensor<1x12x12x8xf32>
 }
 
-// CHECK-LABEL: util.func public @no_pack_depthwise
-// CHECK-NOT: linalg.pack
-// CHECK: linalg.generic
-// CHECK-SAME: tensor<16x16x4xf32>
-// CHECK-NOT: linalg.unpack
-// CHECK: util.return
 func.func @no_pack_depthwise(%lhs: tensor<1x16x16x4xf32>, %rhs: tensor<3x3x4xf32>) -> tensor<1x14x14x4xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<1x14x14x4xf32>
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_aarch64.mlir
similarity index 96%
rename from compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir
rename to compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_aarch64.mlir
index 03740f1..553e80c 100644
--- a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_aarch64.mlir
@@ -1,6 +1,5 @@
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=dispatch-creation | FileCheck %s
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=executable-targets | FileCheck %s --check-prefix=UKERNEL
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=executable-targets | FileCheck %s --check-prefix=UKERNEL
 
 // Fusing the epilogue and the unpack keeps the contraction on the mmt4d ukernel.
 // UKERNEL-LABEL: llvm.func @dynamic_m_bias_dispatch_{{[0-9]+}}_mmt4d_
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_x86_64.mlir
similarity index 65%
copy from compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir
copy to compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_x86_64.mlir
index 03740f1..13da2a0 100644
--- a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic.mlir
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_dynamic_x86_64.mlir
@@ -1,5 +1,3 @@
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=dispatch-creation | FileCheck %s
-// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=aarch64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=executable-targets | FileCheck %s --check-prefix=UKERNEL
 // RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=executable-targets | FileCheck %s --check-prefix=UKERNEL
 
 // Fusing the epilogue and the unpack keeps the contraction on the mmt4d ukernel.
@@ -14,17 +12,6 @@
 // UKERNEL-LABEL: llvm.func @multi_m_relu_dispatch_{{[0-9]+}}_mmt4d_
 // UKERNEL:         llvm.call @iree_uk_mmt4d
 
-// CHECK-LABEL: util.func public @dynamic_m_bias
-// CHECK: %[[MM:.*]] = linalg.mmt4d
-// CHECK-SAME: -> tensor<8x?x8x8xf32>
-// CHECK-NOT: flow.return
-// CHECK: %[[EPILOGUE:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[MM]]
-// CHECK: arith.addf
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[EPILOGUE]]
-// CHECK-SAME: tensor<8x?x8x8xf32> -> tensor<?x64xf32>
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @dynamic_m_bias(%lhs: tensor<?x128xf32>, %rhs: tensor<128x64xf32>, %bias: tensor<64xf32>) -> tensor<?x64xf32> {
   %zero = arith.constant 0.0 : f32
   %c0 = arith.constant 0 : index
@@ -43,17 +30,6 @@
   return %result : tensor<?x64xf32>
 }
 
-// CHECK-LABEL: util.func public @odd_relu
-// CHECK: %[[MM:.*]] = linalg.mmt4d
-// CHECK-SAME: -> tensor<9x9x8x8xf32>
-// CHECK-NOT: flow.return
-// CHECK: %[[EPILOGUE:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[MM]]
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[EPILOGUE]]
-// CHECK-SAME: tensor<9x9x8x8xf32> -> tensor<65x67xf32>
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @odd_relu(%lhs: tensor<65x129xf32>, %rhs: tensor<129x67xf32>) -> tensor<65x67xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<65x67xf32>
@@ -70,17 +46,6 @@
   return %result : tensor<65x67xf32>
 }
 
-// CHECK-LABEL: util.func public @batched_relu
-// CHECK: %[[MM:.*]] = linalg.batch_mmt4d
-// CHECK-SAME: -> tensor<2x8x8x8x8xf32>
-// CHECK-NOT: flow.return
-// CHECK: %[[EPILOGUE:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[MM]]
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[EPILOGUE]]
-// CHECK-SAME: tensor<2x8x8x8x8xf32> -> tensor<2x64x64xf32>
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
 func.func @batched_relu(%lhs: tensor<2x64x128xf32>, %rhs: tensor<2x128x64xf32>) -> tensor<2x64x64xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<2x64x64xf32>
@@ -97,23 +62,6 @@
   return %result : tensor<2x64x64xf32>
 }
 
-// The widening producer receives the packed input layout. The normal dispatch
-// fusion policy keeps this producer separate; the contraction still owns its
-// epilogue and unpack.
-// CHECK-LABEL: util.func public @extend_producer
-// CHECK: %[[WIDE:.*]] = linalg.generic
-// CHECK-SAME: ins(%{{.*}} : tensor<8192xf16>)
-// CHECK: arith.extf
-// CHECK: arith.mulf
-// CHECK: iree_tensor_ext.dispatch.tensor.store %[[WIDE]]
-// CHECK: flow.return
-// CHECK: %[[MM:.*]] = linalg.mmt4d
-// CHECK-NOT: flow.return
-// CHECK: linalg.generic
-// CHECK-SAME: ins(%[[MM]]
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: linalg.unpack
 func.func @extend_producer(%lhs: tensor<64x128xf16>, %rhs: tensor<128x64xf32>) -> tensor<64x64xf32> {
   %zero = arith.constant 0.0 : f32
   %scale = arith.constant 1.5 : f32
@@ -141,21 +89,6 @@
   return %result : tensor<64x64xf32>
 }
 
-// Normalization adds an expand after the collapsed contraction. Sink it through
-// the epilogue before encoding propagation, then restore the public ABI shape.
-// CHECK-LABEL: util.func public @multi_m_relu
-// CHECK: %[[MM:.*]] = linalg.mmt4d
-// CHECK-SAME: -> tensor<1x1x4x8xf32>
-// CHECK-NOT: flow.return
-// CHECK: %[[RELU:.*]] = linalg.generic
-// CHECK-SAME: ins(%[[MM]] : tensor<1x1x4x8xf32>)
-// CHECK: arith.maximumf
-// CHECK-NOT: flow.return
-// CHECK: %[[UNPACK:.*]] = linalg.unpack %[[RELU]]
-// CHECK-SAME: tensor<1x1x4x8xf32> -> tensor<6x4xf32>
-// CHECK-NEXT: iree_tensor_ext.dispatch.tensor.store %[[UNPACK]]
-// CHECK: flow.tensor.reshape
-// CHECK-SAME: tensor<6x4xf32> -> tensor<2x3x4xf32>
 func.func @multi_m_relu(%a: tensor<2x3x8xf32>, %b: tensor<8x4xf32>) -> tensor<2x3x4xf32> {
   %zero = arith.constant 0.0 : f32
   %empty = tensor.empty() : tensor<2x3x4xf32>
diff --git a/compiler/plugins/target/LLVMCPU/test/early_data_tiling_x86_64.mlir b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_x86_64.mlir
new file mode 100644
index 0000000..93c682e
--- /dev/null
+++ b/compiler/plugins/target/LLVMCPU/test/early_data_tiling_x86_64.mlir
@@ -0,0 +1,25 @@
+// RUN: iree-compile %s --iree-hal-target-backends=llvm-cpu --iree-llvmcpu-target-cpu=generic --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf --iree-opt-experimental-early-data-tiling --compile-to=global-optimization | FileCheck %s --check-prefix=GLOBAL --implicit-check-not=flow.dispatch --implicit-check-not=iree_encoding.set_encoding
+
+// GLOBAL: iree.encoding.materialized_layout_target =
+// GLOBAL-LABEL: util.func public @matmul_relu
+// GLOBAL: %[[MM:.*]] = linalg.mmt4d
+// GLOBAL: linalg.generic
+// GLOBAL-SAME: ins(%[[MM]] : tensor<{{[0-9]+x[0-9]+x[0-9]+x[0-9]+}}xf32>)
+// GLOBAL: arith.maximumf
+// GLOBAL: linalg.unpack
+
+  func.func @matmul_relu(%lhs: tensor<64x128xf32>, %rhs: tensor<128x64xf32>) -> tensor<64x64xf32> {
+    %zero = arith.constant 0.0 : f32
+    %empty = tensor.empty() : tensor<64x64xf32>
+    %init = linalg.fill ins(%zero : f32) outs(%empty : tensor<64x64xf32>) -> tensor<64x64xf32>
+    %mm = linalg.matmul ins(%lhs, %rhs : tensor<64x128xf32>, tensor<128x64xf32>) outs(%init : tensor<64x64xf32>) -> tensor<64x64xf32>
+    %relu = linalg.generic {
+      indexing_maps = [affine_map<(m, n) -> (m, n)>, affine_map<(m, n) -> (m, n)>],
+      iterator_types = ["parallel", "parallel"]}
+      ins(%mm : tensor<64x64xf32>) outs(%empty : tensor<64x64xf32>) {
+    ^bb0(%value: f32, %unused: f32):
+      %result = arith.maximumf %value, %zero : f32
+      linalg.yield %result : f32
+    } -> tensor<64x64xf32>
+    return %relu : tensor<64x64xf32>
+  }
diff --git a/compiler/plugins/target/LLVMCPU/test/roundeven_native.mlir b/compiler/plugins/target/LLVMCPU/test/roundeven_native.mlir
deleted file mode 100644
index 95e8fb6..0000000
--- a/compiler/plugins/target/LLVMCPU/test/roundeven_native.mlir
+++ /dev/null
@@ -1,71 +0,0 @@
-// aarch64:
-// RUN: iree-compile --iree-hal-target-device=local \
-// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
-// RUN:   --iree-llvmcpu-target-triple=aarch64-none-elf \
-// RUN:   --iree-input-demote-f64-to-f32=false \
-// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
-// RUN:   | FileCheck %s --check-prefix=AARCH64
-
-// x86-64, SSE4.1:
-// RUN: iree-compile --iree-hal-target-device=local \
-// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
-// RUN:   --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf \
-// RUN:   --iree-llvmcpu-target-cpu-features=+sse4.1 \
-// RUN:   --iree-input-demote-f64-to-f32=false \
-// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
-// RUN:   | FileCheck %s --check-prefix=SSE41
-
-// x86-64, AVX2 (implies SSE4.1):
-// RUN: iree-compile --iree-hal-target-device=local \
-// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
-// RUN:   --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf \
-// RUN:   --iree-llvmcpu-target-cpu-features=+avx2 \
-// RUN:   --iree-input-demote-f64-to-f32=false \
-// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
-// RUN:   | FileCheck %s --check-prefix=AVX2
-
-// riscv64, RVV with D:
-// RUN: iree-compile --iree-hal-target-device=local \
-// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
-// RUN:   --iree-llvmcpu-target-triple=riscv64-unknown-elf \
-// RUN:   --iree-llvmcpu-target-cpu-features=+m,+a,+f,+d,+c,+v \
-// RUN:   --iree-input-demote-f64-to-f32=false \
-// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
-// RUN:   | FileCheck %s --check-prefix=RISCV64
-
-// AARCH64-LABEL: {{^}}roundeven_f32_dispatch
-// AARCH64:         frintn v{{[0-9]+}}.4s, v{{[0-9]+}}.4s
-// AARCH64-LABEL: {{^}}roundeven_f64_dispatch
-// AARCH64:         frintn v{{[0-9]+}}.2d, v{{[0-9]+}}.2d
-
-// Immediate 8 is round-to-nearest-even with the precision exception
-// suppressed.
-// SSE41-LABEL: {{^}}roundeven_f32_dispatch
-// SSE41:         roundps $8, {{.*}}%xmm
-// SSE41-LABEL: {{^}}roundeven_f64_dispatch
-// SSE41:         roundpd $8, {{.*}}%xmm
-
-// AVX2-LABEL: {{^}}roundeven_f32_dispatch
-// AVX2:         vroundps $8, {{.*}}%ymm
-// AVX2-LABEL: {{^}}roundeven_f64_dispatch
-// AVX2:         vroundpd $8, {{.*}}%ymm
-
-// Rounding mode 0 is round-to-nearest-even.
-// RISCV64-LABEL: {{^}}roundeven_f32_dispatch
-// RISCV64:         fsrmi [[RM:[a-z0-9]+]], 0
-// RISCV64:         vfcvt.x.f.v
-// RISCV64:         fsrm [[RM]]
-// RISCV64-LABEL: {{^}}roundeven_f64_dispatch
-// RISCV64:         fsrmi [[RM:[a-z0-9]+]], 0
-// RISCV64:         vfcvt.x.f.v
-// RISCV64:         fsrm [[RM]]
-
-func.func @roundeven_f32(%arg0: tensor<1024xf32>) -> tensor<1024xf32> {
-  %0 = math.roundeven %arg0 : tensor<1024xf32>
-  return %0 : tensor<1024xf32>
-}
-
-func.func @roundeven_f64(%arg0: tensor<1024xf64>) -> tensor<1024xf64> {
-  %0 = math.roundeven %arg0 : tensor<1024xf64>
-  return %0 : tensor<1024xf64>
-}
diff --git a/compiler/plugins/target/LLVMCPU/test/roundeven_native_aarch64.mlir b/compiler/plugins/target/LLVMCPU/test/roundeven_native_aarch64.mlir
new file mode 100644
index 0000000..949162c
--- /dev/null
+++ b/compiler/plugins/target/LLVMCPU/test/roundeven_native_aarch64.mlir
@@ -0,0 +1,22 @@
+// aarch64:
+// RUN: iree-compile --iree-hal-target-device=local \
+// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
+// RUN:   --iree-llvmcpu-target-triple=aarch64-none-elf \
+// RUN:   --iree-input-demote-f64-to-f32=false \
+// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
+// RUN:   | FileCheck %s --check-prefix=AARCH64
+
+// AARCH64-LABEL: {{^}}roundeven_f32_dispatch
+// AARCH64:         frintn v{{[0-9]+}}.4s, v{{[0-9]+}}.4s
+// AARCH64-LABEL: {{^}}roundeven_f64_dispatch
+// AARCH64:         frintn v{{[0-9]+}}.2d, v{{[0-9]+}}.2d
+
+func.func @roundeven_f32(%arg0: tensor<1024xf32>) -> tensor<1024xf32> {
+  %0 = math.roundeven %arg0 : tensor<1024xf32>
+  return %0 : tensor<1024xf32>
+}
+
+func.func @roundeven_f64(%arg0: tensor<1024xf64>) -> tensor<1024xf64> {
+  %0 = math.roundeven %arg0 : tensor<1024xf64>
+  return %0 : tensor<1024xf64>
+}
diff --git a/compiler/plugins/target/LLVMCPU/test/roundeven_native_riscv64.mlir b/compiler/plugins/target/LLVMCPU/test/roundeven_native_riscv64.mlir
new file mode 100644
index 0000000..53e5222
--- /dev/null
+++ b/compiler/plugins/target/LLVMCPU/test/roundeven_native_riscv64.mlir
@@ -0,0 +1,28 @@
+// riscv64, RVV with D:
+// RUN: iree-compile --iree-hal-target-device=local \
+// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
+// RUN:   --iree-llvmcpu-target-triple=riscv64-unknown-elf \
+// RUN:   --iree-llvmcpu-target-cpu-features=+m,+a,+f,+d,+c,+v \
+// RUN:   --iree-input-demote-f64-to-f32=false \
+// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
+// RUN:   | FileCheck %s --check-prefix=RISCV64
+
+// Rounding mode 0 is round-to-nearest-even.
+// RISCV64-LABEL: {{^}}roundeven_f32_dispatch
+// RISCV64:         fsrmi [[RM:[a-z0-9]+]], 0
+// RISCV64:         vfcvt.x.f.v
+// RISCV64:         fsrm [[RM]]
+// RISCV64-LABEL: {{^}}roundeven_f64_dispatch
+// RISCV64:         fsrmi [[RM:[a-z0-9]+]], 0
+// RISCV64:         vfcvt.x.f.v
+// RISCV64:         fsrm [[RM]]
+
+func.func @roundeven_f32(%arg0: tensor<1024xf32>) -> tensor<1024xf32> {
+  %0 = math.roundeven %arg0 : tensor<1024xf32>
+  return %0 : tensor<1024xf32>
+}
+
+func.func @roundeven_f64(%arg0: tensor<1024xf64>) -> tensor<1024xf64> {
+  %0 = math.roundeven %arg0 : tensor<1024xf64>
+  return %0 : tensor<1024xf64>
+}
diff --git a/compiler/plugins/target/LLVMCPU/test/roundeven_native_x86_64.mlir b/compiler/plugins/target/LLVMCPU/test/roundeven_native_x86_64.mlir
new file mode 100644
index 0000000..fca927b
--- /dev/null
+++ b/compiler/plugins/target/LLVMCPU/test/roundeven_native_x86_64.mlir
@@ -0,0 +1,39 @@
+// x86-64, SSE4.1:
+// RUN: iree-compile --iree-hal-target-device=local \
+// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
+// RUN:   --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf \
+// RUN:   --iree-llvmcpu-target-cpu-features=+sse4.1 \
+// RUN:   --iree-input-demote-f64-to-f32=false \
+// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
+// RUN:   | FileCheck %s --check-prefix=SSE41
+
+// x86-64, AVX2 (implies SSE4.1):
+// RUN: iree-compile --iree-hal-target-device=local \
+// RUN:   --iree-hal-local-target-device-backends=llvm-cpu \
+// RUN:   --iree-llvmcpu-target-triple=x86_64-unknown-unknown-eabi-elf \
+// RUN:   --iree-llvmcpu-target-cpu-features=+avx2 \
+// RUN:   --iree-input-demote-f64-to-f32=false \
+// RUN:   --iree-hal-dump-executable-intermediates-to=- %s -o /dev/null \
+// RUN:   | FileCheck %s --check-prefix=AVX2
+
+// Immediate 8 is round-to-nearest-even with the precision exception
+// suppressed.
+// SSE41-LABEL: {{^}}roundeven_f32_dispatch
+// SSE41:         roundps $8, {{.*}}%xmm
+// SSE41-LABEL: {{^}}roundeven_f64_dispatch
+// SSE41:         roundpd $8, {{.*}}%xmm
+
+// AVX2-LABEL: {{^}}roundeven_f32_dispatch
+// AVX2:         vroundps $8, {{.*}}%ymm
+// AVX2-LABEL: {{^}}roundeven_f64_dispatch
+// AVX2:         vroundpd $8, {{.*}}%ymm
+
+func.func @roundeven_f32(%arg0: tensor<1024xf32>) -> tensor<1024xf32> {
+  %0 = math.roundeven %arg0 : tensor<1024xf32>
+  return %0 : tensor<1024xf32>
+}
+
+func.func @roundeven_f64(%arg0: tensor<1024xf64>) -> tensor<1024xf64> {
+  %0 = math.roundeven %arg0 : tensor<1024xf64>
+  return %0 : tensor<1024xf64>
+}