Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = slt 4294967295:i32, %0
pc %1 1:i1
%2:i32 = xor 4294967295:i32, %0
%3:i1 = slt 4294967295:i32, %2
cand %3 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_236/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%.pr = load i32* @a, align 4, !tbaa !1
%cmp5 = icmp sgt i32 %.pr, -1
br i1 %cmp5, label %for.cond1thread-pre-split.lr.ph, label %for.end3
for.cond1thread-pre-split.lr.ph: ; preds = %entry
%.pr4 = load i32* @b, align 4, !tbaa !1
%tobool = icmp eq i32 %.pr4, 0
br i1 %tobool, label %for.inc.split.us.preheader, label %for.cond1.preheader
for.cond1.preheader: ; preds = %for.cond1thread-pre-split.lr.ph
br label %for.cond1
for.inc.split.us.preheader: ; preds = %for.cond1thread-pre-split.lr.ph
%0 = xor i32 %.pr, -1
%1 = icmp sgt i32 %0, -1
%smax = select i1 %1, i32 %0, i32 -1
%2 = add i32 %.pr, %smax
%3 = add i32 %2, 2
%end.idx = add i32 %2, 2
%n.vec = and i32 %3, -8
%cmp.zero = icmp eq i32 %n.vec, 0
%rev.ind.end = sub i32 %.pr, %n.vec
br i1 %cmp.zero, label %middle.block, label %vector.body.preheader
vector.body.preheader: ; preds = %for.inc.split.us.preheader
br label %vector.body
vector.body: ; preds = %vector.body.preheader, %vector.body
%index = phi i32 [ %index.next, %vector.body ], [ 0, %vector.body.preheader ]
%index.next = add i32 %index, 8
%4 = icmp eq i32 %index.next, %n.vec
br i1 %4, label %middle.block.loopexit, label %vector.body, !llvm.loop !5
middle.block.loopexit: ; preds = %vector.body
br label %middle.block
middle.block: ; preds = %middle.block.loopexit, %for.inc.split.us.preheader
%resume.val = phi i32 [ %.pr, %for.inc.split.us.preheader ], [ %rev.ind.end, %middle.block.loopexit ]
%new.indc.resume.val = phi i32 [ 0, %for.inc.split.us.preheader ], [ %n.vec, %middle.block.loopexit ]
%cmp.n = icmp eq i32 %end.idx, %new.indc.resume.val
br i1 %cmp.n, label %for.cond.for.end3_crit_edge, label %for.inc.split.us.preheader8
for.inc.split.us.preheader8: ; preds = %middle.block
br label %for.inc.split.us
for.inc.split.us: ; preds = %for.inc.split.us.preheader8, %for.inc.split.us
%dec6.us = phi i32 [ %dec.us, %for.inc.split.us ], [ %resume.val, %for.inc.split.us.preheader8 ]
%dec.us = add nsw i32 %dec6.us, -1
%cmp.us = icmp sgt i32 %dec6.us, 0
br i1 %cmp.us, label %for.inc.split.us, label %for.cond.for.end3_crit_edge.loopexit, !llvm.loop !8
for.cond1: ; preds = %for.cond1.preheader, %for.cond1
br label %for.cond1
for.cond.for.end3_crit_edge.loopexit: ; preds = %for.inc.split.us
br label %for.cond.for.end3_crit_edge
for.cond.for.end3_crit_edge: ; preds = %for.cond.for.end3_crit_edge.loopexit, %middle.block
store i32 -1, i32* @a, align 4, !tbaa !1
br label %for.end3
for.end3: ; preds = %for.cond.for.end3_crit_edge, %entry
ret void
}
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -c -w -emit-llvm -O3 reduce_236/foo.c -o reduce_236/foo.bc
C source code:
int a, b;
void fn1() {
for (; a >= 0; a--)
for (; b;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl a(%rip), %eax
testl %eax, %eax
js .LBB0_10
cmpl $0, b(%rip)
je .LBB0_2
.LBB0_11: # %for.cond1
jmp .LBB0_11
.LBB0_2: # %for.inc.split.us.preheader
movl %eax, %esi
notl %esi
cmpl $-2, %esi
movl $-1, %r9d
movl $-1, %ecx
cmovgl %esi, %ecx
leal 2(%rax,%rcx), %r10d
movl %r10d, %ecx
andl $-8, %ecx
xorl %edi, %edi
movl %r10d, %edx
andl $-8, %edx
je .LBB0_6
movl %eax, %r8d
subl %ecx, %r8d
cmpl $-2, %esi
cmovgl %esi, %r9d
leal 2(%rax,%r9), %eax
andl $-8, %eax
.LBB0_4: # %vector.body
addl $-8, %eax
jne .LBB0_4
movl %r8d, %eax
movl %edx, %edi
.LBB0_6: # %middle.block
cmpl %edi, %r10d
je .LBB0_9
incl %eax
.LBB0_8: # %for.inc.split.us
decl %eax
testl %eax, %eax
jg .LBB0_8
.LBB0_9: # %for.cond.for.end3_crit_edge
movl $-1, a(%rip)
.LBB0_10: # %for.end3
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_236/foo.c -S -o -
x86-64 from GCC:
fn1:
movl a(%rip), %edx
testl %edx, %edx
js .L1
movl b(%rip), %eax
testl %eax, %eax
je .L3
.L4:
jmp .L4
.L3:
movl $-1, a(%rip)
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_236/foo.c -S -o -