diff options
| author | 2015-10-01 14:16:40 +0000 | |
|---|---|---|
| committer | 2015-10-01 14:16:40 +0000 | |
| commit | b3577f0ab8f1765d3554f575d99adbc65bfaf1b6 (patch) | |
| tree | da686105f2382f4c4db58bfb1429ff544bbbd694 | |
| parent | 9664c08964c7db92151335023c6ea595f75f4033 (diff) | |
| parent | 9f389d4d00f34a6c76e55b183b8c3d106e314261 (diff) | |
Merge "ART: Fix a static_cast int32_t -> uint64_t bug."
| -rw-r--r-- | compiler/optimizing/nodes.h | 4 | ||||
| -rw-r--r-- | test/535-regression-const-val/expected.txt | 0 | ||||
| -rw-r--r-- | test/535-regression-const-val/info.txt | 2 | ||||
| -rw-r--r-- | test/535-regression-const-val/smali/TestCase.smali | 36 | ||||
| -rw-r--r-- | test/535-regression-const-val/src/Main.java | 22 |
5 files changed, 63 insertions, 1 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 84bde8ea5f..d52f5927de 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2239,7 +2239,9 @@ class HIntConstant : public HConstant { public: int32_t GetValue() const { return value_; } - uint64_t GetValueAsUint64() const OVERRIDE { return static_cast<uint64_t>(value_); } + uint64_t GetValueAsUint64() const OVERRIDE { + return static_cast<uint64_t>(static_cast<uint32_t>(value_)); + } bool InstructionDataEquals(HInstruction* other) const OVERRIDE { DCHECK(other->IsIntConstant()); diff --git a/test/535-regression-const-val/expected.txt b/test/535-regression-const-val/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/535-regression-const-val/expected.txt diff --git a/test/535-regression-const-val/info.txt b/test/535-regression-const-val/info.txt new file mode 100644 index 0000000000..ea3e67b79c --- /dev/null +++ b/test/535-regression-const-val/info.txt @@ -0,0 +1,2 @@ +Test a regression where SsaChecker would fail comparing raw value of IntConstant +vs FloatConstant due to a static_cast sign extend. diff --git a/test/535-regression-const-val/smali/TestCase.smali b/test/535-regression-const-val/smali/TestCase.smali new file mode 100644 index 0000000000..f42f1738b5 --- /dev/null +++ b/test/535-regression-const-val/smali/TestCase.smali @@ -0,0 +1,36 @@ +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.class public LTestCase; +.super Ljava/lang/Object; + +.method public static testCase(ZZ)I + .registers 5 + + # Create Phi [ 0.0f, -0.25f ]. + # Binary representation of -0.25f has the most significant bit set. + if-eqz p0, :else + :then + const v0, 0x0 + goto :merge + :else + const/high16 v0, 0xbe800000 + :merge + + # Now use as either float or int. + if-eqz p1, :return + float-to-int v0, v0 + :return + return v0 +.end method diff --git a/test/535-regression-const-val/src/Main.java b/test/535-regression-const-val/src/Main.java new file mode 100644 index 0000000000..858770f508 --- /dev/null +++ b/test/535-regression-const-val/src/Main.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class Main { + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String[] args) {} +} |