diff options
| -rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 8 | ||||
| -rw-r--r-- | test/571-irreducible-loop/expected.txt | 1 | ||||
| -rw-r--r-- | test/571-irreducible-loop/info.txt | 2 | ||||
| -rw-r--r-- | test/571-irreducible-loop/smali/IrreducibleLoop.smali | 47 | ||||
| -rw-r--r-- | test/571-irreducible-loop/src/Main.java | 29 |
5 files changed, 87 insertions, 0 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 18d70daf47..da054baa1c 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -2688,6 +2688,8 @@ void LocationsBuilderX86::VisitAdd(HAdd* add) { locations->SetInAt(0, Location::RequiresFpuRegister()); if (add->InputAt(1)->IsX86LoadFromConstantTable()) { DCHECK(add->InputAt(1)->IsEmittedAtUseSite()); + } else if (add->InputAt(1)->IsConstant()) { + locations->SetInAt(1, Location::RequiresFpuRegister()); } else { locations->SetInAt(1, Location::Any()); } @@ -2804,6 +2806,8 @@ void LocationsBuilderX86::VisitSub(HSub* sub) { locations->SetInAt(0, Location::RequiresFpuRegister()); if (sub->InputAt(1)->IsX86LoadFromConstantTable()) { DCHECK(sub->InputAt(1)->IsEmittedAtUseSite()); + } else if (sub->InputAt(1)->IsConstant()) { + locations->SetInAt(1, Location::RequiresFpuRegister()); } else { locations->SetInAt(1, Location::Any()); } @@ -2918,6 +2922,8 @@ void LocationsBuilderX86::VisitMul(HMul* mul) { locations->SetInAt(0, Location::RequiresFpuRegister()); if (mul->InputAt(1)->IsX86LoadFromConstantTable()) { DCHECK(mul->InputAt(1)->IsEmittedAtUseSite()); + } else if (mul->InputAt(1)->IsConstant()) { + locations->SetInAt(1, Location::RequiresFpuRegister()); } else { locations->SetInAt(1, Location::Any()); } @@ -3415,6 +3421,8 @@ void LocationsBuilderX86::VisitDiv(HDiv* div) { locations->SetInAt(0, Location::RequiresFpuRegister()); if (div->InputAt(1)->IsX86LoadFromConstantTable()) { DCHECK(div->InputAt(1)->IsEmittedAtUseSite()); + } else if (div->InputAt(1)->IsConstant()) { + locations->SetInAt(1, Location::RequiresFpuRegister()); } else { locations->SetInAt(1, Location::Any()); } diff --git a/test/571-irreducible-loop/expected.txt b/test/571-irreducible-loop/expected.txt new file mode 100644 index 0000000000..3a71184143 --- /dev/null +++ b/test/571-irreducible-loop/expected.txt @@ -0,0 +1 @@ +5.9E-44 diff --git a/test/571-irreducible-loop/info.txt b/test/571-irreducible-loop/info.txt new file mode 100644 index 0000000000..1e0dd02284 --- /dev/null +++ b/test/571-irreducible-loop/info.txt @@ -0,0 +1,2 @@ +Regression test for optimizing in the presence of +an irreducible loop. diff --git a/test/571-irreducible-loop/smali/IrreducibleLoop.smali b/test/571-irreducible-loop/smali/IrreducibleLoop.smali new file mode 100644 index 0000000000..737a18b5cb --- /dev/null +++ b/test/571-irreducible-loop/smali/IrreducibleLoop.smali @@ -0,0 +1,47 @@ +# Copyright (C) 2016 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 LIrreducibleLoop; + +.super Ljava/lang/Object; + +# Check that on x86 we don't crash because irreducible loops +# disabled the constant pool optimization. +.method public static test1(IF)F + .registers 5 + const/16 v0, 1 + const/16 v1, 42 + + if-nez p0, :loop_entry + goto :other_loop_pre_entry + + # The then part: beginning of the irreducible loop. + :loop_entry + if-eqz p0, :exit + add-float v2, p1, v1 + sub-float v2, v2, v1 + div-float v2, v2, v1 + mul-float v2, v2, v1 + :other_loop_entry + sub-int p0, p0, v0 + goto :loop_entry + + # The other block branching to the irreducible loop. + # In that block, v4 has no live range. + :other_loop_pre_entry + goto :other_loop_entry + + :exit + return v1 +.end method diff --git a/test/571-irreducible-loop/src/Main.java b/test/571-irreducible-loop/src/Main.java new file mode 100644 index 0000000000..ff22f6720f --- /dev/null +++ b/test/571-irreducible-loop/src/Main.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2016 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. + */ + +import java.lang.reflect.Method; + +public class Main { + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String[] args) throws Exception { + Class<?> c = Class.forName("IrreducibleLoop"); + Method m = c.getMethod("test1", int.class, float.class); + Object[] arguments = { 42, 31.0f }; + System.out.println(m.invoke(null, arguments)); + } +} |