https://llvm.org/bugs/show_bug.cgi?id=29095
Bug ID: 29095
Summary: CGP generates inefficient branch for double selects
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: daniel...@gmail.com
CC: davi...@google.com, llvm-bugs@lists.llvm.org
Classification: Unclassified
int*
rbsearch(int c, int *t, int n, int ne)
{
int *p;
int m;
while(n > 1) {
m = n >> 1;
p = t + m*ne;
if(__builtin_expect(c >= p[0], true)) {
t = p;
n = n-m;
} else
n = m;
}
return t;
}
For this test case, building with clang -O2, the generated x86 code is has
something like:
cmpl %edi, %r9d
jle .LBB0_3
# BB#2:
movl %r10d, %edx
jmp .LBB0_4
.p2align 4, 0x90
.LBB0_3:
subl %r10d, %edx
.LBB0_4:
cmpl %edi, %r9d
jg .LBB0_6
Note that the two cmpl instructions are redundant. The problem is gone if the
code is compiled with -mllvm -phi-node-folding-threshold=0
The issue is that CGP generates 2 conditional branches (with same condition)
for 2 select instructions.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs