Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 2.9.0, 2.9.0.1, 2.9.1
-
Fix Version/s: 1000
-
Component/s: Compiler: Optimizing
-
Labels:None
-
Number of attachments :
Description
See sourceforge tracker https://sourceforge.net/tracker/index.php?func=detail&aid=1147079&group_id=128805&atid=712768 for full history.
The crux of the problem is shown by the following example:
For example if someone happened to write Java code (or if we
did some partial CSE on instanceof operations that resulted
in code) like:
boolean flag = x instanceof C
if (flag)
if (flag) { ... }
The peephole optimization in OPT_DynamicTypeCheck isn't
checking to see if the register defined by the instanceof
operation has multiple uses before deciding to expand it in
a way that results in the register not being defined to have
a value.
As noted in OPT_DynamicTypeCheck, what we really should be
doing is having OPT_Simple which has def/use chains built
look to transform the result of an instanceof whose only use
is an IFCMP into an IF_INSTANCEOF operator. Then
OPT_DynamicTypeCheck could simply apply this optimization to
IF_INSTANCEOF and not try to do its own peephole optimization.
Alternatively (instead of IF_INSTANCEOF) it might be cleaner
(require less changes to branch optimizations, etc) to add
an INSTANCEOF and NOT_INSTANCEOF cases to
OPT_ConditionOperand and rewrite
t100 = x instanceof C
ifcmp (t100 != 0)
to
ifcmp (x instanceof C)