@@ -537,8 +537,39 @@ exit:
537537 ret void
538538}
539539
540- define void @ptr_iv_no_inbounds (ptr %base , i64 %end ) {
541- ; CHECK-LABEL: define void @ptr_iv_no_inbounds(
540+ define void @ptr_iv_nuw (ptr %base , i64 %end ) {
541+ ; CHECK-LABEL: define void @ptr_iv_nuw(
542+ ; CHECK-SAME: ptr [[BASE:%.*]], i64 [[END:%.*]]) {
543+ ; CHECK-NEXT: entry:
544+ ; CHECK-NEXT: br label [[LOOP:%.*]]
545+ ; CHECK: loop:
546+ ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
547+ ; CHECK-NEXT: [[IV_PTR:%.*]] = getelementptr nuw i8, ptr [[BASE]], i64 [[IV]]
548+ ; CHECK-NEXT: call void @use.p0(ptr [[IV_PTR]])
549+ ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 4
550+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[IV_NEXT]], [[END]]
551+ ; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[LOOP]]
552+ ; CHECK: exit:
553+ ; CHECK-NEXT: ret void
554+ ;
555+ entry:
556+ br label %loop
557+
558+ loop:
559+ %iv.ptr = phi ptr [ %iv.ptr.next , %loop ], [ %base , %entry ]
560+ %iv = phi i64 [ %iv.next , %loop ], [ 0 , %entry ]
561+ call void @use.p0 (ptr %iv.ptr )
562+ %iv.next = add nuw nsw i64 %iv , 4
563+ %iv.ptr.next = getelementptr nuw i8 , ptr %base , i64 %iv.next
564+ %cmp = icmp eq i64 %iv.next , %end
565+ br i1 %cmp , label %exit , label %loop
566+
567+ exit:
568+ ret void
569+ }
570+
571+ define void @ptr_iv_no_flags (ptr %base , i64 %end ) {
572+ ; CHECK-LABEL: define void @ptr_iv_no_flags(
542573; CHECK-SAME: ptr [[BASE:%.*]], i64 [[END:%.*]]) {
543574; CHECK-NEXT: entry:
544575; CHECK-NEXT: br label [[LOOP:%.*]]
0 commit comments