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
146 lines
6.0 KiB
LLVM
146 lines
6.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5
|
|
; RUN: opt -passes='simplifycfg<switch-to-lookup>' -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
;.
|
|
; CHECK: @switch.table.switch_of_powers_two = private unnamed_addr constant [7 x i32] [i32 3, i32 poison, i32 poison, i32 2, i32 1, i32 0, i32 42], align 4
|
|
; CHECK: @switch.table.switch_of_powers_two_default_reachable = private unnamed_addr constant [7 x i32] [i32 3, i32 5, i32 5, i32 2, i32 1, i32 0, i32 42], align 4
|
|
; CHECK: @switch.table.switch_of_powers_two_default_reachable_multipreds = private unnamed_addr constant [7 x i32] [i32 3, i32 poison, i32 poison, i32 2, i32 1, i32 0, i32 42], align 4
|
|
;.
|
|
define i32 @switch_of_powers_two(i32 %arg) {
|
|
; CHECK-LABEL: define i32 @switch_of_powers_two(
|
|
; CHECK-SAME: i32 [[ARG:%.*]]) {
|
|
; CHECK-NEXT: [[ENTRY:.*:]]
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.cttz.i32(i32 [[ARG]], i1 true)
|
|
; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[TMP0]] to i64
|
|
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [7 x i32], ptr @switch.table.switch_of_powers_two, i64 0, i64 [[TMP1]]
|
|
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
|
|
; CHECK-NEXT: ret i32 [[SWITCH_LOAD]]
|
|
;
|
|
entry:
|
|
switch i32 %arg, label %default_case [
|
|
i32 1, label %bb1
|
|
i32 8, label %bb2
|
|
i32 16, label %bb3
|
|
i32 32, label %bb4
|
|
i32 64, label %bb5
|
|
]
|
|
|
|
|
|
default_case: unreachable
|
|
bb1: br label %return
|
|
bb2: br label %return
|
|
bb3: br label %return
|
|
bb4: br label %return
|
|
bb5: br label %return
|
|
|
|
return:
|
|
%phi = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ]
|
|
ret i32 %phi
|
|
}
|
|
|
|
define i32 @switch_of_powers_two_default_reachable(i32 %arg) !prof !0 {
|
|
; CHECK-LABEL: define i32 @switch_of_powers_two_default_reachable(
|
|
; CHECK-SAME: i32 [[ARG:%.*]]) !prof [[PROF0:![0-9]+]] {
|
|
; CHECK-NEXT: [[ENTRY:.*]]:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.ctpop.i32(i32 [[ARG]])
|
|
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 1
|
|
; CHECK-NEXT: br i1 [[TMP1]], label %[[ENTRY_SPLIT:.*]], label %[[RETURN:.*]], !prof [[PROF1:![0-9]+]]
|
|
; CHECK: [[ENTRY_SPLIT]]:
|
|
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.cttz.i32(i32 [[ARG]], i1 true)
|
|
; CHECK-NEXT: [[TMP3:%.*]] = icmp ult i32 [[TMP2]], 7
|
|
; CHECK-NEXT: br i1 [[TMP3]], label %[[SWITCH_LOOKUP:.*]], label %[[RETURN]], !prof [[PROF2:![0-9]+]]
|
|
; CHECK: [[SWITCH_LOOKUP]]:
|
|
; CHECK-NEXT: [[TMP4:%.*]] = zext nneg i32 [[TMP2]] to i64
|
|
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [7 x i32], ptr @switch.table.switch_of_powers_two_default_reachable, i64 0, i64 [[TMP4]]
|
|
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
|
|
; CHECK-NEXT: br label %[[RETURN]]
|
|
; CHECK: [[RETURN]]:
|
|
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[SWITCH_LOAD]], %[[SWITCH_LOOKUP]] ], [ 5, %[[ENTRY_SPLIT]] ], [ 5, %[[ENTRY]] ]
|
|
; CHECK-NEXT: ret i32 [[PHI]]
|
|
;
|
|
entry:
|
|
switch i32 %arg, label %default_case [
|
|
i32 1, label %bb1
|
|
i32 8, label %bb2
|
|
i32 16, label %bb3
|
|
i32 32, label %bb4
|
|
i32 64, label %bb5
|
|
], !prof !1
|
|
|
|
default_case: br label %return
|
|
bb1: br label %return
|
|
bb2: br label %return
|
|
bb3: br label %return
|
|
bb4: br label %return
|
|
bb5: br label %return
|
|
|
|
return:
|
|
%phi = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ], [ 5, %default_case ]
|
|
ret i32 %phi
|
|
}
|
|
|
|
define i32 @switch_of_powers_two_default_reachable_multipreds(i32 %arg, i1 %cond) {
|
|
; CHECK-LABEL: define i32 @switch_of_powers_two_default_reachable_multipreds(
|
|
; CHECK-SAME: i32 [[ARG:%.*]], i1 [[COND:%.*]]) {
|
|
; CHECK-NEXT: [[ENTRY:.*]]:
|
|
; CHECK-NEXT: br i1 [[COND]], label %[[SWITCH:.*]], label %[[RETURN:.*]]
|
|
; CHECK: [[SWITCH]]:
|
|
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.ctpop.i32(i32 [[ARG]])
|
|
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 1
|
|
; CHECK-NEXT: br i1 [[TMP1]], label %[[SWITCH_SPLIT:.*]], label %[[RETURN]]
|
|
; CHECK: [[SWITCH_SPLIT]]:
|
|
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.cttz.i32(i32 [[ARG]], i1 true)
|
|
; CHECK-NEXT: [[TMP3:%.*]] = icmp ult i32 [[TMP2]], 7
|
|
; CHECK-NEXT: [[SWITCH_MASKINDEX:%.*]] = trunc i32 [[TMP2]] to i8
|
|
; CHECK-NEXT: [[SWITCH_SHIFTED:%.*]] = lshr i8 121, [[SWITCH_MASKINDEX]]
|
|
; CHECK-NEXT: [[SWITCH_LOBIT:%.*]] = trunc i8 [[SWITCH_SHIFTED]] to i1
|
|
; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[TMP3]], i1 [[SWITCH_LOBIT]], i1 false
|
|
; CHECK-NEXT: br i1 [[OR_COND]], label %[[SWITCH_LOOKUP:.*]], label %[[RETURN]]
|
|
; CHECK: [[SWITCH_LOOKUP]]:
|
|
; CHECK-NEXT: [[TMP4:%.*]] = zext nneg i32 [[TMP2]] to i64
|
|
; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [7 x i32], ptr @switch.table.switch_of_powers_two_default_reachable_multipreds, i64 0, i64 [[TMP4]]
|
|
; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
|
|
; CHECK-NEXT: br label %[[RETURN]]
|
|
; CHECK: [[RETURN]]:
|
|
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[SWITCH_LOAD]], %[[SWITCH_LOOKUP]] ], [ 0, %[[ENTRY]] ], [ [[ARG]], %[[SWITCH]] ], [ [[ARG]], %[[SWITCH_SPLIT]] ]
|
|
; CHECK-NEXT: ret i32 [[PHI]]
|
|
;
|
|
entry:
|
|
br i1 %cond, label %switch, label %default_case
|
|
|
|
switch:
|
|
switch i32 %arg, label %default_case [
|
|
i32 1, label %bb1
|
|
i32 8, label %bb2
|
|
i32 16, label %bb3
|
|
i32 32, label %bb4
|
|
i32 64, label %bb5
|
|
]
|
|
|
|
default_case:
|
|
%pn = phi i32 [ 0, %entry ], [ %arg, %switch ]
|
|
br label %return
|
|
|
|
bb1: br label %return
|
|
bb2: br label %return
|
|
bb3: br label %return
|
|
bb4: br label %return
|
|
bb5: br label %return
|
|
|
|
return:
|
|
%phi = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ], [ %pn, %default_case ]
|
|
ret i32 %phi
|
|
}
|
|
|
|
!0 = !{!"function_entry_count", i32 10}
|
|
!1 = !{!"branch_weights", i32 10, i32 5, i32 7, i32 11, i32 13, i32 17}
|
|
;.
|
|
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
|
|
;.
|
|
; CHECK: [[PROF0]] = !{!"function_entry_count", i32 10}
|
|
; CHECK: [[PROF1]] = !{!"branch_weights", i32 58, i32 5}
|
|
; CHECK: [[PROF2]] = !{!"branch_weights", i32 53, i32 5}
|
|
;.
|