Souper says:
; Function: fn1
%0:i32 = var
%1:i64 = sext %0
%2:i64 = subnsw 2036854775807:i64, %1
%3:i1 = slt %2, 0:i64
cand %3 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_493/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%conv = sext i32 %0 to i64
%sub = sub nsw i64 2036854775807, %conv
%cmp = icmp slt i64 %sub, 0
%sub.lobit = lshr i64 %sub, 63
%1 = trunc i64 %sub.lobit to i32
%conv1. = select i1 %cmp, i32 %1, i32 0
ret i32 %conv1.
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_493/foo.c -o reduce_493/foo.bc
C source code:
int a;
int fn1() { return 2036854775807 - a < 0 ?: 0; }
x86-64 from LLVM:
fn1: # @fn1
movslq a(%rip), %rcx
movabsq $2036854775807, %rax # imm = 0x1DA3E015FFF
subq %rcx, %rax
shrq $63, %rax
andl %eax, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_493/foo.c -S -o -
x86-64 from GCC:
fn1:
xorl %eax, %eax
ret
COMMAND: gcc -w -O3 reduce_493/foo.c -S -o -