Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = eq 0:i32, %0
%2:i32 = zext %1
%3:i32 = var
%4:i1 = ne 0:i32, %3
%5:i32 = zext %4
%6:i32 = subnsw %2, %5
%7:i1 = slt %6, 2:i32
cand %7 1:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_307/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @c, align 4, !tbaa !1
%cmp = icmp eq i32 %0, 0
%conv = zext i1 %cmp to i32
%1 = load i32* @b, align 4, !tbaa !1
%cmp1 = icmp ne i32 %1, 0
%conv2 = zext i1 %cmp1 to i32
%sub = sub nsw i32 %conv, %conv2
%cmp3 = icmp slt i32 %sub, 2
%conv4 = zext i1 %cmp3 to i32
store i32 %conv4, i32* @a, align 4, !tbaa !1
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_307/foo.c -o reduce_307/foo.bc
C source code:
int a, b, c;
void fn1() { a = (0 == c) - (b != 0) <= 1; }
x86-64 from LLVM:
fn1: # @fn1
cmpl $0, c(%rip)
sete %al
movzbl %al, %eax
cmpl $1, b(%rip)
adcl $-1, %eax
cmpl $2, %eax
setl %al
movzbl %al, %eax
movl %eax, a(%rip)
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_307/foo.c -S -o -
x86-64 from GCC:
fn1:
movl $1, a(%rip)
ret
COMMAND: gcc -w -O3 reduce_307/foo.c -S -o -