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
88 lines
3.4 KiB
LLVM
88 lines
3.4 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
declare void @use(i32) readonly
|
|
|
|
; We prefer to canonicalize the machine width gep indices early
|
|
define void @test(ptr %p, i32 %index) {
|
|
; CHECK-LABEL: define void @test(
|
|
; CHECK-SAME: ptr [[P:%.*]], i32 [[INDEX:%.*]]) {
|
|
; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[INDEX]] to i64
|
|
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr [4 x i8], ptr [[P]], i64 [[TMP1]]
|
|
; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADDR]], align 4
|
|
; CHECK-NEXT: call void @use(i32 [[VAL]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%addr = getelementptr i32, ptr %p, i32 %index
|
|
%val = load i32, ptr %addr
|
|
call void @use(i32 %val)
|
|
ret void
|
|
}
|
|
; If they've already been canonicalized via zext, that's fine
|
|
define void @test2(ptr %p, i32 %index) {
|
|
; CHECK-LABEL: define void @test2(
|
|
; CHECK-SAME: ptr [[P:%.*]], i32 [[INDEX:%.*]]) {
|
|
; CHECK-NEXT: [[I:%.*]] = zext i32 [[INDEX]] to i64
|
|
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr [4 x i8], ptr [[P]], i64 [[I]]
|
|
; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADDR]], align 4
|
|
; CHECK-NEXT: call void @use(i32 [[VAL]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%i = zext i32 %index to i64
|
|
%addr = getelementptr i32, ptr %p, i64 %i
|
|
%val = load i32, ptr %addr
|
|
call void @use(i32 %val)
|
|
ret void
|
|
}
|
|
; If we can use a zext, we prefer that. This requires
|
|
; knowing that the index is positive.
|
|
define void @test3(ptr %p, i32 %index) {
|
|
; CHECK-LABEL: define void @test3(
|
|
; CHECK-SAME: ptr [[P:%.*]], i32 [[INDEX:%.*]]) {
|
|
; CHECK-NEXT: [[ADDR_BEGIN:%.*]] = getelementptr i8, ptr [[P]], i64 160
|
|
; CHECK-NEXT: [[ADDR_FIXED:%.*]] = getelementptr i8, ptr [[P]], i64 352
|
|
; CHECK-NEXT: [[VAL_FIXED:%.*]] = load i32, ptr [[ADDR_FIXED]], align 4, !range [[RNG0:![0-9]+]]
|
|
; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[VAL_FIXED]] to i64
|
|
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr [4 x i8], ptr [[ADDR_BEGIN]], i64 [[TMP1]]
|
|
; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADDR]], align 4
|
|
; CHECK-NEXT: call void @use(i32 [[VAL]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%addr_begin = getelementptr i32, ptr %p, i64 40
|
|
%addr_fixed = getelementptr i32, ptr %addr_begin, i64 48
|
|
%val_fixed = load i32, ptr %addr_fixed, !range !0
|
|
%addr = getelementptr i32, ptr %addr_begin, i32 %val_fixed
|
|
%val = load i32, ptr %addr
|
|
call void @use(i32 %val)
|
|
ret void
|
|
}
|
|
; Replace sext with zext where possible
|
|
define void @test4(ptr %p, i32 %index) {
|
|
; CHECK-LABEL: define void @test4(
|
|
; CHECK-SAME: ptr [[P:%.*]], i32 [[INDEX:%.*]]) {
|
|
; CHECK-NEXT: [[ADDR_BEGIN:%.*]] = getelementptr i8, ptr [[P]], i64 160
|
|
; CHECK-NEXT: [[ADDR_FIXED:%.*]] = getelementptr i8, ptr [[P]], i64 352
|
|
; CHECK-NEXT: [[VAL_FIXED:%.*]] = load i32, ptr [[ADDR_FIXED]], align 4, !range [[RNG0]]
|
|
; CHECK-NEXT: [[I:%.*]] = zext nneg i32 [[VAL_FIXED]] to i64
|
|
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr [4 x i8], ptr [[ADDR_BEGIN]], i64 [[I]]
|
|
; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ADDR]], align 4
|
|
; CHECK-NEXT: call void @use(i32 [[VAL]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
%addr_begin = getelementptr i32, ptr %p, i64 40
|
|
%addr_fixed = getelementptr i32, ptr %addr_begin, i64 48
|
|
%val_fixed = load i32, ptr %addr_fixed, !range !0
|
|
%i = sext i32 %val_fixed to i64
|
|
%addr = getelementptr i32, ptr %addr_begin, i64 %i
|
|
%val = load i32, ptr %addr
|
|
call void @use(i32 %val)
|
|
ret void
|
|
}
|
|
|
|
;; !range !0
|
|
!0 = !{i32 0, i32 2147483647}
|
|
|
|
;.
|
|
; CHECK: [[RNG0]] = !{i32 0, i32 2147483647}
|
|
;.
|