1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -O3 -S | FileCheck --check-prefix=OLDPM %s 3; RUN: opt < %s -passes='default<O3>' -aa-pipeline=default -S | FileCheck --check-prefix=NEWPM %s 4 5target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" 6target triple = "thumbv6m-none-none-eabi" 7 8; Not only should we be able to to form memsets here, the original loops 9; should be deleted, too. 10 11; Function Attrs: nounwind 12define dso_local void @arm_fill_q7(i8 signext %value, i8* %pDst, i32 %blockSize) #0 { 13; OLDPM-LABEL: @arm_fill_q7( 14; OLDPM-NEXT: entry: 15; OLDPM-NEXT: [[CMP_NOT20:%.*]] = icmp ult i32 [[BLOCKSIZE:%.*]], 4 16; OLDPM-NEXT: br i1 [[CMP_NOT20]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 17; OLDPM: while.body.preheader: 18; OLDPM-NEXT: [[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4 19; OLDPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 [[VALUE:%.*]], i32 [[TMP0]], i1 false) 20; OLDPM-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PDST]], i32 [[TMP0]] 21; OLDPM-NEXT: br label [[WHILE_END]] 22; OLDPM: while.end: 23; OLDPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[SCEVGEP]], [[WHILE_BODY_PREHEADER]] ] 24; OLDPM-NEXT: [[REM:%.*]] = and i32 [[BLOCKSIZE]], 3 25; OLDPM-NEXT: [[CMP14_NOT17:%.*]] = icmp eq i32 [[REM]], 0 26; OLDPM-NEXT: br i1 [[CMP14_NOT17]], label [[WHILE_END18:%.*]], label [[WHILE_BODY16_PREHEADER:%.*]] 27; OLDPM: while.body16.preheader: 28; OLDPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST_ADDR_0_LCSSA]], i8 [[VALUE]], i32 [[REM]], i1 false) 29; OLDPM-NEXT: br label [[WHILE_END18]] 30; OLDPM: while.end18: 31; OLDPM-NEXT: ret void 32; 33; NEWPM-LABEL: @arm_fill_q7( 34; NEWPM-NEXT: entry: 35; NEWPM-NEXT: [[CMP_NOT17:%.*]] = icmp ult i32 [[BLOCKSIZE:%.*]], 4 36; NEWPM-NEXT: br i1 [[CMP_NOT17]], label [[WHILE_END:%.*]], label [[WHILE_BODY_PREHEADER:%.*]] 37; NEWPM: while.body.preheader: 38; NEWPM-NEXT: [[TMP0:%.*]] = and i32 [[BLOCKSIZE]], -4 39; NEWPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST:%.*]], i8 [[VALUE:%.*]], i32 [[TMP0]], i1 false) 40; NEWPM-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, i8* [[PDST]], i32 [[TMP0]] 41; NEWPM-NEXT: br label [[WHILE_END]] 42; NEWPM: while.end: 43; NEWPM-NEXT: [[PDST_ADDR_0_LCSSA:%.*]] = phi i8* [ [[PDST]], [[ENTRY:%.*]] ], [ [[SCEVGEP]], [[WHILE_BODY_PREHEADER]] ] 44; NEWPM-NEXT: [[REM:%.*]] = and i32 [[BLOCKSIZE]], 3 45; NEWPM-NEXT: [[CMP14_NOT20:%.*]] = icmp eq i32 [[REM]], 0 46; NEWPM-NEXT: br i1 [[CMP14_NOT20]], label [[WHILE_END18:%.*]], label [[WHILE_BODY16_PREHEADER:%.*]] 47; NEWPM: while.body16.preheader: 48; NEWPM-NEXT: call void @llvm.memset.p0i8.i32(i8* align 1 [[PDST_ADDR_0_LCSSA]], i8 [[VALUE]], i32 [[REM]], i1 false) 49; NEWPM-NEXT: br label [[WHILE_END18]] 50; NEWPM: while.end18: 51; NEWPM-NEXT: ret void 52; 53entry: 54 %value.addr = alloca i8, align 1 55 %pDst.addr = alloca i8*, align 4 56 %blockSize.addr = alloca i32, align 4 57 %blkCnt = alloca i32, align 4 58 %packedValue = alloca i32, align 4 59 store i8 %value, i8* %value.addr, align 1, !tbaa !3 60 store i8* %pDst, i8** %pDst.addr, align 4, !tbaa !6 61 store i32 %blockSize, i32* %blockSize.addr, align 4, !tbaa !8 62 %0 = bitcast i32* %blkCnt to i8* 63 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3 64 %1 = bitcast i32* %packedValue to i8* 65 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #3 66 %2 = load i8, i8* %value.addr, align 1, !tbaa !3 67 %conv = sext i8 %2 to i32 68 %shl = shl i32 %conv, 0 69 %and = and i32 %shl, 255 70 %3 = load i8, i8* %value.addr, align 1, !tbaa !3 71 %conv1 = sext i8 %3 to i32 72 %shl2 = shl i32 %conv1, 8 73 %and3 = and i32 %shl2, 65280 74 %or = or i32 %and, %and3 75 %4 = load i8, i8* %value.addr, align 1, !tbaa !3 76 %conv4 = sext i8 %4 to i32 77 %shl5 = shl i32 %conv4, 16 78 %and6 = and i32 %shl5, 16711680 79 %or7 = or i32 %or, %and6 80 %5 = load i8, i8* %value.addr, align 1, !tbaa !3 81 %conv8 = sext i8 %5 to i32 82 %shl9 = shl i32 %conv8, 24 83 %and10 = and i32 %shl9, -16777216 84 %or11 = or i32 %or7, %and10 85 store i32 %or11, i32* %packedValue, align 4, !tbaa !8 86 %6 = load i32, i32* %blockSize.addr, align 4, !tbaa !8 87 %shr = lshr i32 %6, 2 88 store i32 %shr, i32* %blkCnt, align 4, !tbaa !8 89 br label %while.cond 90 91while.cond: ; preds = %while.body, %entry 92 %7 = load i32, i32* %blkCnt, align 4, !tbaa !8 93 %cmp = icmp ugt i32 %7, 0 94 br i1 %cmp, label %while.body, label %while.end 95 96while.body: ; preds = %while.cond 97 %8 = load i32, i32* %packedValue, align 4, !tbaa !8 98 call void @write_q7x4_ia(i8** %pDst.addr, i32 %8) 99 %9 = load i32, i32* %blkCnt, align 4, !tbaa !8 100 %dec = add i32 %9, -1 101 store i32 %dec, i32* %blkCnt, align 4, !tbaa !8 102 br label %while.cond, !llvm.loop !10 103 104while.end: ; preds = %while.cond 105 %10 = load i32, i32* %blockSize.addr, align 4, !tbaa !8 106 %rem = urem i32 %10, 4 107 store i32 %rem, i32* %blkCnt, align 4, !tbaa !8 108 br label %while.cond13 109 110while.cond13: ; preds = %while.body16, %while.end 111 %11 = load i32, i32* %blkCnt, align 4, !tbaa !8 112 %cmp14 = icmp ugt i32 %11, 0 113 br i1 %cmp14, label %while.body16, label %while.end18 114 115while.body16: ; preds = %while.cond13 116 %12 = load i8, i8* %value.addr, align 1, !tbaa !3 117 %13 = load i8*, i8** %pDst.addr, align 4, !tbaa !6 118 %incdec.ptr = getelementptr inbounds i8, i8* %13, i32 1 119 store i8* %incdec.ptr, i8** %pDst.addr, align 4, !tbaa !6 120 store i8 %12, i8* %13, align 1, !tbaa !3 121 %14 = load i32, i32* %blkCnt, align 4, !tbaa !8 122 %dec17 = add i32 %14, -1 123 store i32 %dec17, i32* %blkCnt, align 4, !tbaa !8 124 br label %while.cond13, !llvm.loop !12 125 126while.end18: ; preds = %while.cond13 127 %15 = bitcast i32* %packedValue to i8* 128 call void @llvm.lifetime.end.p0i8(i64 4, i8* %15) #3 129 %16 = bitcast i32* %blkCnt to i8* 130 call void @llvm.lifetime.end.p0i8(i64 4, i8* %16) #3 131 ret void 132} 133 134; Function Attrs: argmemonly nofree nosync nounwind willreturn 135declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 136 137; Function Attrs: alwaysinline nounwind 138define internal void @write_q7x4_ia(i8** %pQ7, i32 %value) #2 { 139entry: 140 %pQ7.addr = alloca i8**, align 4 141 %value.addr = alloca i32, align 4 142 %val = alloca i32, align 4 143 store i8** %pQ7, i8*** %pQ7.addr, align 4, !tbaa !6 144 store i32 %value, i32* %value.addr, align 4, !tbaa !8 145 %0 = bitcast i32* %val to i8* 146 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3 147 %1 = load i32, i32* %value.addr, align 4, !tbaa !8 148 store i32 %1, i32* %val, align 4, !tbaa !8 149 %2 = load i32, i32* %val, align 4, !tbaa !8 150 %and = and i32 %2, 255 151 %conv = trunc i32 %and to i8 152 %3 = load i8**, i8*** %pQ7.addr, align 4, !tbaa !6 153 %4 = load i8*, i8** %3, align 4, !tbaa !6 154 %arrayidx = getelementptr inbounds i8, i8* %4, i32 0 155 store i8 %conv, i8* %arrayidx, align 1, !tbaa !3 156 %5 = load i32, i32* %val, align 4, !tbaa !8 157 %shr = ashr i32 %5, 8 158 %and1 = and i32 %shr, 255 159 %conv2 = trunc i32 %and1 to i8 160 %6 = load i8**, i8*** %pQ7.addr, align 4, !tbaa !6 161 %7 = load i8*, i8** %6, align 4, !tbaa !6 162 %arrayidx3 = getelementptr inbounds i8, i8* %7, i32 1 163 store i8 %conv2, i8* %arrayidx3, align 1, !tbaa !3 164 %8 = load i32, i32* %val, align 4, !tbaa !8 165 %shr4 = ashr i32 %8, 16 166 %and5 = and i32 %shr4, 255 167 %conv6 = trunc i32 %and5 to i8 168 %9 = load i8**, i8*** %pQ7.addr, align 4, !tbaa !6 169 %10 = load i8*, i8** %9, align 4, !tbaa !6 170 %arrayidx7 = getelementptr inbounds i8, i8* %10, i32 2 171 store i8 %conv6, i8* %arrayidx7, align 1, !tbaa !3 172 %11 = load i32, i32* %val, align 4, !tbaa !8 173 %shr8 = ashr i32 %11, 24 174 %and9 = and i32 %shr8, 255 175 %conv10 = trunc i32 %and9 to i8 176 %12 = load i8**, i8*** %pQ7.addr, align 4, !tbaa !6 177 %13 = load i8*, i8** %12, align 4, !tbaa !6 178 %arrayidx11 = getelementptr inbounds i8, i8* %13, i32 3 179 store i8 %conv10, i8* %arrayidx11, align 1, !tbaa !3 180 %14 = load i8**, i8*** %pQ7.addr, align 4, !tbaa !6 181 %15 = load i8*, i8** %14, align 4, !tbaa !6 182 %add.ptr = getelementptr inbounds i8, i8* %15, i32 4 183 store i8* %add.ptr, i8** %14, align 4, !tbaa !6 184 %16 = bitcast i32* %val to i8* 185 call void @llvm.lifetime.end.p0i8(i64 4, i8* %16) #3 186 ret void 187} 188 189; Function Attrs: argmemonly nofree nosync nounwind willreturn 190declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 191 192attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m0plus" "target-features"="+armv6-m,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" "unsafe-fp-math"="false" "use-soft-float"="false" } 193attributes #1 = { argmemonly nofree nosync nounwind willreturn } 194attributes #2 = { alwaysinline nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m0plus" "target-features"="+armv6-m,+strict-align,+thumb-mode,-aes,-bf16,-cdecp0,-cdecp1,-cdecp2,-cdecp3,-cdecp4,-cdecp5,-cdecp6,-cdecp7,-crc,-crypto,-dotprod,-dsp,-fp16fml,-fullfp16,-hwdiv,-hwdiv-arm,-i8mm,-lob,-mve,-mve.fp,-ras,-sb,-sha2" "unsafe-fp-math"="false" "use-soft-float"="false" } 195attributes #3 = { nounwind } 196 197!llvm.module.flags = !{!0, !1} 198!llvm.ident = !{!2} 199 200!0 = !{i32 1, !"wchar_size", i32 4} 201!1 = !{i32 1, !"min_enum_size", i32 4} 202!2 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git 07f234be1ccbce131704f580aa3f117083a887f7)"} 203!3 = !{!4, !4, i64 0} 204!4 = !{!"omnipotent char", !5, i64 0} 205!5 = !{!"Simple C/C++ TBAA"} 206!6 = !{!7, !7, i64 0} 207!7 = !{!"any pointer", !4, i64 0} 208!8 = !{!9, !9, i64 0} 209!9 = !{!"int", !4, i64 0} 210!10 = distinct !{!10, !11} 211!11 = !{!"llvm.loop.mustprogress"} 212!12 = distinct !{!12, !11} 213