Souper says:
; Function: fn1
%0:i32 = var
%1:i32 = sdiv %0, 0:i32
%2:i1 = eq 0:i32, %1
cand %2 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_178/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%div = sdiv i32 %0, 0
store i32 %div, i32* @b, align 4, !tbaa !1
%tobool = icmp eq i32 %div, 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_178/foo.c -o reduce_178/foo.bc
C source code:
int a, b;
void fn1() {
int c = 0;
b = a / c;
if (b)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
xorl %ecx, %ecx
cltd
idivl %ecx
testl %eax, %eax
movl %eax, b(%rip)
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_178/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
xorl %ecx, %ecx
cltd
idivl %ecx
testl %eax, %eax
movl %eax, b(%rip)
je .L1
.L3:
jmp .L3
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_178/foo.c -S -o -