Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = slt 0:i32, %0
%2:i32 = sext %1
%3:i32 = var
%4:i1 = eq 0:i32, %3
%5:i32 = zext %4
%6:i1 = sle %2, %5
cand %6 1:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_66/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%cmp = icmp sgt i32 %0, 0
%conv = zext i1 %cmp to i32
store i32 %conv, i32* @d, align 4, !tbaa !1
%sub = sext i1 %cmp to i32
store i32 %sub, i32* @e, align 4, !tbaa !1
%1 = load i32* @b, align 4, !tbaa !1
%cmp1 = icmp eq i32 %1, 0
%conv2 = zext i1 %cmp1 to i32
%cmp3 = icmp sge i32 %conv2, %sub
%conv4 = zext i1 %cmp3 to i32
store i32 %conv4, i32* @c, align 4, !tbaa !1
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_66/foo.c -o reduce_66/foo.bc
C source code:
int a, b, c, d, e;
void fn1() {
d = 0 < a;
e = -d;
c = (0 == b) >= e;
}
x86-64 from LLVM:
fn1: # @fn1
xorl %eax, %eax
cmpl $0, a(%rip)
setg %cl
movzbl %cl, %ecx
movl %ecx, d(%rip)
movl $-1, %ecx
cmovlel %eax, %ecx
movl %ecx, e(%rip)
cmpl $0, b(%rip)
sete %al
movzbl %al, %eax
cmpl %ecx, %eax
setge %al
movzbl %al, %eax
movl %eax, c(%rip)
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_66/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %edx
xorl %eax, %eax
movl $1, c(%rip)
testl %edx, %edx
setg %al
movl %eax, d(%rip)
negl %eax
movl %eax, e(%rip)
ret
COMMAND: gcc -w -O3 reduce_66/foo.c -S -o -