Souper says:
; Function: fn1
%0:i8 = var
%1:i32 = sext %0
%2:i32 = addnsw 4294967168:i32, %1
%3:i1 = ne 0:i32, %2
cand %3 1:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_377/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i8* @a, align 1, !tbaa !1
%conv = sext i8 %0 to i32
%sub = add nsw i32 %conv, -128
%tobool = icmp ne i32 %sub, 0
%sub. = select i1 %tobool, i32 %sub, i32 1
ret i32 %sub.
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_377/foo.c -o reduce_377/foo.bc
C source code:
char a;
int fn1() { return a - 128 ?: 1; }
x86-64 from LLVM:
fn1: # @fn1
movsbl a(%rip), %ecx
addl $-128, %ecx
movl $1, %eax
cmovnel %ecx, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_377/foo.c -S -o -
x86-64 from GCC:
fn1:
movsbl a(%rip), %eax
addl $-128, %eax
ret
COMMAND: gcc -w -O3 reduce_377/foo.c -S -o -