Souper says:
; Function: fn2
%0:i32 = var
%1:i32 = subnsw 0:i32, %0
%2:i32 = and %0, %1
%3:i1 = eq 14:i32, %2
cand %3 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_147/foo.bc
LLVM says:
define void @fn2() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%sub.i = sub nsw i32 0, %0
%and.i = and i32 %0, %sub.i
%tobool.i = icmp eq i32 %and.i, 14
br i1 %tobool.i, label %for.cond.i.preheader, label %for.cond1.preheader.split.i
for.cond.i.preheader: ; preds = %entry
br label %for.cond.i
for.cond.i: ; preds = %for.cond.i.preheader, %for.cond.i
br label %for.cond.i
for.cond1.preheader.split.i: ; preds = %entry
store i32 %and.i, i32* @b, align 4, !tbaa !1
br label %for.cond1.i
for.cond1.i: ; preds = %for.cond1.i, %for.cond1.preheader.split.i
br label %for.cond1.i
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_147/foo.c -o reduce_147/foo.bc
C source code:
int a, b;
static unsigned char fn1();
void fn2() { fn1(14); }
unsigned char fn1(p1) {
for (;;) {
b = a & -a;
if (p1 ^ b)
for (;;)
;
}
}
x86-64 from LLVM:
fn2: # @fn2
movl a(%rip), %ecx
movl %ecx, %eax
negl %eax
andl %ecx, %eax
cmpl $14, %eax
jne .LBB0_2
.LBB0_1: # %for.cond.i
jmp .LBB0_1
.LBB0_2: # %for.cond1.preheader.split.i
movl %eax, b(%rip)
.LBB0_3: # %for.cond1.i
jmp .LBB0_3
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_147/foo.c -S -o -
x86-64 from GCC:
fn2:
movl a(%rip), %edx
movl %edx, %eax
negl %eax
andl %edx, %eax
cmpl $14, %eax
jne .L2
.L3:
jmp .L3
.L2:
movl %eax, b(%rip)
.L4:
jmp .L4
COMMAND: gcc -w -O3 reduce_147/foo.c -S -o -