1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s
3
4@c = external dso_local local_unnamed_addr global i32, align 4
5@b = external dso_local local_unnamed_addr global i32, align 4
6@d = external dso_local local_unnamed_addr global i32, align 4
7
8define void @fn1() {
9; CHECK-LABEL: fn1:
10; CHECK:       # %bb.0:
11; CHECK-NEXT:    cmpl $1, c(%rip)
12; CHECK-NEXT:    sbbl %eax, %eax
13; CHECK-NEXT:    andl $1, %eax
14; CHECK-NEXT:    movl %eax, d(%rip)
15; CHECK-NEXT:    retq
16  %t0 = load i32, i32* @c, align 4
17  %tobool1 = icmp eq i32 %t0, 0
18  %xor = zext i1 %tobool1 to i32
19  %t1 = load i32, i32* @b, align 4
20  %tobool2 = icmp ne i32 %t1, 0
21  %t2 = load i32, i32* @d, align 4
22  %tobool4 = icmp ne i32 %t2, 0
23  %t3 = and i1 %tobool4, %tobool2
24  %sub = sext i1 %t3 to i32
25  %div = sdiv i32 %sub, 2
26  %add = add nsw i32 %div, %xor
27  store i32 %add, i32* @d, align 4
28  ret void
29}
30