Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/InstSimplify/structured-gep.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

92 lines
3.0 KiB
LLVM

; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
%struct.S = type { i32, float }
%struct.Nested = type { %struct.S, i32 }
@g = external global i32
@arr = external global [10 x i32]
define ptr @zero_index_local(ptr %p) {
; CHECK-LABEL: @zero_index_local(ptr %p
; CHECK-NEXT: ret ptr %p
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(i32) %p)
ret ptr %sgep
}
define ptr @zero_index_global() {
; CHECK-LABEL: @zero_index_global(
; CHECK-NEXT: ret ptr @g
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(i32) @g)
ret ptr %sgep
}
define ptr @zero_index_array(ptr %p) {
; CHECK-LABEL: @zero_index_array(ptr %p
; CHECK-NEXT: ret ptr %p
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype([10 x i32]) %p)
ret ptr %sgep
}
define ptr addrspace(11) @zero_index_addrspace(ptr addrspace(11) %p) {
; CHECK-LABEL: @zero_index_addrspace(ptr addrspace(11) %p
; CHECK-NEXT: ret ptr addrspace(11) %p
;
%sgep = call ptr addrspace(11) (ptr addrspace(11), ...) @llvm.structured.gep.p11(ptr addrspace(11) elementtype(i32) %p)
ret ptr addrspace(11) %sgep
}
define i32 @zero_index_with_load(ptr %p) {
; CHECK-LABEL: @zero_index_with_load(ptr %p
; CHECK-NEXT: [[V:%.*]] = load i32, ptr %p, align 4
; CHECK-NEXT: ret i32 [[V]]
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(i32) %p)
%v = load i32, ptr %sgep, align 4
ret i32 %v
}
; GEP with a zero index can be simplified, but SGEP cannot.
define ptr @zero_index_struct(ptr %p) {
; CHECK-LABEL: @zero_index_struct(ptr %p
; CHECK-NEXT: [[SGEP:%.*]] = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.S) %p, i32 0)
; CHECK-NEXT: ret ptr [[SGEP]]
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.S) %p, i32 0)
ret ptr %sgep
}
define ptr @one_index_struct(ptr %p) {
; CHECK-LABEL: @one_index_struct(ptr %p
; CHECK-NEXT: [[SGEP:%.*]] = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.S) %p, i32 1)
; CHECK-NEXT: ret ptr [[SGEP]]
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.S) %p, i32 1)
ret ptr %sgep
}
define ptr @multi_index_nested(ptr %p) {
; CHECK-LABEL: @multi_index_nested(
; CHECK-NEXT: [[SGEP:%.*]] = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.Nested) %p, i32 0, i32 0)
; CHECK-NEXT: ret ptr [[SGEP]]
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype(%struct.Nested) %p, i32 0, i32 0)
ret ptr %sgep
}
define ptr @dynamic_index(ptr %p, i32 %i) {
; CHECK-LABEL: @dynamic_index(
; CHECK-NEXT: [[SGEP:%.*]] = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype([10 x i32]) %p, i32 %i)
; CHECK-NEXT: ret ptr [[SGEP]]
;
%sgep = call ptr (ptr, ...) @llvm.structured.gep.p0(ptr elementtype([10 x i32]) %p, i32 %i)
ret ptr %sgep
}
declare ptr @llvm.structured.gep.p0(ptr, ...) #0
declare ptr addrspace(11) @llvm.structured.gep.p11(ptr addrspace(11), ...) #0
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }