Home | History | Annotate | Download | only in LICM
      1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
      2 ; RUN: opt < %s -scoped-noalias -tbaa -licm -S | FileCheck %s
      3 
      4 ; This test case case is generated from the following C code with -fstrict-aliasing,
      5 ; and after passing through -inline -mem2reg -loop-rotate -instcombine
      6 ; void add(double *restrict data, int *restrict addend) {
      7 ;    *data += *addend;
      8 ; }
      9 ;
     10 ; void foo(double *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 load
     17 ; load having different noalias metadata.
     18 
     19 define void @foo(double* %data, i32* %addend) #0 {
     20 ; CHECK:       for.body.lr.ph:
     21 ; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* [[ADDEND:%.*]], align 4, !tbaa !1
     22 ; CHECK-NEXT:    [[CONV:%.*]] = sitofp i32 [[TMP1]] to double
     23 ; CHECK-NEXT:    [[TMP2:%.*]] = load i32, i32* [[ADDEND]], align 4, !tbaa !1, !alias.scope !5, !noalias !8
     24 ; CHECK-NEXT:    [[CONV_I:%.*]] = sitofp i32 [[TMP2]] to double
     25 entry:
     26   %i = alloca i32, align 4
     27   %0 = bitcast i32* %i to i8*
     28   call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #2
     29   store i32 0, i32* %i, align 4, !tbaa !1
     30   br i1 true, label %for.body.lr.ph, label %for.cond.cleanup
     31 
     32 for.body.lr.ph:                                   ; preds = %entry
     33   br label %for.body
     34 
     35 for.cond.for.cond.cleanup_crit_edge:              ; preds = %for.inc
     36   br label %for.cond.cleanup
     37 
     38 for.cond.cleanup:                                 ; preds = %for.cond.for.cond.cleanup_crit_edge, %entry
     39   %1 = bitcast i32* %i to i8*
     40   call void @llvm.lifetime.end.p0i8(i64 4, i8* %1) #2
     41   br label %for.end
     42 
     43 for.body:                                         ; preds = %for.body.lr.ph, %for.inc
     44   %2 = load i32, i32* %addend, align 4, !tbaa !1
     45   %conv = sitofp i32 %2 to double
     46   %3 = load i32, i32* %i, align 4, !tbaa !1
     47   %idxprom = sext i32 %3 to i64
     48   %arrayidx = getelementptr inbounds double, double* %data, i64 %idxprom
     49   %4 = load double, double* %arrayidx, align 8, !tbaa !5
     50   %add = fadd double %4, %conv
     51   store double %add, double* %arrayidx, align 8, !tbaa !5
     52   %idxprom1 = sext i32 %3 to i64
     53   %arrayidx2 = getelementptr inbounds double, double* %data, i64 %idxprom1
     54   %5 = load i32, i32* %addend, align 4, !tbaa !1, !alias.scope !7, !noalias !10
     55   %conv.i = sitofp i32 %5 to double
     56   %6 = load double, double* %arrayidx2, align 8, !tbaa !5, !alias.scope !10, !noalias !7
     57   %add.i = fadd double %6, %conv.i
     58   store double %add.i, double* %arrayidx2, align 8, !tbaa !5, !alias.scope !10, !noalias !7
     59   br label %for.inc
     60 
     61 for.inc:                                          ; preds = %for.body
     62   %7 = load i32, i32* %i, align 4, !tbaa !1
     63   %inc = add nsw i32 %7, 1
     64   store i32 %inc, i32* %i, align 4, !tbaa !1
     65   %cmp = icmp slt i32 %inc, 1000
     66   br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge
     67 
     68 for.end:                                          ; preds = %for.cond.cleanup
     69   ret void
     70 }
     71 
     72 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0
     73 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0
     74 
     75 attributes #0 = { argmemonly nounwind }
     76 
     77 !llvm.ident = !{!0}
     78 
     79 !0 = !{!"clang version 5.0.0  (llvm/trunk 299971)"}
     80 !1 = !{!2, !2, i64 0}
     81 !2 = !{!"int", !3, i64 0}
     82 !3 = !{!"omnipotent char", !4, i64 0}
     83 !4 = !{!"Simple C/C++ TBAA"}
     84 !5 = !{!6, !6, i64 0}
     85 !6 = !{!"double", !3, i64 0}
     86 !7 = !{!8}
     87 !8 = distinct !{!8, !9, !"add: %addend"}
     88 !9 = distinct !{!9, !"add"}
     89 !10 = !{!11}
     90 !11 = distinct !{!11, !9, !"add: %data"}
     91