Souper says:
; Function: fn1
%0:i32 = var
%1:i1 = slt %0, 1:i32
pc %1 1:i1
%2:i1 = slt 0:i32, %0
cand %2 0:i1
COMMAND: /home/regehr/souper/build/souper -stp-path=/usr/local/bin/stp reduce_642/foo.bc
LLVM says:
define void @fn1() #0 {
entry:
%.pr = load i32* @b, align 4, !tbaa !1
%cmp5 = icmp slt 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* @a, 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 = icmp sgt i32 %.pr, 0
%.pr.op = add i32 %.pr, 1
%1 = select i1 %0, i32 %.pr.op, i32 1
%2 = sub i32 %1, %.pr
%n.vec = and i32 %2, -8
%end.idx.rnd.down = add i32 %n.vec, %.pr
%cmp.zero = icmp eq i32 %n.vec, 0
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 ], [ %.pr, %vector.body.preheader ]
%index.next = add i32 %index, 8
%3 = icmp eq i32 %index.next, %end.idx.rnd.down
br i1 %3, 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 ], [ %end.idx.rnd.down, %middle.block.loopexit ]
%cmp.n = icmp eq i32 %1, %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
%inc6.us = phi i32 [ %inc.us, %for.inc.split.us ], [ %resume.val, %for.inc.split.us.preheader8 ]
%inc.us = add nsw i32 %inc6.us, 1
%cmp.us = icmp slt i32 %inc6.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* @b, 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_642/foo.c -o reduce_642/foo.bc
C source code:
int a, b;
void fn1() {
for (; b <= 0; b++)
for (; a;)
;
}
x86-64 from LLVM:
fn1: # @fn1
movl b(%rip), %eax
testl %eax, %eax
jg .LBB0_10
cmpl $0, a(%rip)
je .LBB0_2
.LBB0_11: # %for.cond1
jmp .LBB0_11
.LBB0_2: # %for.inc.split.us.preheader
leal 1(%rax), %edx
testl %eax, %eax
movl $1, %ecx
cmovgl %edx, %ecx
movl %ecx, %esi
subl %eax, %esi
movl %esi, %edx
andl $-8, %edx
andl $-8, %esi
je .LBB0_6
addl %eax, %edx
xorl %esi, %esi
testl %eax, %eax
cmovnsl %eax, %esi
incl %esi
subl %eax, %esi
andl $-8, %esi
.LBB0_4: # %vector.body
addl $-8, %esi
jne .LBB0_4
movl %edx, %eax
.LBB0_6: # %middle.block
cmpl %eax, %ecx
je .LBB0_9
decl %eax
.LBB0_8: # %for.inc.split.us
incl %eax
js .LBB0_8
.LBB0_9: # %for.cond.for.end3_crit_edge
movl $1, b(%rip)
.LBB0_10: # %for.end3
retq
COMMAND: /home/regehr/souper/third_party/llvm/Debug/bin/clang -w -O3 reduce_642/foo.c -S -o -
x86-64 from GCC:
fn1:
movl b(%rip), %edx
testl %edx, %edx
jg .L1
movl a(%rip), %eax
testl %eax, %eax
je .L3
.L4:
jmp .L4
.L3:
movl $1, b(%rip)
.L1:
rep ret
COMMAND: gcc -w -O3 reduce_642/foo.c -S -o -