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