Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = ne 0:i32, %0
%2:i32 = var
%3:i1 = slt 0:i32, %2
%4:i1 = slt %2, 1:i32
%5:i1 = and %1, %3, %4
cand %5 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_463/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%tobool = icmp ne i32 %0, 0
%1 = load i32* @b, align 4
%cmp = icmp sgt i32 %1, 0
%or.cond = and i1 %tobool, %cmp
%cmp1 = icmp slt i32 %1, 1
%cmp1. = and i1 %or.cond, %cmp1
%land.ext = zext i1 %cmp1. to i32
ret i32 %land.ext
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_463/foo.c -o reduce_463/foo.bc
C source code:
int a, b;
int fn1() { return a && b > 0 && b <= 0; }
x86-64 from LLVM:
fn1: # @fn1
cmpl $0, a(%rip)
setne %al
cmpl $0, b(%rip)
setg %cl
setle %dl
andb %al, %cl
andb %dl, %cl
movzbl %cl, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_463/foo.c -S -o -
x86-64 from GCC:
fn1:
xorl %eax, %eax
ret
COMMAND: gcc -w -O3 reduce_463/foo.c -S -o -