Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/SimpleLoopUnswitch/AMDGPU/nontrivial-unswitch-divergent-target.ll
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

184 lines
5.6 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -mtriple=amdgcn-- -passes='loop(simple-loop-unswitch<nontrivial>),verify<loops>' -S < %s | FileCheck %s
; RUN: opt -mtriple=amdgcn-- -passes='loop-mssa(simple-loop-unswitch<nontrivial>),verify<loops>' -S < %s | FileCheck %s
; RUN: opt -mtriple=amdgcn-- -passes='simple-loop-unswitch<nontrivial>' -verify-memoryssa -S < %s | FileCheck %s
declare i32 @a()
declare i32 @b()
declare i32 @c()
; Non-trivial loop unswitching where there are two distinct trivial
; conditions to unswitch within the loop. The conditions are divergent
; and should not unswitch.
define void @test1(ptr %ptr, i1 %cond1, i1 %cond2) {
; CHECK-LABEL: define void @test1(
; CHECK-SAME: ptr [[PTR:%.*]], i1 [[COND1:%.*]], i1 [[COND2:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: br label %[[LOOP_BEGIN:.*]]
; CHECK: [[LOOP_BEGIN]]:
; CHECK-NEXT: br i1 [[COND1]], label %[[LOOP_A:.*]], label %[[LOOP_B:.*]]
; CHECK: [[LOOP_A]]:
; CHECK-NEXT: [[UNUSED_A:%.*]] = call i32 @a()
; CHECK-NEXT: br label %[[LATCH:.*]]
; CHECK: [[LOOP_B]]:
; CHECK-NEXT: br i1 [[COND2]], label %[[LOOP_B_A:.*]], label %[[LOOP_B_B:.*]]
; CHECK: [[LOOP_B_A]]:
; CHECK-NEXT: [[UNUSED_B:%.*]] = call i32 @b()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LOOP_B_B]]:
; CHECK-NEXT: [[UNUSED_C:%.*]] = call i32 @c()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LATCH]]:
; CHECK-NEXT: [[V:%.*]] = load i1, ptr [[PTR]], align 1
; CHECK-NEXT: br i1 [[V]], label %[[LOOP_BEGIN]], label %[[LOOP_EXIT:.*]]
; CHECK: [[LOOP_EXIT]]:
; CHECK-NEXT: ret void
;
entry:
br label %loop_begin
loop_begin:
br i1 %cond1, label %loop_a, label %loop_b
loop_a:
%unused.a = call i32 @a()
br label %latch
loop_b:
br i1 %cond2, label %loop_b_a, label %loop_b_b
loop_b_a:
%unused.b = call i32 @b()
br label %latch
loop_b_b:
%unused.c = call i32 @c()
br label %latch
latch:
%v = load i1, ptr %ptr
br i1 %v, label %loop_begin, label %loop_exit
loop_exit:
ret void
}
; Non-trivial loop unswitching where there are two distinct trivial
; conditions to unswitch within the loop. The conditions are known to
; be uniform, so it should be unswitchable. However, unswitch
; currently does not make use of UniformityAnalysis.
define amdgpu_kernel void @test1_uniform(ptr %ptr, i1 %cond1, i1 %cond2) {
; CHECK-LABEL: define amdgpu_kernel void @test1_uniform(
; CHECK-SAME: ptr [[PTR:%.*]], i1 [[COND1:%.*]], i1 [[COND2:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: br label %[[LOOP_BEGIN:.*]]
; CHECK: [[LOOP_BEGIN]]:
; CHECK-NEXT: br i1 [[COND1]], label %[[LOOP_A:.*]], label %[[LOOP_B:.*]]
; CHECK: [[LOOP_A]]:
; CHECK-NEXT: [[UNUSED_A:%.*]] = call i32 @a()
; CHECK-NEXT: br label %[[LATCH:.*]]
; CHECK: [[LOOP_B]]:
; CHECK-NEXT: br i1 [[COND2]], label %[[LOOP_B_A:.*]], label %[[LOOP_B_B:.*]]
; CHECK: [[LOOP_B_A]]:
; CHECK-NEXT: [[UNUSED_B:%.*]] = call i32 @b()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LOOP_B_B]]:
; CHECK-NEXT: [[UNUSED_C:%.*]] = call i32 @c()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LATCH]]:
; CHECK-NEXT: [[V:%.*]] = load i1, ptr [[PTR]], align 1
; CHECK-NEXT: br i1 [[V]], label %[[LOOP_BEGIN]], label %[[LOOP_EXIT:.*]]
; CHECK: [[LOOP_EXIT]]:
; CHECK-NEXT: ret void
;
entry:
br label %loop_begin
loop_begin:
br i1 %cond1, label %loop_a, label %loop_b
loop_a:
%unused.a = call i32 @a()
br label %latch
loop_b:
br i1 %cond2, label %loop_b_a, label %loop_b_b
loop_b_a:
%unused.b = call i32 @b()
br label %latch
loop_b_b:
%unused.c = call i32 @c()
br label %latch
latch:
%v = load i1, ptr %ptr
br i1 %v, label %loop_begin, label %loop_exit
loop_exit:
ret void
}
; Non-trivial loop unswitching where there are two distinct trivial
; conditions to unswitch within the loop. There is no divergence
; because it's assumed it can only execute with a workgroup of size 1.
define void @test1_single_lane_execution(ptr %ptr, i1 %cond1, i1 %cond2) #0 {
; CHECK-LABEL: define void @test1_single_lane_execution(
; CHECK-SAME: ptr [[PTR:%.*]], i1 [[COND1:%.*]], i1 [[COND2:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: br label %[[LOOP_BEGIN:.*]]
; CHECK: [[LOOP_BEGIN]]:
; CHECK-NEXT: br i1 [[COND1]], label %[[LOOP_A:.*]], label %[[LOOP_B:.*]]
; CHECK: [[LOOP_A]]:
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @a()
; CHECK-NEXT: br label %[[LATCH:.*]]
; CHECK: [[LOOP_B]]:
; CHECK-NEXT: br i1 [[COND2]], label %[[LOOP_B_A:.*]], label %[[LOOP_B_B:.*]]
; CHECK: [[LOOP_B_A]]:
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @b()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LOOP_B_B]]:
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @c()
; CHECK-NEXT: br label %[[LATCH]]
; CHECK: [[LATCH]]:
; CHECK-NEXT: [[V:%.*]] = load i1, ptr [[PTR]], align 1
; CHECK-NEXT: br i1 [[V]], label %[[LOOP_BEGIN]], label %[[LOOP_EXIT:.*]]
; CHECK: [[LOOP_EXIT]]:
; CHECK-NEXT: ret void
;
entry:
br label %loop_begin
loop_begin:
br i1 %cond1, label %loop_a, label %loop_b
loop_a:
call i32 @a()
br label %latch
; The 'loop_a' unswitched loop.
loop_b:
br i1 %cond2, label %loop_b_a, label %loop_b_b
; The second unswitched condition.
loop_b_a:
call i32 @b()
br label %latch
; The 'loop_b_a' unswitched loop.
loop_b_b:
call i32 @c()
br label %latch
; The 'loop_b_b' unswitched loop.
latch:
%v = load i1, ptr %ptr
br i1 %v, label %loop_begin, label %loop_exit
loop_exit:
ret void
}
attributes #0 = { "amdgpu-flat-work-group-size"="1,1" }