189 lines · plain
1; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic -frame-pointer=all | FileCheck %s -check-prefix=X86-322; RUN: llc < %s -mtriple=x86_64-apple-darwin -relocation-model=pic -frame-pointer=all | FileCheck %s -check-prefix=X86-643 4; MachineLICM should be able to hoist loop invariant reload out of the loop.5; Only linear scan needs this, -regalloc=greedy sinks the spill instead.6; rdar://72330997 8%struct.FILE = type { ptr, i32, i32, i16, i16, %struct.__sbuf, i32, ptr, ptr, ptr, ptr, ptr, %struct.__sbuf, ptr, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }9%struct.__sFILEX = type opaque10%struct.__sbuf = type { ptr, i32 }11%struct.epoch_t = type { ptr, ptr, i32, i32, i32, i32, i32 }12%struct.trans_t = type { i32, i32, i32, ptr }13 14@.str12 = external constant [2 x i8], align 1 ; <ptr> [#uses=1]15@.str19 = external constant [7 x i8], align 1 ; <ptr> [#uses=1]16@.str24 = external constant [4 x i8], align 1 ; <ptr> [#uses=1]17 18define i32 @t1(i32 %c, ptr nocapture %v) nounwind ssp {19; X86-32-LABEL: t1:20entry:21 br i1 undef, label %bb, label %bb322 23bb: ; preds = %entry24 unreachable25 26bb3: ; preds = %entry27 br i1 undef, label %bb.i, label %bb.nph4128 29bb.i: ; preds = %bb330 unreachable31 32bb.nph41: ; preds = %bb333 %0 = call ptr @"\01_fopen$UNIX2003"(ptr undef, ptr @.str12) nounwind ; <ptr> [#uses=3]34 br i1 undef, label %bb4, label %bb5.preheader35 36bb5.preheader: ; preds = %bb.nph4137 br label %bb538 39bb4: ; preds = %bb.nph4140 unreachable41 42bb5: ; preds = %bb5, %bb5.preheader43 br i1 undef, label %bb7, label %bb544 45bb7: ; preds = %bb546 br i1 undef, label %bb9, label %bb1247 48bb9: ; preds = %bb749 unreachable50 51bb12: ; preds = %bb752 br i1 undef, label %bb16, label %bb2253 54bb16: ; preds = %bb1255 unreachable56 57bb22: ; preds = %bb1258 br label %bb.i159 60bb.i1: ; preds = %bb.i1, %bb2261 %1 = icmp eq i8 undef, 69 ; <i1> [#uses=1]62 br i1 %1, label %imix_test.exit, label %bb.i163 64imix_test.exit: ; preds = %bb.i165 br i1 undef, label %bb23, label %bb26.preheader66 67bb26.preheader: ; preds = %imix_test.exit68 br i1 undef, label %bb28, label %bb3069 70bb23: ; preds = %imix_test.exit71 unreachable72; Verify that there are no loads inside the loop.73; X86-32: .p2align 474; X86-32: %bb2875; X86-32-NOT: (%esp),76; X86-32-NOT: (%ebp),77; X86-32: jmp78 79bb28: ; preds = %bb28, %bb26.preheader80 %counter.035 = phi i32 [ %3, %bb28 ], [ 0, %bb26.preheader ] ; <i32> [#uses=2]81 %tmp56 = shl i32 %counter.035, 2 ; <i32> [#uses=0]82 %2 = call ptr @fgets(ptr undef, i32 50, ptr %0) nounwind ; <ptr> [#uses=0]83 %3 = add nsw i32 %counter.035, 1 ; <i32> [#uses=1]84 %4 = call i32 @feof(ptr %0) nounwind ; <i32> [#uses=0]85 br label %bb2886 87bb30: ; preds = %bb26.preheader88 %5 = call i32 @strcmp(ptr undef, ptr @.str19) nounwind readonly ; <i32> [#uses=0]89 br i1 undef, label %bb34, label %bb7090 91bb32.loopexit: ; preds = %bb4592 %6 = icmp eq i32 undef, 0 ; <i1> [#uses=1]93 %indvar.next55 = add i32 %indvar54, 1 ; <i32> [#uses=1]94 br i1 %6, label %bb34, label %bb7095 96bb34: ; preds = %bb32.loopexit, %bb3097 %indvar54 = phi i32 [ %indvar.next55, %bb32.loopexit ], [ 0, %bb30 ] ; <i32> [#uses=3]98 br i1 false, label %bb35, label %bb39.preheader99 100bb35: ; preds = %bb34101 unreachable102 103bb39.preheader: ; preds = %bb34104 %7 = getelementptr inbounds %struct.epoch_t, ptr undef, i32 %indvar54, i32 3 ; <ptr> [#uses=1]105 %8 = getelementptr inbounds %struct.epoch_t, ptr undef, i32 %indvar54, i32 2 ; <ptr> [#uses=0]106 br i1 false, label %bb42, label %bb45107 108bb42: ; preds = %bb39.preheader109 unreachable110 111bb45: ; preds = %bb39.preheader112 %9 = call i32 @strcmp(ptr undef, ptr @.str24) nounwind readonly ; <i32> [#uses=0]113 br i1 false, label %bb47, label %bb32.loopexit114 115bb47: ; preds = %bb45116 %10 = load i32, ptr %7, align 4 ; <i32> [#uses=0]117 unreachable118 119bb70: ; preds = %bb32.loopexit, %bb30120 br i1 undef, label %bb78, label %bb76121 122bb76: ; preds = %bb70123 unreachable124 125bb78: ; preds = %bb70126 br i1 undef, label %bb83, label %bb79127 128bb79: ; preds = %bb78129 unreachable130 131bb83: ; preds = %bb78132 call void @rewind(ptr %0) nounwind133 unreachable134}135 136declare ptr @"\01_fopen$UNIX2003"(ptr, ptr)137 138declare ptr @fgets(ptr, i32, ptr nocapture) nounwind139 140declare void @rewind(ptr nocapture) nounwind141 142declare i32 @feof(ptr nocapture) nounwind143 144declare i32 @strcmp(ptr nocapture, ptr nocapture) nounwind readonly145 146@map_4_to_16 = external constant [16 x i16], align 32 ; <ptr> [#uses=2]147 148define void @t2(ptr nocapture %bufp, ptr nocapture %data, i32 %dsize) nounwind ssp {149; X86-64-LABEL: t2:150entry:151 br i1 undef, label %return, label %bb.nph152 153bb.nph: ; preds = %entry154; X86-64: movq _map_4_to_16@GOTPCREL(%rip)155; X86-64: .p2align 4156 %tmp5 = zext i32 undef to i64 ; <i64> [#uses=1]157 %tmp6 = add i64 %tmp5, 1 ; <i64> [#uses=1]158 %tmp11 = shl i64 undef, 1 ; <i64> [#uses=1]159 %tmp14 = mul i64 undef, 3 ; <i64> [#uses=1]160 br label %bb161 162bb: ; preds = %bb, %bb.nph163 %tmp9 = mul i64 undef, undef ; <i64> [#uses=2]164 %tmp12 = add i64 %tmp11, %tmp9 ; <i64> [#uses=1]165 %scevgep13 = getelementptr i8, ptr %bufp, i64 %tmp12 ; <ptr> [#uses=1]166 %tmp15 = add i64 %tmp14, %tmp9 ; <i64> [#uses=1]167 %scevgep16 = getelementptr i8, ptr %bufp, i64 %tmp15 ; <ptr> [#uses=1]168 %0 = load i8, ptr undef, align 1 ; <i8> [#uses=1]169 %1 = zext i8 %0 to i32 ; <i32> [#uses=1]170 %2 = getelementptr inbounds [16 x i16], ptr @map_4_to_16, i64 0, i64 0 ; <ptr> [#uses=1]171 %3 = load i16, ptr %2, align 2 ; <i16> [#uses=1]172 %4 = trunc i16 %3 to i8 ; <i8> [#uses=1]173 store i8 %4, ptr undef, align 1174 %5 = and i32 %1, 15 ; <i32> [#uses=1]175 %6 = zext i32 %5 to i64 ; <i64> [#uses=1]176 %7 = getelementptr inbounds [16 x i16], ptr @map_4_to_16, i64 0, i64 %6 ; <ptr> [#uses=1]177 %8 = load i16, ptr %7, align 2 ; <i16> [#uses=2]178 %9 = lshr i16 %8, 8 ; <i16> [#uses=1]179 %10 = trunc i16 %9 to i8 ; <i8> [#uses=1]180 store i8 %10, ptr %scevgep13, align 1181 %11 = trunc i16 %8 to i8 ; <i8> [#uses=1]182 store i8 %11, ptr %scevgep16, align 1183 %exitcond = icmp eq i64 undef, %tmp6 ; <i1> [#uses=1]184 br i1 %exitcond, label %return, label %bb185 186return: ; preds = %bb, %entry187 ret void188}189