xref: /llvm-project/llvm/test/Other/optimize-inrange-gep.ll (revision 29441e4f5fa5f5c7709f7cf180815ba97f611297)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2; RUN: opt -O0 -S < %s | FileCheck %s --check-prefix=O0
3; RUN: opt -O1 -S < %s | FileCheck %s
4; RUN: opt -O2 -S < %s | FileCheck %s
5; RUN: opt -O3 -S < %s | FileCheck %s
6; RUN: opt -Os -S < %s | FileCheck %s
7; RUN: opt -Oz -S < %s | FileCheck %s
8
9target datalayout = "e-p:64:64"
10
11; Make sure that optimizations do not lose inrange information.
12
13@vtable = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr null] }
14
15define void @foo(ptr %p) {
16; O0-LABEL: define void @foo(
17; O0-SAME: ptr [[P:%.*]]) {
18; O0-NEXT:    store ptr getelementptr inrange(-24, 0) ({ [3 x ptr], [3 x ptr] }, ptr @vtable, i32 0, i32 0, i32 3), ptr [[P]], align 8
19; O0-NEXT:    ret void
20;
21; CHECK-LABEL: define void @foo(
22; CHECK-SAME: ptr writeonly captures(none) initializes((0, 8)) [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
23; CHECK-NEXT:    store ptr getelementptr inbounds nuw inrange(-24, 0) (i8, ptr @vtable, i64 24), ptr [[P]], align 8
24; CHECK-NEXT:    ret void
25;
26  store ptr getelementptr inrange(-24, 0) ({ [3 x ptr], [3 x ptr] }, ptr @vtable, i32 0, i32 0, i32 3), ptr %p
27  ret void
28}
29