1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -O3 -S | FileCheck %s 3; RUN: opt < %s -passes="default<O3>" -S | FileCheck %s 4 5; LoopFullUnrollPass will not preform non-full unrolling, 6; yet until we unroll at least 2x, 7; the loads/stores into `%i3 = alloca %t0, align 4` 8; happen at non-constant indexes. 9 10target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 11target triple = "x86_64-pc-linux-gnu" 12 13%t0 = type { [2 x i32] } 14 15$_ZNSt5arrayIiLm2EEixEm = comdat any 16 17$_ZNSt14__array_traitsIiLm2EE6_S_refERA2_Kim = comdat any 18 19@global = private unnamed_addr constant %t0 { [2 x i32] [i32 24, i32 42] }, align 4 20 21; Function Attrs: mustprogress nounwind uwtable 22define dso_local void @foo(i32 noundef %arg, ptr noundef nonnull align 4 dereferenceable(8) %arg1) #0 { 23; CHECK-LABEL: @foo( 24; CHECK-NEXT: bb: 25; CHECK-NEXT: [[I9:%.*]] = sdiv i32 [[ARG:%.*]], 128 26; CHECK-NEXT: [[I10:%.*]] = shl nsw i32 [[I9]], 7 27; CHECK-NEXT: [[ARG_OFF:%.*]] = add i32 [[ARG]], 127 28; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[ARG_OFF]], 255 29; CHECK-NEXT: br i1 [[TMP0]], label [[BB12:%.*]], label [[BB13:%.*]] 30; CHECK: bb12.loopexit: 31; CHECK-NEXT: [[I3_SROA_8_0_INSERT_EXT:%.*]] = zext i32 [[I21_3:%.*]] to i64 32; CHECK-NEXT: [[I3_SROA_8_0_INSERT_SHIFT:%.*]] = shl nuw i64 [[I3_SROA_8_0_INSERT_EXT]], 32 33; CHECK-NEXT: [[I3_SROA_0_0_INSERT_EXT:%.*]] = zext i32 [[I21_2:%.*]] to i64 34; CHECK-NEXT: [[I3_SROA_0_0_INSERT_INSERT:%.*]] = or disjoint i64 [[I3_SROA_8_0_INSERT_SHIFT]], [[I3_SROA_0_0_INSERT_EXT]] 35; CHECK-NEXT: br label [[BB12]] 36; CHECK: bb12: 37; CHECK-NEXT: [[TMP1:%.*]] = phi i64 [ [[I3_SROA_0_0_INSERT_INSERT]], [[BB12_LOOPEXIT:%.*]] ], [ 180388626456, [[BB:%.*]] ] 38; CHECK-NEXT: store i64 [[TMP1]], ptr [[ARG1:%.*]], align 4, !tbaa [[TBAA5:![0-9]+]] 39; CHECK-NEXT: ret void 40; CHECK: bb13: 41; CHECK-NEXT: [[I3_SROA_8_0:%.*]] = phi i32 [ [[I21_3]], [[BB13]] ], [ 42, [[BB]] ] 42; CHECK-NEXT: [[I3_SROA_0_0:%.*]] = phi i32 [ [[I21_2]], [[BB13]] ], [ 24, [[BB]] ] 43; CHECK-NEXT: [[I4_05:%.*]] = phi i32 [ [[I24_3:%.*]], [[BB13]] ], [ 0, [[BB]] ] 44; CHECK-NEXT: [[I21:%.*]] = mul nsw i32 [[I3_SROA_0_0]], [[I4_05]] 45; CHECK-NEXT: [[I24:%.*]] = or disjoint i32 [[I4_05]], 1 46; CHECK-NEXT: [[I21_1:%.*]] = mul nsw i32 [[I3_SROA_8_0]], [[I24]] 47; CHECK-NEXT: [[I24_1:%.*]] = or disjoint i32 [[I4_05]], 2 48; CHECK-NEXT: [[I21_2]] = mul nsw i32 [[I21]], [[I24_1]] 49; CHECK-NEXT: [[I24_2:%.*]] = or disjoint i32 [[I4_05]], 3 50; CHECK-NEXT: [[I21_3]] = mul nsw i32 [[I21_1]], [[I24_2]] 51; CHECK-NEXT: [[I24_3]] = add nuw nsw i32 [[I4_05]], 4 52; CHECK-NEXT: [[I11_NOT_3:%.*]] = icmp eq i32 [[I24_3]], [[I10]] 53; CHECK-NEXT: br i1 [[I11_NOT_3]], label [[BB12_LOOPEXIT]], label [[BB13]], !llvm.loop [[LOOP8:![0-9]+]] 54; 55bb: 56 %i = alloca i32, align 4 57 %i2 = alloca ptr, align 8 58 %i3 = alloca %t0, align 4 59 %i4 = alloca i32, align 4 60 %i5 = alloca ptr, align 8 61 store i32 %arg, ptr %i, align 4, !tbaa !5 62 store ptr %arg1, ptr %i2, align 8, !tbaa !9 63 call void @llvm.lifetime.start.p0(i64 8, ptr %i3) #3 64 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %i3, ptr align 4 @global, i64 8, i1 false) 65 call void @llvm.lifetime.start.p0(i64 4, ptr %i4) #3 66 store i32 0, ptr %i4, align 4, !tbaa !5 67 br label %bb6 68 69bb6: ; preds = %bb22, %bb 70 %i7 = load i32, ptr %i4, align 4, !tbaa !5 71 %i8 = load i32, ptr %i, align 4, !tbaa !5 72 %i9 = sdiv i32 %i8, 128 73 %i10 = mul nsw i32 128, %i9 74 %i11 = icmp ne i32 %i7, %i10 75 br i1 %i11, label %bb13, label %bb12 76 77bb12: ; preds = %bb6 78 call void @llvm.lifetime.end.p0(i64 4, ptr %i4) #3 79 br label %bb25 80 81bb13: ; preds = %bb6 82 call void @llvm.lifetime.start.p0(i64 8, ptr %i5) #3 83 %i14 = load i32, ptr %i4, align 4, !tbaa !5 84 %i15 = srem i32 %i14, 2 85 %i16 = sext i32 %i15 to i64 86 %i17 = call noundef nonnull align 4 dereferenceable(4) ptr @wibble(ptr noundef nonnull align 4 dereferenceable(8) %i3, i64 noundef %i16) #3 87 store ptr %i17, ptr %i5, align 8, !tbaa !9 88 %i18 = load i32, ptr %i4, align 4, !tbaa !5 89 %i19 = load ptr, ptr %i5, align 8, !tbaa !9 90 %i20 = load i32, ptr %i19, align 4, !tbaa !5 91 %i21 = mul nsw i32 %i20, %i18 92 store i32 %i21, ptr %i19, align 4, !tbaa !5 93 call void @llvm.lifetime.end.p0(i64 8, ptr %i5) #3 94 br label %bb22 95 96bb22: ; preds = %bb13 97 %i23 = load i32, ptr %i4, align 4, !tbaa !5 98 %i24 = add nsw i32 %i23, 1 99 store i32 %i24, ptr %i4, align 4, !tbaa !5 100 br label %bb6, !llvm.loop !11 101 102bb25: ; preds = %bb12 103 %i26 = load ptr, ptr %i2, align 8, !tbaa !9 104 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %i26, ptr align 4 %i3, i64 8, i1 false), !tbaa.struct !13 105 call void @llvm.lifetime.end.p0(i64 8, ptr %i3) #3 106 ret void 107} 108 109; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn 110declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1 111 112; Function Attrs: argmemonly nocallback nofree nounwind willreturn 113declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2 114 115; Function Attrs: mustprogress nounwind uwtable 116define linkonce_odr dso_local noundef nonnull align 4 dereferenceable(4) ptr @wibble(ptr noundef nonnull align 4 dereferenceable(8) %arg, i64 noundef %arg1) #0 comdat($_ZNSt5arrayIiLm2EEixEm) align 2 { 117bb: 118 %i = alloca ptr, align 8 119 %i2 = alloca i64, align 8 120 store ptr %arg, ptr %i, align 8, !tbaa !9 121 store i64 %arg1, ptr %i2, align 8, !tbaa !15 122 %i3 = load ptr, ptr %i, align 8 123 %i5 = load i64, ptr %i2, align 8, !tbaa !15 124 %i6 = call noundef nonnull align 4 dereferenceable(4) ptr @widget(ptr noundef nonnull align 4 dereferenceable(8) %i3, i64 noundef %i5) #3 125 ret ptr %i6 126} 127 128; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn 129declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1 130 131; Function Attrs: mustprogress nounwind uwtable 132define linkonce_odr dso_local noundef nonnull align 4 dereferenceable(4) ptr @widget(ptr noundef nonnull align 4 dereferenceable(8) %arg, i64 noundef %arg1) #0 comdat($_ZNSt14__array_traitsIiLm2EE6_S_refERA2_Kim) align 2 { 133bb: 134 %i = alloca ptr, align 8 135 %i2 = alloca i64, align 8 136 store ptr %arg, ptr %i, align 8, !tbaa !9 137 store i64 %arg1, ptr %i2, align 8, !tbaa !15 138 %i3 = load ptr, ptr %i, align 8, !tbaa !9 139 %i4 = load i64, ptr %i2, align 8, !tbaa !15 140 %i5 = getelementptr inbounds [2 x i32], ptr %i3, i64 0, i64 %i4 141 ret ptr %i5 142} 143 144attributes #0 = { mustprogress nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } 145attributes #1 = { argmemonly nocallback nofree nosync nounwind willreturn } 146attributes #2 = { argmemonly nocallback nofree nounwind willreturn } 147attributes #3 = { nounwind } 148 149!llvm.module.flags = !{!0, !1, !2, !3} 150!llvm.ident = !{!4} 151 152!0 = !{i32 1, !"wchar_size", i32 4} 153!1 = !{i32 8, !"PIC Level", i32 2} 154!2 = !{i32 7, !"PIE Level", i32 2} 155!3 = !{i32 7, !"uwtable", i32 2} 156!4 = !{!"Debian clang version 16.0.0-++20221024100939+996267d20ea0-1~exp1~20221024221046.844"} 157!5 = !{!6, !6, i64 0} 158!6 = !{!"int", !7, i64 0} 159!7 = !{!"omnipotent char", !8, i64 0} 160!8 = !{!"Simple C++ TBAA"} 161!9 = !{!10, !10, i64 0} 162!10 = !{!"any pointer", !7, i64 0} 163!11 = distinct !{!11, !12} 164!12 = !{!"llvm.loop.mustprogress"} 165!13 = !{i64 0, i64 8, !14} 166!14 = !{!7, !7, i64 0} 167!15 = !{!16, !16, i64 0} 168!16 = !{!"long", !7, i64 0} 169