1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[InstCombine] Add test for infinite combine loop (NFC)

Test courtesy of bkramer for the infinite combine loop introduced
by D87480.
This commit is contained in:
Nikita Popov 2020-09-16 18:27:55 +02:00
parent 18f35c5544
commit f88393ae10

View File

@ -2683,5 +2683,20 @@ define i8 @select_replacement_loop(i8 %x, i8 %y, i8 %z) {
ret i8 %sel
}
define i32 @select_replacement_loop2(i32 %arg, i32 %arg2) {
; CHECK-LABEL: @select_replacement_loop2(
; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[ARG:%.*]], [[ARG2:%.*]]
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[DIV]], [[ARG2]]
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[MUL]], [[ARG]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[DIV]], i32 undef
; CHECK-NEXT: ret i32 [[SEL]]
;
%div = udiv i32 %arg, %arg2
%mul = mul nsw i32 %div, %arg2
%cmp = icmp eq i32 %mul, %arg
%sel = select i1 %cmp, i32 %div, i32 undef
ret i32 %sel
}
declare void @use(i1)
declare i32 @llvm.cttz.i32(i32, i1 immarg)