120 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 62; RUN: opt -passes="default<O1>" -S < %s | FileCheck --check-prefixes=O1 %s3; RUN: opt -passes="default<O2>" -S < %s | FileCheck --check-prefixes=O23 %s4; RUN: opt -passes="default<O3>" -S < %s | FileCheck --check-prefixes=O23 %s5 6target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"7target triple = "x86_64-unknown-linux-gnu"8 9; We should retain the TBAA on the load here, not lose it.10 11define void @licm(ptr align 8 dereferenceable(8) %_M_start.i, i64 %numElem) {12; O1-LABEL: define void @licm(13; O1-SAME: ptr readonly align 8 captures(none) dereferenceable(8) [[_M_START_I:%.*]], i64 [[NUMELEM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {14; O1-NEXT: [[ENTRY:.*:]]15; O1-NEXT: [[CMP1_NOT:%.*]] = icmp eq i64 [[NUMELEM]], 016; O1-NEXT: br i1 [[CMP1_NOT]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_BODY_LR_PH:.*]]17; O1: [[FOR_BODY_LR_PH]]:18; O1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[_M_START_I]], align 8, !tbaa [[ANYPTR_TBAA3:![0-9]+]]19; O1-NEXT: br label %[[FOR_BODY:.*]]20; O1: [[FOR_BODY]]:21; O1-NEXT: [[K_02:%.*]] = phi i64 [ 0, %[[FOR_BODY_LR_PH]] ], [ [[INC:%.*]], %[[FOR_BODY]] ]22; O1-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds double, ptr [[TMP0]], i64 [[K_02]]23; O1-NEXT: store double 2.000000e+00, ptr [[ADD_PTR_I]], align 8, !tbaa [[DOUBLE_TBAA8:![0-9]+]]24; O1-NEXT: [[INC]] = add nuw i64 [[K_02]], 125; O1-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], [[NUMELEM]]26; O1-NEXT: br i1 [[EXITCOND_NOT]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY]]27; O1: [[FOR_COND_CLEANUP]]:28; O1-NEXT: ret void29;30; O23-LABEL: define void @licm(31; O23-SAME: ptr readonly align 8 captures(none) dereferenceable(8) [[_M_START_I:%.*]], i64 [[NUMELEM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {32; O23-NEXT: [[ENTRY:.*:]]33; O23-NEXT: [[CMP1_NOT:%.*]] = icmp eq i64 [[NUMELEM]], 034; O23-NEXT: br i1 [[CMP1_NOT]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_BODY_LR_PH:.*]]35; O23: [[FOR_BODY_LR_PH]]:36; O23-NEXT: [[TMP0:%.*]] = load ptr, ptr [[_M_START_I]], align 8, !tbaa [[ANYPTR_TBAA3:![0-9]+]]37; O23-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[NUMELEM]], 438; O23-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[FOR_BODY_PREHEADER:.*]], label %[[VECTOR_PH:.*]]39; O23: [[VECTOR_PH]]:40; O23-NEXT: [[N_VEC:%.*]] = and i64 [[NUMELEM]], -441; O23-NEXT: br label %[[VECTOR_BODY:.*]]42; O23: [[VECTOR_BODY]]:43; O23-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]44; O23-NEXT: [[TMP1:%.*]] = getelementptr inbounds double, ptr [[TMP0]], i64 [[INDEX]]45; O23-NEXT: [[TMP2:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP1]], i64 1646; O23-NEXT: store <2 x double> splat (double 2.000000e+00), ptr [[TMP1]], align 8, !tbaa [[DOUBLE_TBAA8:![0-9]+]]47; O23-NEXT: store <2 x double> splat (double 2.000000e+00), ptr [[TMP2]], align 8, !tbaa [[DOUBLE_TBAA8]]48; O23-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 449; O23-NEXT: [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]50; O23-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]]51; O23: [[MIDDLE_BLOCK]]:52; O23-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[NUMELEM]], [[N_VEC]]53; O23-NEXT: br i1 [[CMP_N]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY_PREHEADER]]54; O23: [[FOR_BODY_PREHEADER]]:55; O23-NEXT: [[K_02_PH:%.*]] = phi i64 [ 0, %[[FOR_BODY_LR_PH]] ], [ [[N_VEC]], %[[MIDDLE_BLOCK]] ]56; O23-NEXT: br label %[[FOR_BODY:.*]]57; O23: [[FOR_BODY]]:58; O23-NEXT: [[K_02:%.*]] = phi i64 [ [[INC:%.*]], %[[FOR_BODY]] ], [ [[K_02_PH]], %[[FOR_BODY_PREHEADER]] ]59; O23-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds double, ptr [[TMP0]], i64 [[K_02]]60; O23-NEXT: store double 2.000000e+00, ptr [[ADD_PTR_I]], align 8, !tbaa [[DOUBLE_TBAA8]]61; O23-NEXT: [[INC]] = add nuw i64 [[K_02]], 162; O23-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INC]], [[NUMELEM]]63; O23-NEXT: br i1 [[EXITCOND_NOT]], label %[[FOR_COND_CLEANUP]], label %[[FOR_BODY]], !llvm.loop [[LOOP13:![0-9]+]]64; O23: [[FOR_COND_CLEANUP]]:65; O23-NEXT: ret void66;67entry:68 br label %for.cond69 70for.cond: ; preds = %for.body, %entry71 %k.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]72 %cmp = icmp ult i64 %k.0, %numElem73 br i1 %cmp, label %for.body, label %for.cond.cleanup74 75for.body: ; preds = %for.cond76 %0 = load ptr, ptr %_M_start.i, align 8, !tbaa !377 %add.ptr.i = getelementptr inbounds double, ptr %0, i64 %k.078 store double 2.000000e+00, ptr %add.ptr.i, align 8, !tbaa !879 %inc = add nuw i64 %k.0, 180 br label %for.cond81 82for.cond.cleanup: ; preds = %for.cond83 ret void84}85 86!llvm.module.flags = !{!0, !1}87!llvm.ident = !{!2}88 89!0 = !{i32 1, !"wchar_size", i32 4}90!1 = !{i32 7, !"uwtable", i32 1}91!2 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git fc510998f7c287df2bc1304673e0cd8452d50b31)"}92!3 = !{!4, !5, i64 0}93!4 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !5, i64 0, !5, i64 8, !5, i64 16}94!5 = !{!"any pointer", !6, i64 0}95!6 = !{!"omnipotent char", !7, i64 0}96!7 = !{!"Simple C++ TBAA"}97!8 = !{!9, !9, i64 0}98!9 = !{!"double", !6, i64 0}99;.100; O1: [[ANYPTR_TBAA3]] = !{[[META4:![0-9]+]], [[META5:![0-9]+]], i64 0}101; O1: [[META4]] = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", [[META5]], i64 0, [[META5]], i64 8, [[META5]], i64 16}102; O1: [[META5]] = !{!"any pointer", [[META6:![0-9]+]], i64 0}103; O1: [[META6]] = !{!"omnipotent char", [[META7:![0-9]+]], i64 0}104; O1: [[META7]] = !{!"Simple C++ TBAA"}105; O1: [[DOUBLE_TBAA8]] = !{[[META9:![0-9]+]], [[META9]], i64 0}106; O1: [[META9]] = !{!"double", [[META6]], i64 0}107;.108; O23: [[ANYPTR_TBAA3]] = !{[[META4:![0-9]+]], [[META5:![0-9]+]], i64 0}109; O23: [[META4]] = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", [[META5]], i64 0, [[META5]], i64 8, [[META5]], i64 16}110; O23: [[META5]] = !{!"any pointer", [[META6:![0-9]+]], i64 0}111; O23: [[META6]] = !{!"omnipotent char", [[META7:![0-9]+]], i64 0}112; O23: [[META7]] = !{!"Simple C++ TBAA"}113; O23: [[DOUBLE_TBAA8]] = !{[[META9:![0-9]+]], [[META9]], i64 0}114; O23: [[META9]] = !{!"double", [[META6]], i64 0}115; O23: [[LOOP10]] = distinct !{[[LOOP10]], [[META11:![0-9]+]], [[META12:![0-9]+]]}116; O23: [[META11]] = !{!"llvm.loop.isvectorized", i32 1}117; O23: [[META12]] = !{!"llvm.loop.unroll.runtime.disable"}118; O23: [[LOOP13]] = distinct !{[[LOOP13]], [[META12]], [[META11]]}119;.120