# HG changeset patch # User Roland Schatz # Date 1413447689 -7200 # Node ID 45d7b2c7029d5010542889c5bb19d6c6e5a5b5aa # Parent cdd0b5d3d9bf1d6556fd1765ee15b55b55acb073 Use correct kind for narrow int constants. diff -r cdd0b5d3d9bf -r 45d7b2c7029d graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Thu Oct 16 10:06:27 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Thu Oct 16 10:21:29 2014 +0200 @@ -272,10 +272,19 @@ */ public static Constant forPrimitiveInt(int bits, long i) { assert bits <= 64; - if (bits > 32) { - return new PrimitiveConstant(Kind.Long, i); - } else { - return new PrimitiveConstant(Kind.Int, (int) i); + switch (bits) { + case 1: + return forBoolean(i != 0); + case 8: + return forByte((byte) i); + case 16: + return forShort((short) i); + case 32: + return forInt((int) i); + case 64: + return forLong(i); + default: + throw new IllegalArgumentException("unsupported integer width: " + bits); } }