OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 return VisitFloat32Compare(selector, value, cont); | 1935 return VisitFloat32Compare(selector, value, cont); |
1936 case IrOpcode::kFloat32LessThan: | 1936 case IrOpcode::kFloat32LessThan: |
1937 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThan); | 1937 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThan); |
1938 return VisitFloat32Compare(selector, value, cont); | 1938 return VisitFloat32Compare(selector, value, cont); |
1939 case IrOpcode::kFloat32LessThanOrEqual: | 1939 case IrOpcode::kFloat32LessThanOrEqual: |
1940 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); | 1940 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); |
1941 return VisitFloat32Compare(selector, value, cont); | 1941 return VisitFloat32Compare(selector, value, cont); |
1942 case IrOpcode::kFloat64Equal: | 1942 case IrOpcode::kFloat64Equal: |
1943 cont->OverwriteAndNegateIfEqual(kUnorderedEqual); | 1943 cont->OverwriteAndNegateIfEqual(kUnorderedEqual); |
1944 return VisitFloat64Compare(selector, value, cont); | 1944 return VisitFloat64Compare(selector, value, cont); |
1945 case IrOpcode::kFloat64LessThan: | 1945 case IrOpcode::kFloat64LessThan: { |
| 1946 Float64BinopMatcher m(value); |
| 1947 if (m.left().Is(0.0) && m.right().IsFloat64Abs()) { |
| 1948 // This matches the pattern |
| 1949 // |
| 1950 // Float64LessThan(#0.0, Float64Abs(x)) |
| 1951 // |
| 1952 // which TurboFan generates for NumberToBoolean in the general case, |
| 1953 // and which evaluates to false if x is 0, -0 or NaN. We can compile |
| 1954 // this to a simple (v)ucomisd using not_equal flags condition, which |
| 1955 // avoids the costly Float64Abs. |
| 1956 cont->OverwriteAndNegateIfEqual(kNotEqual); |
| 1957 InstructionCode const opcode = |
| 1958 selector->IsSupported(AVX) ? kAVXFloat64Cmp : kSSEFloat64Cmp; |
| 1959 return VisitCompare(selector, opcode, m.left().node(), |
| 1960 m.right().InputAt(0), cont, false); |
| 1961 } |
1946 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThan); | 1962 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThan); |
1947 return VisitFloat64Compare(selector, value, cont); | 1963 return VisitFloat64Compare(selector, value, cont); |
| 1964 } |
1948 case IrOpcode::kFloat64LessThanOrEqual: | 1965 case IrOpcode::kFloat64LessThanOrEqual: |
1949 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); | 1966 cont->OverwriteAndNegateIfEqual(kUnsignedGreaterThanOrEqual); |
1950 return VisitFloat64Compare(selector, value, cont); | 1967 return VisitFloat64Compare(selector, value, cont); |
1951 case IrOpcode::kProjection: | 1968 case IrOpcode::kProjection: |
1952 // Check if this is the overflow output projection of an | 1969 // Check if this is the overflow output projection of an |
1953 // <Operation>WithOverflow node. | 1970 // <Operation>WithOverflow node. |
1954 if (ProjectionIndexOf(value->op()) == 1u) { | 1971 if (ProjectionIndexOf(value->op()) == 1u) { |
1955 // We cannot combine the <Operation>WithOverflow with this branch | 1972 // We cannot combine the <Operation>WithOverflow with this branch |
1956 // unless the 0th projection (the use of the actual value of the | 1973 // unless the 0th projection (the use of the actual value of the |
1957 // <Operation> is either nullptr, which means there's no use of the | 1974 // <Operation> is either nullptr, which means there's no use of the |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 FlagsContinuation::ForSet(kUnsignedGreaterThanOrEqual, node); | 2215 FlagsContinuation::ForSet(kUnsignedGreaterThanOrEqual, node); |
2199 VisitFloat32Compare(this, node, &cont); | 2216 VisitFloat32Compare(this, node, &cont); |
2200 } | 2217 } |
2201 | 2218 |
2202 | 2219 |
2203 void InstructionSelector::VisitFloat64Equal(Node* node) { | 2220 void InstructionSelector::VisitFloat64Equal(Node* node) { |
2204 FlagsContinuation cont = FlagsContinuation::ForSet(kUnorderedEqual, node); | 2221 FlagsContinuation cont = FlagsContinuation::ForSet(kUnorderedEqual, node); |
2205 VisitFloat64Compare(this, node, &cont); | 2222 VisitFloat64Compare(this, node, &cont); |
2206 } | 2223 } |
2207 | 2224 |
2208 | |
2209 void InstructionSelector::VisitFloat64LessThan(Node* node) { | 2225 void InstructionSelector::VisitFloat64LessThan(Node* node) { |
| 2226 Float64BinopMatcher m(node); |
| 2227 if (m.left().Is(0.0) && m.right().IsFloat64Abs()) { |
| 2228 // This matches the pattern |
| 2229 // |
| 2230 // Float64LessThan(#0.0, Float64Abs(x)) |
| 2231 // |
| 2232 // which TurboFan generates for NumberToBoolean in the general case, |
| 2233 // and which evaluates to false if x is 0, -0 or NaN. We can compile |
| 2234 // this to a simple (v)ucomisd using not_equal flags condition, which |
| 2235 // avoids the costly Float64Abs. |
| 2236 FlagsContinuation cont = FlagsContinuation::ForSet(kNotEqual, node); |
| 2237 InstructionCode const opcode = |
| 2238 IsSupported(AVX) ? kAVXFloat64Cmp : kSSEFloat64Cmp; |
| 2239 return VisitCompare(this, opcode, m.left().node(), m.right().InputAt(0), |
| 2240 &cont, false); |
| 2241 } |
2210 FlagsContinuation cont = | 2242 FlagsContinuation cont = |
2211 FlagsContinuation::ForSet(kUnsignedGreaterThan, node); | 2243 FlagsContinuation::ForSet(kUnsignedGreaterThan, node); |
2212 VisitFloat64Compare(this, node, &cont); | 2244 VisitFloat64Compare(this, node, &cont); |
2213 } | 2245 } |
2214 | 2246 |
2215 | |
2216 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { | 2247 void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { |
2217 FlagsContinuation cont = | 2248 FlagsContinuation cont = |
2218 FlagsContinuation::ForSet(kUnsignedGreaterThanOrEqual, node); | 2249 FlagsContinuation::ForSet(kUnsignedGreaterThanOrEqual, node); |
2219 VisitFloat64Compare(this, node, &cont); | 2250 VisitFloat64Compare(this, node, &cont); |
2220 } | 2251 } |
2221 | 2252 |
2222 | 2253 |
2223 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { | 2254 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { |
2224 X64OperandGenerator g(this); | 2255 X64OperandGenerator g(this); |
2225 Emit(kSSEFloat64ExtractLowWord32, g.DefineAsRegister(node), | 2256 Emit(kSSEFloat64ExtractLowWord32, g.DefineAsRegister(node), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 // static | 2377 // static |
2347 MachineOperatorBuilder::AlignmentRequirements | 2378 MachineOperatorBuilder::AlignmentRequirements |
2348 InstructionSelector::AlignmentRequirements() { | 2379 InstructionSelector::AlignmentRequirements() { |
2349 return MachineOperatorBuilder::AlignmentRequirements:: | 2380 return MachineOperatorBuilder::AlignmentRequirements:: |
2350 FullUnalignedAccessSupport(); | 2381 FullUnalignedAccessSupport(); |
2351 } | 2382 } |
2352 | 2383 |
2353 } // namespace compiler | 2384 } // namespace compiler |
2354 } // namespace internal | 2385 } // namespace internal |
2355 } // namespace v8 | 2386 } // namespace v8 |
OLD | NEW |