1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
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)
12 define void @fill_with_zeros(ptr %dst) {
13 ; CHECK-LABEL: @fill_with_zeros(
14 ; CHECK-NEXT: store i32 97, ptr [[DST:%.*]], align 1
15 ; CHECK-NEXT: ret void
17 tail call ptr @strncpy(ptr %dst, ptr @str, i64 4)
21 define void @fill_with_zeros2(ptr %dst) {
22 ; CHECK-LABEL: @fill_with_zeros2(
23 ; CHECK-NEXT: store i32 6513249, ptr [[DST:%.*]], align 1
24 ; CHECK-NEXT: ret void
26 tail call ptr @strncpy(ptr %dst, ptr @str2, i64 4)
30 define void @fill_with_zeros3(ptr %dst) {
31 ; CHECK-LABEL: @fill_with_zeros3(
32 ; CHECK-NEXT: store i32 1684234849, ptr [[DST:%.*]], align 1
33 ; CHECK-NEXT: ret void
35 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 4)
39 define void @fill_with_zeros4(ptr %dst) {
40 ; CHECK-LABEL: @fill_with_zeros4(
41 ; 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)
42 ; CHECK-NEXT: ret void
44 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 128)
48 define void @no_simplify(ptr %dst) {
49 ; CHECK-LABEL: @no_simplify(
50 ; CHECK-NEXT: [[TMP1:%.*]] = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) [[DST:%.*]], ptr noundef nonnull dereferenceable(5) @str3, i64 129)
51 ; CHECK-NEXT: ret void
53 tail call ptr @strncpy(ptr %dst, ptr @str3, i64 129)