Justin Bogner | b81a337 | 2020-01-23 10:24:10 -0800 | [diff] [blame] | 1 | ; RUN: opt -S < %s -loop-unroll -unroll-allow-partial=1 | FileCheck %s |
| 2 | ; |
| 3 | ; Bugpointed test that triggered UB while cleaning up dead |
| 4 | ; instructions after simplifying indvars |
| 5 | |
| 6 | ; We just check that some unrolling happened here - the assert we've |
| 7 | ; added to ValueHandleBase::operator* would fire if the bug was still |
| 8 | ; present. |
| 9 | ; CHECK: atomicrmw volatile add i32* |
| 10 | ; CHECK: atomicrmw volatile add i32* |
| 11 | ; CHECK: atomicrmw volatile add i32* |
| 12 | |
| 13 | @global = external global i32, align 4 |
| 14 | |
| 15 | define void @widget() { |
| 16 | bb: |
| 17 | br label %bb1 |
| 18 | |
| 19 | bb1: |
| 20 | br label %bb2 |
| 21 | |
| 22 | bb2: |
| 23 | %tmp = phi i32 [ 0, %bb1 ], [ %tmp34, %bb33 ] |
| 24 | %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp34, %bb33 ] |
| 25 | %tmp26 = and i32 %tmp, 1073741823 |
| 26 | %tmp27 = getelementptr inbounds i32, i32* @global, i32 %tmp26 |
| 27 | %tmp28 = atomicrmw volatile add i32* %tmp27, i32 1 monotonic |
| 28 | %tmp29 = icmp ugt i32 %tmp28, 23 |
| 29 | %tmp30 = shl i32 %tmp, 6 |
| 30 | %tmp31 = add i32 %tmp30, undef |
| 31 | %tmp32 = add i32 %tmp31, %tmp28 |
| 32 | store i32 undef, i32* undef, align 4 |
| 33 | br label %bb33 |
| 34 | |
| 35 | bb33: |
| 36 | %tmp34 = add nuw nsw i32 %tmp3, 1 |
| 37 | %tmp35 = icmp ult i32 %tmp3, 15 |
| 38 | br i1 %tmp35, label %bb2, label %bb36 |
| 39 | |
| 40 | bb36: |
| 41 | br label %bb1 |
| 42 | } |