1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3target datalayout = "e-m:e-i64:64-n8:16:32:64"
4
5; Although i1 is not in the datalayout, we should treat it
6; as a legal type because it is a fundamental type in IR.
7; This means we should shrink the phi (sink the zexts).
8
9define i64 @sink_i1_casts(i1 %cond1, i1 %cond2) {
10; CHECK-LABEL: @sink_i1_casts(
11; CHECK-NEXT:  entry:
12; CHECK-NEXT:    br i1 %cond1, label %if, label %end
13; CHECK:       if:
14; CHECK-NEXT:    br label %end
15; CHECK:       end:
16; CHECK-NEXT:    [[PHI_IN:%.*]] = phi i1 [ %cond1, %entry ], [ %cond2, %if ]
17; CHECK-NEXT:    [[PHI:%.*]] = zext i1 [[PHI_IN]] to i64
18; CHECK-NEXT:    ret i64 [[PHI]]
19;
20entry:
21  %z1 = zext i1 %cond1 to i64
22  br i1 %cond1, label %if, label %end
23
24if:
25  %z2 = zext i1 %cond2 to i64
26  br label %end
27
28end:
29  %phi = phi i64 [ %z1, %entry ], [ %z2, %if ]
30  ret i64 %phi
31}
32
33