Mercurial > hg > truffle
changeset 19350:af4a778b3ce6
Allow WordCastNode to be reduced to constant node (for constant input)
author | Paul Woegerer <paul.woegerer@oracle.com> |
---|---|
date | Fri, 13 Feb 2015 11:39:05 +0100 |
parents | ff5b7f5063a3 |
children | 78510d27786b |
files | graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Fri Feb 13 11:33:00 2015 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Fri Feb 13 11:39:05 2015 +0100 @@ -65,6 +65,17 @@ /* If the cast is unused, it can be eliminated. */ return input; } + + assert !stamp().isCompatible(input.stamp()); + if (input.isConstant()) { + /* Null pointers are uncritical for GC, so they can be constant folded. */ + if (input.asJavaConstant().isNull()) { + return ConstantNode.forIntegerStamp(stamp(), 0); + } else if (input.asJavaConstant().getKind().isNumericInteger() && input.asJavaConstant().asLong() == 0) { + return ConstantNode.forConstant(stamp(), JavaConstant.NULL_POINTER, tool.getMetaAccess()); + } + } + return this; }