Incorrect result of the "mul-long by 1" operation

ART handles "mul-long by 1" as a special case and try to alloc a new pair
of regs through the EvalLocWide method and then put there the multiplicand
through the StoreValueWide method. But in case when both multiplicand and
multiplier are constants, it will not place correct values in a new reg pair
and result of calculations will be incorrect. The new solution uses the
only StoreValueWide method.

Change-Id: I3d6947737c92c5a12f2840003b17a427e31d288f
Signed-off-by: Alexei Zavjalov <alexei.zavjalov@intel.com>
diff --git a/compiler/dex/quick/gen_loadstore.cc b/compiler/dex/quick/gen_loadstore.cc
index f7c2821..7aef93e 100644
--- a/compiler/dex/quick/gen_loadstore.cc
+++ b/compiler/dex/quick/gen_loadstore.cc
@@ -240,6 +240,8 @@
   DCHECK_EQ(IsFpReg(rl_src.low_reg), IsFpReg(rl_src.high_reg));
   DCHECK(rl_dest.wide);
   DCHECK(rl_src.wide);
+  rl_src = UpdateLocWide(rl_src);
+  rl_dest = UpdateLocWide(rl_dest);
   if (rl_src.location == kLocPhysReg) {
     if (IsLive(rl_src.low_reg) ||
         IsLive(rl_src.high_reg) ||
diff --git a/compiler/dex/quick/x86/int_x86.cc b/compiler/dex/quick/x86/int_x86.cc
index 5f04b7d..6c3ba4e 100644
--- a/compiler/dex/quick/x86/int_x86.cc
+++ b/compiler/dex/quick/x86/int_x86.cc
@@ -923,7 +923,6 @@
       StoreValueWide(rl_dest, rl_result);
       return;
     } else if (val == 1) {
-      rl_src1 = EvalLocWide(rl_src1, kCoreReg, true);
       StoreValueWide(rl_dest, rl_src1);
       return;
     } else if (val == 2) {
diff --git a/test/083-compiler-regressions/expected.txt b/test/083-compiler-regressions/expected.txt
index 57065ef..541f0f8 100644
--- a/test/083-compiler-regressions/expected.txt
+++ b/test/083-compiler-regressions/expected.txt
@@ -4,6 +4,7 @@
 b5884080 passes
 largeFrame passes
 largeFrameFloat passes
+mulBy1Test passes
 getterSetterTest passes
 identityTest passes
 wideGetterSetterTest passes
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index 6829388..81f5b14 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -35,6 +35,7 @@
         b5884080Test();
         largeFrameTest();
         largeFrameTestFloat();
+        mulBy1Test();
         getterSetterTest();
         identityTest();
         wideGetterSetterTest();
@@ -161,6 +162,19 @@
         }
     }
 
+    static void mulBy1Test() {
+        long res;
+        long j = 1;
+        res = 1 * j + j;
+        if (res == 2L) {
+            System.out.println("mulBy1Test passes");
+        }
+        else {
+            System.out.println("mulBy1Test fails: " + res +
+                               " (expecting 2)");
+        }
+    }
+
     static void b2296099Test() throws Exception {
        int x = -1190771042;
        int dist = 360530809;