blob: c514dd1f5ec755f3253bf66623ffa1f98db5ff0d [file] [log] [blame]
Benjamin Kramerb8743a92012-05-28 19:18:16 +00001; RUN: opt -S -instcombine < %s | FileCheck %s
2
3@c = common global i8 0, align 1
4@a = common global i8 0, align 1
5@b = common global i8 0, align 1
6
7define void @func() nounwind uwtable ssp {
8entry:
David Blaikiea79ac142015-02-27 21:17:42 +00009 %0 = load i8, i8* @c, align 1
Benjamin Kramerb8743a92012-05-28 19:18:16 +000010 %conv = zext i8 %0 to i32
11 %or = or i32 %conv, 1
12 %conv1 = trunc i32 %or to i8
13 store i8 %conv1, i8* @a, align 1
14 %conv2 = zext i8 %conv1 to i32
15 %neg = xor i32 %conv2, -1
16 %and = and i32 1, %neg
17 %conv3 = trunc i32 %and to i8
18 store i8 %conv3, i8* @b, align 1
David Blaikiea79ac142015-02-27 21:17:42 +000019 %1 = load i8, i8* @a, align 1
Benjamin Kramerb8743a92012-05-28 19:18:16 +000020 %conv4 = zext i8 %1 to i32
21 %conv5 = zext i8 %conv3 to i32
22 %tobool = icmp ne i32 %conv4, 0
23 br i1 %tobool, label %land.rhs, label %land.end
24
25land.rhs: ; preds = %entry
26 %tobool8 = icmp ne i32 %conv5, 0
27 br label %land.end
28
29land.end: ; preds = %land.rhs, %entry
30 %2 = phi i1 [ false, %entry ], [ %tobool8, %land.rhs ]
31 %land.ext = zext i1 %2 to i32
32 %mul = mul nsw i32 3, %land.ext
33 %conv9 = trunc i32 %mul to i8
34 store i8 %conv9, i8* @a, align 1
35 ret void
36
Stephen Linc1c7a132013-07-14 01:42:54 +000037; CHECK-LABEL: @func(
Benjamin Kramerb8743a92012-05-28 19:18:16 +000038; CHECK-NOT: select
39}