; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S | FileCheck %s
define i32 @func(i32 %x) {
; CHECK-LABEL: @func(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:.*]], 0
; CHECK-NEXT: [[TMP2:%.*]] = call i32 @foo(i1 [[TMP1]])
; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[X]], 1
; CHECK-NEXT: [[TMP4:%.*]] = call i32 @foo(i1 [[TMP3]])
; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i32 [[TMP4]], 0
; CHECK-NEXT: [[TMP6:%.*]] = select i1 [[TMP5]], i32 [[TMP4]], i32 [[TMP2]]
; CHECK-NEXT: [[TMP7:%.*]] = icmp eq i32 [[X]], 2
; CHECK-NEXT: [[TMP8:%.*]] = call i32 @foo(i1 [[TMP7]])
; CHECK-NEXT: [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
; CHECK-NEXT: [[TMP10:%.*]] = select i1 [[TMP9]], i32 [[TMP8]], i32 [[TMP6]]
; CHECK-NEXT: ret i32 [[TMP10]]
;
%1 = icmp eq i32 %x, 0
%2 = call i32 @foo(i1 %1)
%3 = icmp eq i32 %x, 2
%4 = call i32 @foo(i1 %3)
%5 = icmp ne i32 %4, 0
%6 = select i1 %5, i32 %4, i32 %2
ret i32 %6
}
declare i32 @foo(i1)