Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = eq 0:i32, %0
%2:i32 = zext %1
%3:i32 = select %1, %2, %0
%4:i1 = eq 0:i32, %3
cand %4 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_385/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%cmp = icmp eq i32 %0, 0
%conv = zext i1 %cmp to i32
%cond = select i1 %cmp, i32 %conv, i32 %0
store i32 %cond, i32* @c, align 4, !tbaa !1
%tobool = icmp eq i32 %cond, 0
br i1 %tobool, label %if.end, label %if.then
if.then: ; preds = %entry
store i32 0, i32* @b, 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_385/foo.c -o reduce_385/foo.bc
C source code:
int a, b, c;
void fn1() {
c = a == 0 ?: a;
if (c)
b = 0;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
sete %cl
movzbl %cl, %ecx
cmovnel %eax, %ecx
testl %ecx, %ecx
movl %ecx, c(%rip)
je .LBB0_2
movl $0, b(%rip)
.LBB0_2: # %if.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_385/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %edx
movl $1, %eax
movl $0, b(%rip)
testl %edx, %edx
cmovne %edx, %eax
movl %eax, c(%rip)
ret
COMMAND: gcc -w -O3 reduce_385/foo.c -S -o -