https://bugs.llvm.org/show_bug.cgi?id=35906
Bug ID: 35906
Summary: Comparisons against last enum are optimizable (found
via LLVM classof() analysis)
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: d...@znu.io
CC: llvm-bugs@lists.llvm.org
In LLVM and derived projects, exhaustive enums are common. For example, from
the casting machinery, an abstract class might have code roughly like this:
static bool classof(Thing *t) {
return t->getKind() >= ThingKind::First_AbstractFoo &&
t->getKind() <= ThingKind::Last_AbstractFoo;
}
If ThingKind::Last_AbstractFoo equals the last enumeration, then "t->getKind()
<= ThingKind::Last_AbstractFoo" will always be true. (Similarly, "t->getKind()
> ThingKind::Last_AbstractFoo" will always fail). That being said, clang
generates the IR for the pointless comparison above.
This seems like an easy optimization opportunity.
--
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