提交 98129bcf 编写于 作者: T twisti

6863155: Server compiler generates incorrect code (x86, long, bitshift, bitmask)

Summary: Code compiled with server compiler generates an incorrect result.
Reviewed-by: cfang, never, kvn
上级 71606488
......@@ -608,17 +608,15 @@ Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
// Are we masking a long that was converted from an int with a mask
// that fits in 32-bits? Commute them and use an AndINode.
if (op == Op_ConvI2L && (mask & CONST64(0xFFFFFFFF00000000)) == 0) {
// If we are doing an UI2L conversion (i.e. the mask is
// 0x00000000FFFFFFFF) we cannot convert the AndL to an AndI
// because the AndI would be optimized away later in Identity.
if (mask != CONST64(0x00000000FFFFFFFF)) {
// that fits in 32-bits? Commute them and use an AndINode. Don't
// convert masks which would cause a sign extension of the integer
// value. This check includes UI2L masks (0x00000000FFFFFFFF) which
// would be optimized away later in Identity.
if (op == Op_ConvI2L && (mask & CONST64(0xFFFFFFFF80000000)) == 0) {
Node* andi = new (phase->C, 3) AndINode(in1->in(1), phase->intcon(mask));
andi = phase->transform(andi);
return new (phase->C, 2) ConvI2LNode(andi);
}
}
// Masking off sign bits? Dont make them!
if (op == Op_RShiftL) {
......
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6863155
* @summary Server compiler generates incorrect code (x86, long, bitshift, bitmask)
*
* @run main/othervm -Xcomp -XX:CompileOnly=Test6863155.test Test6863155
*/
public class Test6863155 {
private static long test(byte b) {
return b << 24 & 0xff000000L;
}
public static void main(String... args) {
long result = test((byte) 0xc2);
long expected = 0x00000000c2000000L;
if (result != expected)
throw new InternalError(Long.toHexString(result) + " != " + Long.toHexString(expected));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册