1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
5 @str = constant [2 x i8] c"a\00"
6 @str2 = constant [3 x i8] c"abc"
7 @str3 = constant [4 x i8] c"abcd"
9 declare ptr @strncpy(ptr, ptr, i64)
13 ; CHECK: @str = constant [2 x i8] c"a\00"
14 ; CHECK: @str2 = constant [3 x i8] c"abc"
15 ; CHECK: @str3 = constant [4 x i8] c"abcd"
16 ; CHECK: @str.1 = private unnamed_addr constant [4 x i8] c"a\00\00\00", align 1
17 ; CHECK: @str.2 = private unnamed_addr constant [128 x i8] c"abcd\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 1
19 define void @fill_with_zeros(ptr %dst) {
20 ; CHECK-LABEL: @fill_with_zeros(
21 ; CHECK-NEXT: store i32 97, ptr [[DST:%.*]], align 1
22 ; CHECK-NEXT: ret void
24 tail call ptr @strncpy(ptr %dst, ptr @str, i64 4)
28 define void @fill_with_zeros2(ptr %dst) {
29 ; CHECK-LABEL: @fill_with_zeros2(
30 ; CHECK-NEXT: store i32 6513249, ptr [[DST:%.*]], align 1
31 ; CHECK-NEXT: ret void
33 tail call ptr @strncpy(ptr %dst, ptr @str2, i64 4)
37 define void @fill_with_zeros3(ptr %dst) {
38 ; CHECK-LABEL: @fill_with_zeros3(
39 ; CHECK-NEXT: store i32 1684234849, ptr [[DST:%.*]], align 1
40 ; CHECK-NEXT: ret void
42 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 4)
46 define void @fill_with_zeros4(ptr %dst) {
47 ; CHECK-LABEL: @fill_with_zeros4(
48 ; CHECK-NEXT: tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(128) [[DST:%.*]], ptr noundef nonnull align 1 dereferenceable(128) @str.2, i64 128, i1 false)
49 ; CHECK-NEXT: ret void
51 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 128)
55 define void @no_simplify(ptr %dst) {
56 ; CHECK-LABEL: @no_simplify(
57 ; CHECK-NEXT: [[TMP1:%.*]] = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) [[DST:%.*]], ptr noundef nonnull dereferenceable(5) @str3, i64 129)
58 ; CHECK-NEXT: ret void
60 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 129)
64 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }