Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = slt 0:i32, %0
pc %1 1:i1
%2:i32 = sub 0:i32, %0
%3:i1 = slt 4294967295:i32, %2
cand %3 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_658/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%.pr = load i32* @a, align 4, !tbaa !1
%cmp1 = icmp sgt i32 %.pr, 0
br i1 %cmp1, label %for.body.lr.ph, label %for.end
for.body.lr.ph: ; preds = %entry
%0 = sub i32 0, %.pr
%1 = icmp sgt i32 %0, -1
%.op = add i32 %.pr, -1
%2 = select i1 %1, i32 %.op, i32 0
store i32 0, i32* @b, align 4, !tbaa !1
store i32 %2, i32* @a, align 4, !tbaa !1
br label %for.end
for.end: ; preds = %for.body.lr.ph, %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_658/foo.c -o reduce_658/foo.bc
C source code:
int a, b;
void fn1() {
for (; a > 0; --a)
b = 0;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
jle .LBB0_2
leal -1(%rax), %ecx
xorl %edx, %edx
negl %eax
cmovnsl %ecx, %edx
movl $0, b(%rip)
movl %edx, a(%rip)
.LBB0_2: # %for.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_658/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
testl %eax, %eax
jle .L1
movl $0, b(%rip)
movl $0, a(%rip)
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_658/foo.c -S -o -