Souper says:
; Function: fn1
%0:i32 = var
%1:i32 = var
%2:i32 = mul %0, %1
%3:i1 = eq 0:i32, %2
pc %3 0:i1
%4:i1 = eq 0:i32, %0
cand %4 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_397/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%1 = load i32* @b, align 4, !tbaa !1
%mul = mul nsw i32 %1, %0
store i32 %mul, i32* @c, align 4, !tbaa !1
%tobool = icmp eq i32 %mul, 0
br i1 %tobool, label %if.end4, label %for.cond.preheader
for.cond.preheader: ; preds = %entry
%phitmp = icmp eq i32 %1, 0
br label %for.cond
for.cond: ; preds = %for.cond.preheader, %for.cond
%2 = phi i1 [ true, %for.cond ], [ %phitmp, %for.cond.preheader ]
br i1 %2, label %for.cond, label %for.cond3.preheader
for.cond3.preheader: ; preds = %for.cond
br label %for.cond3
for.cond3: ; preds = %for.cond3.preheader, %for.cond3
br label %for.cond3
if.end4: ; preds = %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_397/foo.c -o reduce_397/foo.bc
C source code:
int a, b, c;
void fn1() {
c = a * b;
if (c)
for (;;)
if (b)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl b(%rip), %eax
movl a(%rip), %ecx
imull %eax, %ecx
testl %ecx, %ecx
movl %ecx, c(%rip)
je .LBB0_4
testl %eax, %eax
sete %al
.LBB0_2: # %for.cond
testb $1, %al
movb $1, %al
jne .LBB0_2
.LBB0_3: # %for.cond3
jmp .LBB0_3
.LBB0_4: # %if.end4
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_397/foo.c -S -o -
x86-64 from GCC:
fn1:
movl b(%rip), %eax
movl a(%rip), %edx
imull %eax, %edx
testl %edx, %edx
movl %edx, c(%rip)
je .L1
testl %eax, %eax
jne .L4
.L6:
jmp .L6
.L4:
jmp .L4
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_397/foo.c -S -o -