[llvm-bugs] [Bug 40851] New: Inline jump tables
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 25 01:02:01 PST 2019
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: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190225/4eca014f/attachment.html>
More information about the llvm-bugs
mailing list