Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = eq 0:i32, %0
%2:i32 = zext %1
%3:i32 = udiv 1:i32, %2
%4:i1 = eq 0:i32, %3
cand %4 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_404/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @b, align 4, !tbaa !1
%cmp = icmp eq i32 %0, 0
%conv = zext i1 %cmp to i32
%div = udiv i32 1, %conv
%tobool = icmp eq i32 %div, 0
br i1 %tobool, label %lor.rhs, label %lor.end
lor.rhs: ; preds = %entry
store i32 0, i32* @a, align 4, !tbaa !1
br label %lor.end
lor.end: ; preds = %entry, %lor.rhs
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_404/foo.c -o reduce_404/foo.bc
C source code:
int a, b;
void fn1() { 1 / (b == 0) || (a = 0); }
x86-64 from LLVM:
fn1: # @fn1
cmpl $0, b(%rip)
sete %al
movzbl %al, %ecx
movl $1, %eax
xorl %edx, %edx
divl %ecx
testl %eax, %eax
jne .LBB0_2
movl $0, a(%rip)
.LBB0_2: # %lor.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_404/foo.c -S -o -
x86-64 from GCC:
fn1:
movl b(%rip), %eax
testl %eax, %eax
je .L1
movl $1, %eax
xorl %ecx, %ecx
cltd
idivl %ecx
testl %eax, %eax
je .L4
.L1:
rep ret
.L4:
movl $0, a(%rip)
ret
COMMAND: gcc -w -O3 reduce_404/foo.c -S -o -