https://bugs.llvm.org/show_bug.cgi?id=40851
Bug ID: 40851
Summary: Inline jump tables
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: llvm-bugs@lists.llvm.org
int square(int x) {
return x*x;
}
int add(int x) {
return x + x;
}
typedef int (*p) (int);
p arr[4] = {square, add};
int test(int x) {
int res = arr[1](x);
return res;
}
Expected:
test(int):
lea eax, [rdi+rdi]
ret
Currently:
test(int):
jmp [QWORD PTR arr[rip+8]]
------------
If the index to the jump table isn't a constant, should not be better to expand
"if else" chain like:
if (x==1) arr[1](x);
else if (x==2) arr[2](x);
..and then take an opportunity to inline functions?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs