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)