Souper says:
; Function: fn1
%0:i32 = var
%1:i64 = sext %0
%2:i64 = and 9223372036854775807:i64, %1
%3:i1 = ne 0:i64, %2
%4:i32 = select %3, %0, 1:i32
%5:i1 = eq 0:i32, %4
cand %5 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_388/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%0 = load i32* @a, align 4, !tbaa !1
%conv = sext i32 %0 to i64
%and = and i64 %conv, 9223372036854775807
%tobool = icmp ne i64 %and, 0
%conv1 = select i1 %tobool, i32 %0, i32 1
store i32 %conv1, i32* @b, align 4, !tbaa !1
%tobool2 = icmp eq i32 %conv1, 0
br i1 %tobool2, label %if.end, label %for.cond.preheader
for.cond.preheader: ; preds = %entry
br label %for.cond
for.cond: ; preds = %for.cond.preheader, %for.cond
br label %for.cond
if.end: ; preds = %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_388/foo.c -o reduce_388/foo.bc
C source code:
int a, b;
void fn1() {
b = a & 9223372036854775807 ?: 1;
if (b)
for (;;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movslq a(%rip), %rax
movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
testq %rcx, %rax
movl $1, %ecx
cmovnel %eax, %ecx
testl %ecx, %ecx
movl %ecx, b(%rip)
je .LBB0_2
.LBB0_1: # %for.cond
jmp .LBB0_1
.LBB0_2: # %if.end
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_388/foo.c -S -o -
x86-64 from GCC:
fn1:
movslq a(%rip), %rdx
movabsq $9223372036854775807, %rax
andq %rdx, %rax
je .L2
testl %eax, %eax
movl %eax, b(%rip)
jne .L5
rep ret
.L2:
.L5:
.L4:
jmp .L4
COMMAND: gcc -w -O3 reduce_388/foo.c -S -o -