brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · f84f35d Raw
110 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 52; RUN: opt -passes='print<scalar-evolution>' -scalar-evolution-classify-expressions=0 -disable-output %s 2>&1 | FileCheck %s3 4; The UDiv in the latch may never be executed. The backedge-taken-count5; expressions must account for the fact that evaluating the UDiv6; unconditionally may trigger UB.7define i64 @multi_exit_exit_count_with_udiv_by_value_in_latch(ptr %dst, i64 %N) {8; CHECK-LABEL: 'multi_exit_exit_count_with_udiv_by_value_in_latch'9; CHECK-NEXT:  Determining loop execution counts for: @multi_exit_exit_count_with_udiv_by_value_in_latch10; CHECK-NEXT:  Loop %loop.header: <multiple exits> backedge-taken count is ((0 smax %N) umin_seq (42 /u %N))11; CHECK-NEXT:    exit count for loop.header: (0 smax %N)12; CHECK-NEXT:    exit count for loop.latch: (42 /u %N)13; CHECK-NEXT:  Loop %loop.header: constant max backedge-taken count is i64 4214; CHECK-NEXT:  Loop %loop.header: symbolic max backedge-taken count is ((0 smax %N) umin_seq (42 /u %N))15; CHECK-NEXT:    symbolic max exit count for loop.header: (0 smax %N)16; CHECK-NEXT:    symbolic max exit count for loop.latch: (42 /u %N)17; CHECK-NEXT:  Loop %loop.header: Trip multiple is 118;19entry:20  br label %loop.header21 22loop.header:23  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]24  %gep = getelementptr inbounds i32, ptr %dst, i64 %iv25  store i32 1, ptr %gep26  %c.0 = icmp slt i64 %iv, %N27  br i1 %c.0, label %loop.latch, label %exit28 29loop.latch:30  %iv.next = add i64 %iv, 131  %d = udiv i64 42, %N32  %c.1 = icmp slt i64 %iv, %d33  br i1 %c.1, label %loop.header, label %exit34 35exit:36  %p = phi i64 [ 1, %loop.header ], [ 0, %loop.latch]37  ret i64 %p38}39 40; The UDiv in the latch may never be executed. The backedge-taken-count41; expressions must account for the fact that evaluating the UDiv42; unconditionally may trigger UB.43define i64 @multi_exit_exit_count_with_udiv_by_value_in_latch_different_bounds(ptr %dst, i64 %N, i64 %M) {44; CHECK-LABEL: 'multi_exit_exit_count_with_udiv_by_value_in_latch_different_bounds'45; CHECK-NEXT:  Determining loop execution counts for: @multi_exit_exit_count_with_udiv_by_value_in_latch_different_bounds46; CHECK-NEXT:  Loop %loop.header: <multiple exits> backedge-taken count is ((0 smax %N) umin_seq (42 /u %M))47; CHECK-NEXT:    exit count for loop.header: (0 smax %N)48; CHECK-NEXT:    exit count for loop.latch: (42 /u %M)49; CHECK-NEXT:  Loop %loop.header: constant max backedge-taken count is i64 4250; CHECK-NEXT:  Loop %loop.header: symbolic max backedge-taken count is ((0 smax %N) umin_seq (42 /u %M))51; CHECK-NEXT:    symbolic max exit count for loop.header: (0 smax %N)52; CHECK-NEXT:    symbolic max exit count for loop.latch: (42 /u %M)53; CHECK-NEXT:  Loop %loop.header: Trip multiple is 154;55entry:56  br label %loop.header57 58loop.header:59  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]60  %gep = getelementptr inbounds i32, ptr %dst, i64 %iv61  store i32 1, ptr %gep62  %c.0 = icmp slt i64 %iv, %N63  br i1 %c.0, label %loop.latch, label %exit64 65loop.latch:66  %iv.next = add i64 %iv, 167  %d = udiv i64 42, %M68  %c.1 = icmp slt i64 %iv, %d69  br i1 %c.1, label %loop.header, label %exit70 71exit:72  %p = phi i64 [ 1, %loop.header ], [ 0, %loop.latch]73  ret i64 %p74}75 76; The UDiv in the latch cannot trigger UB, evaluating it unconditionally in the77; trip count expression is fine.78define i64 @multi_exit_exit_count_with_udiv_by_constant_in_latch(ptr %dst, i64 %N) {79; CHECK-LABEL: 'multi_exit_exit_count_with_udiv_by_constant_in_latch'80; CHECK-NEXT:  Determining loop execution counts for: @multi_exit_exit_count_with_udiv_by_constant_in_latch81; CHECK-NEXT:  Loop %loop.header: <multiple exits> backedge-taken count is ((%N /u 42) umin (0 smax %N))82; CHECK-NEXT:    exit count for loop.header: (0 smax %N)83; CHECK-NEXT:    exit count for loop.latch: (%N /u 42)84; CHECK-NEXT:  Loop %loop.header: constant max backedge-taken count is i64 43920819223117980085; CHECK-NEXT:  Loop %loop.header: symbolic max backedge-taken count is ((%N /u 42) umin (0 smax %N))86; CHECK-NEXT:    symbolic max exit count for loop.header: (0 smax %N)87; CHECK-NEXT:    symbolic max exit count for loop.latch: (%N /u 42)88; CHECK-NEXT:  Loop %loop.header: Trip multiple is 189;90entry:91  br label %loop.header92 93loop.header:94  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]95  %gep = getelementptr inbounds i32, ptr %dst, i64 %iv96  store i32 1, ptr %gep97  %c.0 = icmp slt i64 %iv, %N98  br i1 %c.0, label %loop.latch, label %exit99 100loop.latch:101  %iv.next = add i64 %iv, 1102  %d = udiv i64 %N, 42103  %c.1 = icmp slt i64 %iv, %d104  br i1 %c.1, label %loop.header, label %exit105 106exit:107  %p = phi i64 [ 1, %loop.header ], [ 0, %loop.latch]108  ret i64 %p109}110