Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = eq 0:i32, %0
pc %1 1:i1
%2:i32 = addnsw 4294967295:i32, %0
%3:i16 = var
%4:i32 = zext %3
%5:i1 = eq %2, %4
cand %5 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_164/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @b, align 4, !tbaa !1
%sub = add nsw i32 %0, -1
store i32 %sub, i32* @a, align 4, !tbaa !1
%tobool = icmp eq i32 %0, 0
br i1 %tobool, label %if.else, label %if.end3
if.else: ; preds = %entry
%1 = load i16* @c, align 2, !tbaa !5
%conv = zext i16 %1 to i32
%cmp = icmp eq i32 %sub, %conv
br i1 %cmp, label %if.end3, label %for.cond.preheader
for.cond.preheader: ; preds = %if.else
br label %for.cond
for.cond: ; preds = %for.cond.preheader, %for.cond
br label %for.cond
if.end3: ; preds = %if.else, %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_164/foo.c -o reduce_164/foo.bc
C source code:
int a, b;
unsigned short c;
void fn1() {
int *d = &a;
*d = b - 1;
if (b)
;
else if (*d != c)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl b(%rip), %ecx
leal -1(%rcx), %eax
testl %ecx, %ecx
movl %eax, a(%rip)
jne .LBB0_3
movzwl c(%rip), %ecx
cmpl %ecx, %eax
jne .LBB0_2
.LBB0_3: # %if.end3
retq
.LBB0_2: # %for.cond
jmp .LBB0_2
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_164/foo.c -S -o -
x86-64 from GCC:
fn1:
movl b(%rip), %eax
leal -1(%rax), %edx
testl %eax, %eax
movl %edx, a(%rip)
jne .L1
.L3:
jmp .L3
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_164/foo.c -S -o -