Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = slt %0, 0:i32
pc %1 1:i1
%2:i32 = subnsw 1:i32, %0
%3:i1 = slt 0:i32, %2
cand %3 1:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_354/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%cmp = icmp slt i32 %0, 0
br i1 %cmp, label %land.rhs, label %land.end
land.rhs: ; preds = %entry
%sub = sub nsw i32 1, %0
%cmp1 = icmp sgt i32 %sub, 0
br label %land.end
land.end: ; preds = %land.rhs, %entry
%1 = phi i1 [ false, %entry ], [ %cmp1, %land.rhs ]
%land.ext = zext i1 %1 to i32
ret i32 %land.ext
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_354/foo.c -o reduce_354/foo.bc
C source code:
int a;
int fn1() { return a < 0 && 0 < 1 - a; }
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
js .LBB0_2
xorl %eax, %eax
movzbl %al, %eax
retq
.LBB0_2: # %land.rhs
movl $1, %ecx
subl %eax, %ecx
testl %ecx, %ecx
setg %al
movzbl %al, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_354/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %eax
shrl $31, %eax
ret
COMMAND: gcc -w -O3 reduce_354/foo.c -S -o -