1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 ; Verify that a constant with size in excess of 32-bit SIZE_MAX doesn't
5 ; cause trouble. This test exercises an internal limit set arbitrarily
6 ; at 64K for the largest supported zeroinitiazer. If the limit changes
7 ; the test might need to be adjusted.
9 declare ptr @memrchr(ptr, i32, i64)
11 @a = constant <{ i8, [4294967295 x i8] }> <{ i8 1, [4294967295 x i8] zeroinitializer }>
13 ; Verify reading an initializer INT32_MAX + 1 bytes large (starting at
14 ; offset 2147483647 into a which is UINT32_MAX bytes in size).
16 define ptr @call_a_pi32max_p1() {
17 ; CHECK-LABEL: @call_a_pi32max_p1(
18 ; CHECK-NEXT: [[CHR:%.*]] = tail call ptr @memrchr(ptr noundef nonnull dereferenceable(2147483647) getelementptr inbounds (i8, ptr @a, i64 2147483648), i32 0, i64 2147483647)
19 ; CHECK-NEXT: ret ptr [[CHR]]
21 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i32 2147483647
22 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 2147483647)
26 ; Verify reading an initializer INT32_MAX bytes large (starting at offset
27 ; 2147483648 into a which is UINT32_MAX bytes in size).
29 define ptr @call_a_pi32max() {
30 ; CHECK-LABEL: @call_a_pi32max(
31 ; CHECK-NEXT: [[CHR:%.*]] = tail call ptr @memrchr(ptr noundef nonnull dereferenceable(2147483647) getelementptr inbounds (i8, ptr @a, i64 2147483649), i32 0, i64 2147483647)
32 ; CHECK-NEXT: ret ptr [[CHR]]
34 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i64 2147483648
35 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 2147483647)
40 ; Verify reading an initializer UINT32_MAX bytes large (starting at offset
43 define ptr @call_a_pui32max() {
44 ; CHECK-LABEL: @call_a_pui32max(
45 ; CHECK-NEXT: [[CHR:%.*]] = tail call ptr @memrchr(ptr noundef nonnull dereferenceable(4294967295) getelementptr inbounds (i8, ptr @a, i64 1), i32 0, i64 4294967295)
46 ; CHECK-NEXT: ret ptr [[CHR]]
48 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i32 0
49 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 4294967295)
53 ; Verify reading an initializer UINT32_MAX + 1 bytes large (all of a).
55 define ptr @call_a_puimax_p1() {
56 ; CHECK-LABEL: @call_a_puimax_p1(
57 ; CHECK-NEXT: [[CHR:%.*]] = tail call ptr @memrchr(ptr noundef nonnull dereferenceable(4294967296) @a, i32 0, i64 4294967296)
58 ; CHECK-NEXT: ret ptr [[CHR]]
60 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 0
61 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 4294967296)