Souper says:
; Function: fn1
%0:i32 = var
%1:i32 = and 4294967294:i32, %0
%2:i32 = xor 4294967294:i32, %1
%3:i32 = srem 1:i32, %2
%4:i1 = eq 0:i32, %3
cand %4 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_802/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%or = or i32 %0, 1
store i32 %or, i32* @a, align 4, !tbaa !1
%.not = and i32 %0, -2
%neg = xor i32 %.not, -2
store i32 %neg, i32* @b, align 4, !tbaa !1
%rem = srem i32 1, %neg
store i32 %rem, i32* @c, align 4, !tbaa !1
%tobool = icmp eq i32 %rem, 0
br i1 %tobool, label %if.end, label %for.cond.preheader
for.cond.preheader: ; preds = %entry
br label %for.cond
for.cond: ; preds = %for.cond.preheader, %for.cond
br label %for.cond
if.end: ; preds = %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_802/foo.c -o reduce_802/foo.bc
C source code:
int a, b, c;
void fn1() {
b = ~(a |= 1);
c = 1 % b;
if (c)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
movl %eax, %ecx
notl %ecx
orl $1, %eax
movl %eax, a(%rip)
andl $-2, %ecx
movl %ecx, b(%rip)
movl $1, %eax
xorl %edx, %edx
idivl %ecx
testl %edx, %edx
movl %edx, c(%rip)
je .LBB0_2
.LBB0_1: # %for.cond
jmp .LBB0_1
.LBB0_2: # %if.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_802/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
orl $1, %eax
movl %eax, a(%rip)
notl %eax
movl %eax, %ecx
movl %eax, b(%rip)
movl $1, %eax
cltd
idivl %ecx
testl %edx, %edx
movl %edx, c(%rip)
je .L1
.L3:
jmp .L3
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_802/foo.c -S -o -