brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · 10f8b64 Raw
96 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<delicm>' -polly-print-scops -polly-print-delicm -disable-output < %s 2>&1 | FileCheck %s2;3; llvm.org/PR487834;5; PHI predecessors of statement instances can only be reliably derived in defined behaviour situations. In this case, the inner loop's counter would overflow when its upper bound (%call24) is lower than its lower bound (2). However, due to the nsw flag, this would be undefined behavior and therefore not added to any runtime-check context, but to the defined-behaviour context.6;7; Derived from test case pr41656.ll8;9target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"10 11define dso_local void @main() local_unnamed_addr #0 {12entry:13  %call24 = tail call i32 @av_get_channel_layout_nb_channels() #214  br label %if.end3015 16if.end30:                                         ; preds = %entry17  br i1 undef, label %if.then40, label %do.body.preheader18 19do.body.preheader:                                ; preds = %if.end3020  %idx.ext.i = sext i32 %call24 to i6421  %wide.trip.count.i = zext i32 %call24 to i6422  %0 = load ptr, ptr undef, align 8, !tbaa !123  br label %for.body.us.preheader.i24 25if.then40:                                        ; preds = %if.end3026  unreachable27 28for.body.us.preheader.i:                          ; preds = %do.body.preheader29  br i1 false, label %for.body.us.i.us, label %for.body.us.i30 31for.body.us.i.us:                                 ; preds = %for.body.us.preheader.i32  br label %fill_samples.exit33 34for.body.us.i:                                    ; preds = %for.cond2.for.end_crit_edge.us.i, %for.body.us.preheader.i35  %t.1 = phi double [ undef, %for.cond2.for.end_crit_edge.us.i ], [ 0.000000e+00, %for.body.us.preheader.i ]36  %i.05.us.i = phi i32 [ %inc8.us.i, %for.cond2.for.end_crit_edge.us.i ], [ 0, %for.body.us.preheader.i ]37  %dstp.03.us.i = phi ptr [ %add.ptr.us.i, %for.cond2.for.end_crit_edge.us.i ], [ %0, %for.body.us.preheader.i ]38  %mul.us.i = fmul nsz double %t.1, 0x40A59933FC6A96C139  %1 = call nsz double @llvm.sin.f64(double %mul.us.i) #240  store double %1, ptr %dstp.03.us.i, align 8, !tbaa !541  br label %for.body5.us.for.body5.us_crit_edge.i42 43for.body5.us.for.body5.us_crit_edge.i:            ; preds = %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge, %for.body.us.i44  %indvars.iv.next.i66 = phi i64 [ 2, %for.body.us.i ], [ %indvars.iv.next.i, %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge ]45  %indvars.iv.next.i = add nuw nsw i64 %indvars.iv.next.i66, 146  udiv i64 1, %indvars.iv.next.i47  %exitcond.i = icmp eq i64 %indvars.iv.next.i, %wide.trip.count.i48  br i1 %exitcond.i, label %for.cond2.for.end_crit_edge.us.i, label %for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge49 50for.body5.us.for.body5.us_crit_edge.i.for.body5.us.for.body5.us_crit_edge.i_crit_edge: ; preds = %for.body5.us.for.body5.us_crit_edge.i51  %.pre10.i.pre = load i64, ptr %dstp.03.us.i, align 8, !tbaa !552  br label %for.body5.us.for.body5.us_crit_edge.i53 54for.cond2.for.end_crit_edge.us.i:                 ; preds = %for.body5.us.for.body5.us_crit_edge.i55  %add.ptr.us.i = getelementptr inbounds double, ptr %dstp.03.us.i, i64 %idx.ext.i56  %inc8.us.i = add nuw nsw i32 %i.05.us.i, 157  %exitcond7.i = icmp eq i32 %inc8.us.i, 102458  br i1 %exitcond7.i, label %fill_samples.exit, label %for.body.us.i59 60fill_samples.exit:                                ; preds = %for.cond2.for.end_crit_edge.us.i, %for.body.us.i.us61  ret void62}63 64declare dso_local i32 @av_get_channel_layout_nb_channels() local_unnamed_addr #065 66; Function Attrs: nounwind readnone speculatable67declare double @llvm.sin.f64(double) #168 69attributes #0 = { "use-soft-float"="false" }70attributes #1 = { nounwind readnone speculatable }71attributes #2 = { nounwind }72 73!llvm.ident = !{!0}74 75!0 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 2436237895b70ed44cf256f67eb2f74e147eb559)"}76!1 = !{!2, !2, i64 0}77!2 = !{!"any pointer", !3, i64 0}78!3 = !{!"omnipotent char", !4, i64 0}79!4 = !{!"Simple C/C++ TBAA"}80!5 = !{!6, !6, i64 0}81!6 = !{!"double", !3, i64 0}82 83 84; CHECK:      Invalid Context:85; CHECK-NEXT: [call24] -> { : false }86; CHECK:      Defined Behavior Context:87; CHECK-NEXT: [call24] -> {  : 3 <= call24 <= 2147483647 }88 89; Only write to scalar if call24 >= 3 (i.e. has defined behavior)90; Since it should be never executed otherwise, the condition is not strictly necessary.91; CHECK-LABEL: DeLICM result:92; CHECK:          Stmt_for_body_us_preheader_i93; CHECK-NEXT:            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]94; CHECK-NEXT:                 [call24] -> { Stmt_for_body_us_preheader_i[] -> MemRef_t_1__phi[] };95; CHECK-NEXT:            new: [call24] -> { Stmt_for_body_us_preheader_i[] -> MemRef1[0, 0] : call24 >= 3 };96