diff options
| author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-24 14:34:19 +0000 |
|---|---|---|
| committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-24 14:34:19 +0000 |
| commit | 70f808f2d801dabff2152c0f11abc16e56f16300 (patch) | |
| tree | e0a0cb7ef097bd8ede15923f72e3c49733beef0a /gcc/java/jcf-write.c | |
| parent | 0da26c2ee4178bda0d62eb204ff527404d528c0a (diff) | |
| download | ppe42-gcc-70f808f2d801dabff2152c0f11abc16e56f16300.tar.gz ppe42-gcc-70f808f2d801dabff2152c0f11abc16e56f16300.zip | |
PR java/19295
* jcf-write.c (generate_bytecode_insns): Conversions between
integer types of the same precision shouldn't generate widening
or narrowing conversion bytecodes.
* testsuite/libjava.compile/PR19295.java: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94162 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/jcf-write.c')
| -rw-r--r-- | gcc/java/jcf-write.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 8b6dc7de328..da8c6c99870 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -2260,40 +2260,48 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state) } else /* Convert numeric types. */ { - int wide_src = TYPE_PRECISION (src_type) > 32; - int wide_dst = TYPE_PRECISION (dst_type) > 32; - NOTE_POP (1 + wide_src); - RESERVE (1); + int src_prec = TYPE_PRECISION (src_type); + int dst_prec = TYPE_PRECISION (dst_type); + int wide_src = src_prec > 32; + int wide_dst = dst_prec > 32; if (TREE_CODE (dst_type) == REAL_TYPE) { + NOTE_POP (1 + wide_src); + RESERVE (1); if (TREE_CODE (src_type) == REAL_TYPE) OP1 (wide_dst ? OPCODE_f2d : OPCODE_d2f); - else if (TYPE_PRECISION (src_type) == 64) + else if (src_prec == 64) OP1 (OPCODE_l2f + wide_dst); else OP1 (OPCODE_i2f + wide_dst); + NOTE_PUSH (1 + wide_dst); } - else /* Convert to integral type. */ + /* Convert to integral type (but ignore non-widening + and non-narrowing integer type conversions). */ + else if (TREE_CODE (src_type) == REAL_TYPE + || src_prec != dst_prec) { + NOTE_POP (1 + wide_src); + RESERVE (1); if (TREE_CODE (src_type) == REAL_TYPE) OP1 (OPCODE_f2i + wide_dst + 3 * wide_src); else if (wide_dst) OP1 (OPCODE_i2l); else if (wide_src) OP1 (OPCODE_l2i); - if (TYPE_PRECISION (dst_type) < 32) + if (dst_prec < 32) { RESERVE (1); /* Already converted to int, if needed. */ - if (TYPE_PRECISION (dst_type) <= 8) + if (dst_prec <= 8) OP1 (OPCODE_i2b); else if (TYPE_UNSIGNED (dst_type)) OP1 (OPCODE_i2c); else OP1 (OPCODE_i2s); } + NOTE_PUSH (1 + wide_dst); } - NOTE_PUSH (1 + wide_dst); } } break; |

