Souper says:
; Function: fn1
%0:i8 = var
%1:i32 = sext %0
%2:i32 = sdiv 128: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_17/foo.bc
LLVM says:
define i32 @fn1() #0 {
entry:
%0 = load i8* @a, align 1, !tbaa !1
%conv = sext i8 %0 to i32
%div = sdiv i32 128, %conv
%tobool = icmp ne i32 %div, 0
%lor.ext = zext i1 %tobool to i32
ret i32 %lor.ext
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_17/foo.c -o reduce_17/foo.bc
C source code:
char a;
int fn1() { return 128 / a || 0; }
x86-64 from LLVM:
fn1: # @fn1
movsbl a(%rip), %ecx
movl $128, %eax
xorl %edx, %edx
idivl %ecx
testl %eax, %eax
setne %al
movzbl %al, %eax
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_17/foo.c -S -o -
x86-64 from GCC:
fn1:
movsbl a(%rip), %ecx
movl $128, %eax
cltd
idivl %ecx
testl %eax, %eax
setne %al
movzbl %al, %eax
ret
COMMAND: gcc -w -O3 reduce_17/foo.c -S -o -