Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ for.body: ; preds = %entry, %cont
%0 = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %i.04, i32 1)
%1 = extractvalue { i32, i1 } %0, 1

; CHECK: for.body:
; CHECK-NOT: @llvm.usub.with.overflow.i32
; CHECK: br i1 false, label %trap, label %cont, !nosanitize !0
br i1 %1, label %trap, label %cont, !nosanitize !{}

trap: ; preds = %for.body
tail call void @llvm.trap(), !nosanitize !{}
unreachable, !nosanitize !{}

cont: ; preds = %for.body
%2 = extractvalue { i32, i1 } %0, 0
%cmp = icmp sgt i32 %2, 0
br i1 %cmp, label %for.body, label %for.cond.cleanup
}

define void @f_usub_overflow(ptr nocapture %a) {
; CHECK-LABEL: @f_usub_overflow(
entry:
br label %for.body

for.cond.cleanup: ; preds = %cont
ret void

for.body: ; preds = %entry, %cont
%i.04 = phi i32 [ 15, %entry ], [ %2, %cont ]
%idxprom = sext i32 %i.04 to i64
%arrayidx = getelementptr inbounds i8, ptr %a, i64 %idxprom
store i8 0, ptr %arrayidx, align 1
%0 = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %i.04, i32 1)
%1 = extractvalue { i32, i1 } %0, 1

; It is theoretically possible to prove this, but SCEV cannot
; represent non-unsigned-wrapping subtraction operations.

Expand Down