Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/GlobalOpt/global-demotion.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

80 lines
2.4 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=globalopt -S < %s | FileCheck %s
@G1 = internal global i32 5
@G2 = internal global i32 5
@G3 = internal global i32 5
@G4 = internal global i32 5
@G5 = internal global i32 5
define i32 @test1() norecurse {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[G1:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 5, ptr [[G1]], align 4
; CHECK-NEXT: store i32 4, ptr [[G1]], align 4
; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[G1]], align 4
; CHECK-NEXT: ret i32 [[A]]
;
store i32 4, ptr @G1
%a = load i32, ptr @G1
ret i32 %a
}
; The load comes before the store which makes @G2 live before the call.
define i32 @test2() norecurse {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[A_B:%.*]] = load i1, ptr @G2, align 1
; CHECK-NEXT: [[A:%.*]] = select i1 [[A_B]], i32 4, i32 5
; CHECK-NEXT: store i1 true, ptr @G2, align 1
; CHECK-NEXT: ret i32 [[A]]
;
%a = load i32, ptr @G2
store i32 4, ptr @G2
ret i32 %a
}
; This global is indexed by a GEP - this makes it partial alias and we bail out.
; FIXME: We don't actually have to bail out in this case.
define i32 @test3() norecurse {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[A_B:%.*]] = load i1, ptr @G3, align 1
; CHECK-NEXT: [[A:%.*]] = select i1 [[A_B]], i32 4, i32 5
; CHECK-NEXT: store i1 true, ptr @G3, align 1
; CHECK-NEXT: ret i32 [[A]]
;
%a = load i32, ptr @G3
store i32 4, ptr @G3
ret i32 %a
}
; The global is casted away to a larger type then loaded. The store only partially
; covers the load, so we must not demote.
define i32 @test4() norecurse {
; CHECK-LABEL: @test4(
; CHECK-NEXT: store i32 4, ptr @G4, align 4
; CHECK-NEXT: [[A:%.*]] = load i64, ptr @G4, align 4
; CHECK-NEXT: [[B:%.*]] = trunc i64 [[A]] to i32
; CHECK-NEXT: ret i32 [[B]]
;
store i32 4, ptr @G4
%a = load i64, ptr @G4
%b = trunc i64 %a to i32
ret i32 %b
}
; The global is casted away to a smaller type then loaded. This one is fine.
define i32 @test5() norecurse {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[G5:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 5, ptr [[G5]], align 4
; CHECK-NEXT: store i32 4, ptr [[G5]], align 4
; CHECK-NEXT: [[A:%.*]] = load i16, ptr [[G5]], align 2
; CHECK-NEXT: [[B:%.*]] = zext i16 [[A]] to i32
; CHECK-NEXT: ret i32 [[B]]
;
store i32 4, ptr @G5
%a = load i16, ptr @G5
%b = zext i16 %a to i32
ret i32 %b
}