[NFC][ InstCombine] precommit test for D121585

Based on original tests from D121585.
This commit is contained in:
Andrew Wei 2022-03-18 00:35:47 +08:00
parent d2b4a675a8
commit f241d43b40
1 changed files with 32 additions and 0 deletions

View File

@ -237,3 +237,35 @@ if:
else:
ret void
}
declare void @abort()
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64)
declare void @dummy(i64)
; Todo: Two uses in two different users of a single successor block. We can sink.
define i64 @test8(i64 %c) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: bb1:
; CHECK-NEXT: [[OVERFLOW:%.*]] = icmp ugt i64 [[C:%.*]], 2305843009213693951
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[OVERFLOW]], i64 0, i64 8
; CHECK-NEXT: br i1 [[OVERFLOW]], label [[ABORT:%.*]], label [[BB2:%.*]]
; CHECK: bb2:
; CHECK-NEXT: call void @dummy(i64 [[SELECT]])
; CHECK-NEXT: ret i64 [[SELECT]]
; CHECK: abort:
; CHECK-NEXT: call void @abort()
; CHECK-NEXT: unreachable
;
bb1:
%mul = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %c, i64 8)
%overflow = extractvalue { i64, i1 } %mul, 1
%select = select i1 %overflow, i64 0, i64 8
br i1 %overflow, label %abort, label %bb2
bb2:
call void @dummy(i64 %select)
ret i64 %select
abort:
call void @abort()
unreachable
}