Souper says:
; Function: fn1
%0:i1 = var
pc %0 1:i1
%1:i32 = zext %0
%2:i32 = xor 1:i32, %1
%3:i32 = lshr 1:i32, %2
%4:i1 = ne 0:i32, %3
cand %4 1:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_624/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%.b2 = load i1* @a, align 1
%0 = zext i1 %.b2 to i32
%1 = xor i32 %0, 1
store i32 %1, i32* @b, align 4, !tbaa !1
br i1 %.b2, label %lor.rhs, label %lor.end
lor.rhs: ; preds = %entry
%shr = lshr i32 1, %1
%tobool1 = icmp ne i32 %shr, 0
br label %lor.end
lor.end: ; preds = %entry, %lor.rhs
%2 = phi i1 [ true, %entry ], [ %tobool1, %lor.rhs ]
%lor.ext = zext i1 %2 to i32
store i32 %lor.ext, i32* @c, align 4, !tbaa !1
store i1 true, i1* @a, align 1
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_624/foo.c -o reduce_624/foo.bc
C source code:
static int a = 1;
int b;
int c;
void fn1() {
b = a;
c = a || 1 >> a;
a = 0;
}
x86-64 from LLVM:
fn1: # @fn1
movzbl a(%rip), %eax
movl %eax, %ecx
xorl $1, %ecx
cmpl $1, %eax
movl %ecx, b(%rip)
movb $1, %al
jne .LBB0_2
movl $1, %eax
shrl %cl, %eax
testl %eax, %eax
setne %al
.LBB0_2: # %lor.end
movzbl %al, %eax
movl %eax, c(%rip)
movb $1, a(%rip)
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_624/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
movl $1, c(%rip)
movl $0, a(%rip)
movl %eax, b(%rip)
ret
a:
COMMAND: gcc -w -O3 reduce_624/foo.c -S -o -