diff src/share/vm/opto/mulnode.cpp @ 897:52898b0c43e9

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
author twisti
date Tue, 28 Jul 2009 09:02:30 +0200
parents 18a08a7e16b5
children c18cbe5936b8
line wrap: on
line diff
--- a/src/share/vm/opto/mulnode.cpp	Mon Jul 27 06:15:29 2009 -0700
+++ b/src/share/vm/opto/mulnode.cpp	Tue Jul 28 09:02:30 2009 +0200
@@ -608,16 +608,14 @@
   }
 
   // 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)) {
-      Node* andi = new (phase->C, 3) AndINode(in1->in(1), phase->intcon(mask));
-      andi = phase->transform(andi);
-      return new (phase->C, 2) ConvI2LNode(andi);
-    }
+  // 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!