1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4 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" 8 9declare i8* @strncpy(i8*, i8*, i64) 10 11 12define void @fill_with_zeros(i8* %dst) { 13; CHECK-LABEL: @fill_with_zeros( 14; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[DST:%.*]] to i32* 15; CHECK-NEXT: store i32 97, i32* [[TMP1]], align 1 16; CHECK-NEXT: ret void 17; 18 tail call i8* @strncpy(i8* %dst, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i64 4) 19 ret void 20} 21 22define void @fill_with_zeros2(i8* %dst) { 23; CHECK-LABEL: @fill_with_zeros2( 24; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[DST:%.*]] to i32* 25; CHECK-NEXT: store i32 6513249, i32* [[TMP1]], align 1 26; CHECK-NEXT: ret void 27; 28 tail call i8* @strncpy(i8* %dst, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str2, i64 0, i64 0), i64 4) 29 ret void 30} 31 32define void @fill_with_zeros3(i8* %dst) { 33; CHECK-LABEL: @fill_with_zeros3( 34; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[DST:%.*]] to i32* 35; CHECK-NEXT: store i32 1684234849, i32* [[TMP1]], align 1 36; CHECK-NEXT: ret void 37; 38 tail call i8* @strncpy(i8* %dst, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str3, i64 0, i64 0), i64 4) 39 ret void 40} 41 42define void @fill_with_zeros4(i8* %dst) { 43; CHECK-LABEL: @fill_with_zeros4( 44; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(128) [[DST:%.*]], i8* nonnull align 1 dereferenceable(128) getelementptr inbounds ([129 x i8], [129 x i8]* @str.2, i64 0, i64 0), i64 128, i1 false) 45; CHECK-NEXT: ret void 46; 47 tail call i8* @strncpy(i8* %dst, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str3, i64 0, i64 0), i64 128) 48 ret void 49} 50 51define void @no_simplify(i8* %dst) { 52; CHECK-LABEL: @no_simplify( 53; CHECK-NEXT: [[TMP1:%.*]] = tail call i8* @strncpy(i8* nonnull dereferenceable(1) [[DST:%.*]], i8* nonnull dereferenceable(5) getelementptr inbounds ([4 x i8], [4 x i8]* @str3, i64 0, i64 0), i64 129) 54; CHECK-NEXT: ret void 55; 56 tail call i8* @strncpy(i8* %dst, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str3, i64 0, i64 0), i64 129) 57 ret void 58} 59