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