Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = eq 0:i32, %0
%2:i32 = zext %1
%3:i32 = or %0, %2
%4:i1 = eq 0:i32, %3
cand %4 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_783/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%cmp = icmp eq i32 %0, 0
%conv = zext i1 %cmp to i32
store i32 %conv, i32* @b, align 4, !tbaa !1
%or = or i32 %conv, %0
%tobool = icmp eq i32 %or, 0
br i1 %tobool, label %if.end, label %for.cond.preheader
for.cond.preheader: ; preds = %entry
br label %for.cond
for.cond: ; preds = %for.cond.preheader, %for.cond
br label %for.cond
if.end: ; preds = %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_783/foo.c -o reduce_783/foo.bc
C source code:
int a, b;
void fn1() {
b = a == 0;
if (b | a)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
sete %cl
movzbl %cl, %ecx
movl %ecx, b(%rip)
orl %eax, %ecx
je .LBB0_2
.LBB0_1: # %for.cond
jmp .LBB0_1
.LBB0_2: # %if.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_783/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
xorl %edx, %edx
testl %eax, %eax
sete %dl
movl %edx, b(%rip)
orl %eax, %edx
je .L1
.L3:
jmp .L3
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_783/foo.c -S -o -