43 lines · plain
1; RUN: opt -S < %s -passes=loop-unroll -unroll-allow-partial=1 | FileCheck %s2;3; Bugpointed test that triggered UB while cleaning up dead4; instructions after simplifying indvars5 6; We just check that some unrolling happened here - the assert we've7; added to ValueHandleBase::operator* would fire if the bug was still8; present.9; CHECK: atomicrmw volatile add ptr10; CHECK: atomicrmw volatile add ptr11; CHECK: atomicrmw volatile add ptr12 13@global = external global i32, align 414 15define void @widget() {16bb:17 br label %bb118 19bb1:20 br label %bb221 22bb2:23 %tmp = phi i32 [ 0, %bb1 ], [ %tmp34, %bb33 ]24 %tmp3 = phi i32 [ 0, %bb1 ], [ %tmp34, %bb33 ]25 %tmp26 = and i32 %tmp, 107374182326 %tmp27 = getelementptr inbounds i32, ptr @global, i32 %tmp2627 %tmp28 = atomicrmw volatile add ptr %tmp27, i32 1 monotonic28 %tmp29 = icmp ugt i32 %tmp28, 2329 %tmp30 = shl i32 %tmp, 630 %tmp31 = add i32 %tmp30, undef31 %tmp32 = add i32 %tmp31, %tmp2832 store i32 undef, ptr undef, align 433 br label %bb3334 35bb33:36 %tmp34 = add nuw nsw i32 %tmp3, 137 %tmp35 = icmp ult i32 %tmp3, 1538 br i1 %tmp35, label %bb2, label %bb3639 40bb36:41 br label %bb142}43