64 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3;4; Verify that a constant with size in excess of 32-bit SIZE_MAX doesn't5; cause trouble. This test exercises an internal limit set arbitrarily6; at 64K for the largest supported zeroinitiazer. If the limit changes7; the test might need to be adjusted.8 9declare ptr @memrchr(ptr, i32, i64)10 11@a = constant <{ i8, [4294967295 x i8] }> <{ i8 1, [4294967295 x i8] zeroinitializer }>12 13; Verify reading an initializer INT32_MAX + 1 bytes large (starting at14; offset 2147483647 into a which is UINT32_MAX bytes in size).15 16define 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 nuw (i8, ptr @a, i64 2147483648), i32 0, i64 2147483647)19; CHECK-NEXT: ret ptr [[CHR]]20;21 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i32 214748364722 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 2147483647)23 ret ptr %chr24}25 26; Verify reading an initializer INT32_MAX bytes large (starting at offset27; 2147483648 into a which is UINT32_MAX bytes in size).28 29define 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 nuw (i8, ptr @a, i64 2147483649), i32 0, i64 2147483647)32; CHECK-NEXT: ret ptr [[CHR]]33;34 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i64 214748364835 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 2147483647)36 ret ptr %chr37}38 39 40; Verify reading an initializer UINT32_MAX bytes large (starting at offset41; 1 into a).42 43define 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 nuw (i8, ptr @a, i64 1), i32 0, i64 4294967295)46; CHECK-NEXT: ret ptr [[CHR]]47;48 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 1, i32 049 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 4294967295)50 ret ptr %chr51}52 53; Verify reading an initializer UINT32_MAX + 1 bytes large (all of a).54 55define 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]]59;60 %ptr = getelementptr <{ i8, [4294967295 x i8] }>, ptr @a, i32 0, i32 061 %chr = tail call ptr @memrchr(ptr %ptr, i32 0, i64 4294967296)62 ret ptr %chr63}64