Souper says:
; Function: fn1
%0:i8 = var
%1:i1 = eq 0:i8, %0
%2:i32 = var
%3:i1 = eq 0:i32, %2
%4:i1 = or %1, %3
pc %4 1:i1
%5:i1 = xor 1:i1, %3
%6:i1 = ne 0:i8, %0
%7:i1 = and %5, %6
cand %7 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_77/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%tobool = icmp eq i32 %0, 0
%1 = load i8* @b, align 1
%tobool1 = icmp eq i8 %1, 0
%or.cond = or i1 %tobool, %tobool1
br i1 %or.cond, label %lor.rhs, label %lor.end
lor.rhs: ; preds = %entry
%tobool4 = icmp ne i8 %1, 0
%not.tobool = xor i1 %tobool, true
%.tobool4 = and i1 %tobool4, %not.tobool
br label %lor.end
lor.end: ; preds = %lor.rhs, %entry
%2 = phi i1 [ true, %entry ], [ %.tobool4, %lor.rhs ]
%lor.ext = zext i1 %2 to i32
ret i32 %lor.ext
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_77/foo.c -o reduce_77/foo.bc
C source code:
int a;
char b;
int fn1() { return a && b || a && b; }
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
movb b(%rip), %dl
je .LBB0_2
movb $1, %cl
testb %dl, %dl
jne .LBB0_3
.LBB0_2: # %lor.rhs
testb %dl, %dl
setne %dl
testl %eax, %eax
setne %cl
andb %dl, %cl
.LBB0_3: # %lor.end
movzbl %cl, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_77/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %edx
xorl %eax, %eax
testl %edx, %edx
je .L2
xorl %eax, %eax
cmpb $0, b(%rip)
setne %al
.L2:
rep ret
COMMAND: gcc -w -O3 reduce_77/foo.c -S -o -