89 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=licm -S | FileCheck %s3 4; This test case case is generated from the following C code with -fstrict-aliasing,5; and after passing through -passes=inline,mem2reg,loop-rotate,instcombine6; void add(ptr restrict data, int *restrict addend) {7; *data += *addend;8; }9;10; void foo(ptr data, int *addend) {11; for (int i = 0; i < 1000; ++i) {12; *data += *addend;13; add(data, addend);14; }15; }16; We want to make sure the load of addend gets hoisted, independent of the second load17; load having different noalias metadata.18 19define void @foo(ptr %data, ptr %addend) #0 {20; CHECK: for.body.lr.ph:21; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ADDEND:%.*]], align 4, !tbaa !122; CHECK-NEXT: [[CONV:%.*]] = sitofp i32 [[TMP1]] to double23; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ADDEND]], align 4, !tbaa !1, !alias.scope !5, !noalias !824; CHECK-NEXT: [[CONV_I:%.*]] = sitofp i32 [[TMP2]] to double25entry:26 %i = alloca i32, align 427 call void @llvm.lifetime.start.p0(ptr %i) #228 store i32 0, ptr %i, align 4, !tbaa !129 br i1 true, label %for.body.lr.ph, label %for.cond.cleanup30 31for.body.lr.ph: ; preds = %entry32 br label %for.body33 34for.cond.for.cond.cleanup_crit_edge: ; preds = %for.inc35 br label %for.cond.cleanup36 37for.cond.cleanup: ; preds = %for.cond.for.cond.cleanup_crit_edge, %entry38 call void @llvm.lifetime.end.p0(ptr %i) #239 br label %for.end40 41for.body: ; preds = %for.body.lr.ph, %for.inc42 %0 = load i32, ptr %addend, align 4, !tbaa !143 %conv = sitofp i32 %0 to double44 %1 = load i32, ptr %i, align 4, !tbaa !145 %idxprom = sext i32 %1 to i6446 %arrayidx = getelementptr inbounds double, ptr %data, i64 %idxprom47 %2 = load double, ptr %arrayidx, align 8, !tbaa !548 %add = fadd double %2, %conv49 store double %add, ptr %arrayidx, align 8, !tbaa !550 %idxprom1 = sext i32 %1 to i6451 %arrayidx2 = getelementptr inbounds double, ptr %data, i64 %idxprom152 %3 = load i32, ptr %addend, align 4, !tbaa !1, !alias.scope !7, !noalias !1053 %conv.i = sitofp i32 %3 to double54 %4 = load double, ptr %arrayidx2, align 8, !tbaa !5, !alias.scope !10, !noalias !755 %add.i = fadd double %4, %conv.i56 store double %add.i, ptr %arrayidx2, align 8, !tbaa !5, !alias.scope !10, !noalias !757 br label %for.inc58 59for.inc: ; preds = %for.body60 %5 = load i32, ptr %i, align 4, !tbaa !161 %inc = add nsw i32 %5, 162 store i32 %inc, ptr %i, align 4, !tbaa !163 %cmp = icmp slt i32 %inc, 100064 br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge65 66for.end: ; preds = %for.cond.cleanup67 ret void68}69 70declare void @llvm.lifetime.start.p0(ptr nocapture) #071declare void @llvm.lifetime.end.p0(ptr nocapture) #072 73attributes #0 = { argmemonly nounwind }74 75!llvm.ident = !{!0}76 77!0 = !{!"clang version 5.0.0 (llvm/trunk 299971)"}78!1 = !{!2, !2, i64 0}79!2 = !{!"int", !3, i64 0}80!3 = !{!"omnipotent char", !4, i64 0}81!4 = !{!"Simple C/C++ TBAA"}82!5 = !{!6, !6, i64 0}83!6 = !{!"double", !3, i64 0}84!7 = !{!8}85!8 = distinct !{!8, !9, !"add: %addend"}86!9 = distinct !{!9, !"add"}87!10 = !{!11}88!11 = distinct !{!11, !9, !"add: %data"}89