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