Files
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

67 lines
2.1 KiB
MLIR

// RUN: mlir-opt %s -convert-cf-to-llvm -split-input-file | FileCheck %s
// Unstructured control flow is converted, but the enclosing op is not
// converted.
// CHECK-LABEL: func.func @single_case(
// CHECK-SAME: %[[val:.*]]: i32, %[[idx:.*]]: index) -> index {
// CHECK: %[[cast0:.*]] = builtin.unrealized_conversion_cast %[[idx]] : index to i64
// CHECK: llvm.switch %[[val]] : i32, ^[[bb1:.*]](%[[cast0]] : i64) [
// CHECK: ]
// CHECK: ^[[bb1]](%[[arg0:.*]]: i64):
// CHECK: %[[cast1:.*]] = builtin.unrealized_conversion_cast %[[arg0]] : i64 to index
// CHECK: return %[[cast1]] : index
// CHECK: }
func.func @single_case(%val: i32, %idx: index) -> index {
cf.switch %val : i32, [
default: ^bb1(%idx : index)
]
^bb1(%arg0: index):
return %arg0 : index
}
// -----
// func.func and func.return types match. No unrealized_conversion_cast is
// needed.
// CHECK-LABEL: func.func @single_case_type_match(
// CHECK-SAME: %[[val:.*]]: i32, %[[i:.*]]: i64) -> i64 {
// CHECK: llvm.switch %[[val]] : i32, ^[[bb1:.*]](%[[i]] : i64) [
// CHECK: ]
// CHECK: ^[[bb1]](%[[arg0:.*]]: i64):
// CHECK: return %[[arg0]] : i64
// CHECK: }
func.func @single_case_type_match(%val: i32, %i: i64) -> i64 {
cf.switch %val : i32, [
default: ^bb1(%i : i64)
]
^bb1(%arg0: i64):
return %arg0 : i64
}
// -----
// CHECK-LABEL: func.func @multi_case
// CHECK-COUNT-2: unrealized_conversion_cast {{.*}} : index to i64
// CHECK: llvm.switch %{{.*}} : i32, ^{{.*}}(%{{.*}} : i64) [
// CHECK: 12: ^{{.*}}(%{{.*}} : i64),
// CHECK: 13: ^{{.*}}(%{{.*}} : i64),
// CHECK: 14: ^{{.*}}(%{{.*}} : i64)
// CHECK: ]
func.func @multi_case(%val: i32, %idx1: index, %idx2: index, %i: i64) -> index {
cf.switch %val : i32, [
default: ^bb1(%idx1 : index),
12: ^bb2(%idx2 : index),
13: ^bb1(%idx1 : index),
14: ^bb3(%i : i64)
]
^bb1(%arg0: index):
return %arg0 : index
^bb2(%arg1: index):
return %arg1 : index
^bb3(%arg2: i64):
%cast = arith.index_cast %arg2 : i64 to index
return %cast : index
}