1 ; RUN: opt -S < %s -passes=loop-unroll -unroll-allow-partial=1 | FileCheck %s
3 ; Bugpointed test that triggered UB while cleaning up dead
4 ; instructions after simplifying indvars
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
9 ; CHECK: atomicrmw volatile add ptr
10 ; CHECK: atomicrmw volatile add ptr
11 ; CHECK: atomicrmw volatile add ptr
13 @global = external global i32, align 4
15 define void @widget() {
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, ptr @global, i32 %tmp26
27 %tmp28 = atomicrmw volatile add ptr %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, ptr undef, align 4
36 %tmp34 = add nuw nsw i32 %tmp3, 1
37 %tmp35 = icmp ult i32 %tmp3, 15
38 br i1 %tmp35, label %bb2, label %bb36