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 "src/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 } | 1869 } |
1870 } | 1870 } |
1871 | 1871 |
1872 VisitWordCompare(selector, node, opcode, cont); | 1872 VisitWordCompare(selector, node, opcode, cont); |
1873 } | 1873 } |
1874 | 1874 |
1875 | 1875 |
1876 // Shared routine for word comparisons against zero. | 1876 // Shared routine for word comparisons against zero. |
1877 void VisitWordCompareZero(InstructionSelector* selector, Node* user, | 1877 void VisitWordCompareZero(InstructionSelector* selector, Node* user, |
1878 Node* value, FlagsContinuation* cont) { | 1878 Node* value, FlagsContinuation* cont) { |
1879 while (selector->CanCover(user, value)) { | 1879 // Try to combine with comparisons against 0 by simply inverting the branch. |
| 1880 while (value->opcode() == IrOpcode::kWord32Equal && |
| 1881 selector->CanCover(user, value)) { |
| 1882 Int32BinopMatcher m(value); |
| 1883 if (!m.right().Is(0)) break; |
| 1884 |
| 1885 user = value; |
| 1886 value = m.left().node(); |
| 1887 cont->Negate(); |
| 1888 } |
| 1889 |
| 1890 if (selector->CanCover(user, value)) { |
1880 switch (value->opcode()) { | 1891 switch (value->opcode()) { |
1881 case IrOpcode::kWord32Equal: { | 1892 case IrOpcode::kWord32Equal: |
1882 // Combine with comparisons against 0 by simply inverting the | |
1883 // continuation. | |
1884 Int32BinopMatcher m(value); | |
1885 if (m.right().Is(0)) { | |
1886 user = value; | |
1887 value = m.left().node(); | |
1888 cont->Negate(); | |
1889 continue; | |
1890 } | |
1891 cont->OverwriteAndNegateIfEqual(kEqual); | 1893 cont->OverwriteAndNegateIfEqual(kEqual); |
1892 return VisitWordCompare(selector, value, cont); | 1894 return VisitWordCompare(selector, value, cont); |
1893 } | |
1894 case IrOpcode::kInt32LessThan: | 1895 case IrOpcode::kInt32LessThan: |
1895 cont->OverwriteAndNegateIfEqual(kSignedLessThan); | 1896 cont->OverwriteAndNegateIfEqual(kSignedLessThan); |
1896 return VisitWordCompare(selector, value, cont); | 1897 return VisitWordCompare(selector, value, cont); |
1897 case IrOpcode::kInt32LessThanOrEqual: | 1898 case IrOpcode::kInt32LessThanOrEqual: |
1898 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); | 1899 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); |
1899 return VisitWordCompare(selector, value, cont); | 1900 return VisitWordCompare(selector, value, cont); |
1900 case IrOpcode::kUint32LessThan: | 1901 case IrOpcode::kUint32LessThan: |
1901 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); | 1902 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); |
1902 return VisitWordCompare(selector, value, cont); | 1903 return VisitWordCompare(selector, value, cont); |
1903 case IrOpcode::kUint32LessThanOrEqual: | 1904 case IrOpcode::kUint32LessThanOrEqual: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 return VisitShift(selector, value, TryMatchASR, cont); | 1968 return VisitShift(selector, value, TryMatchASR, cont); |
1968 case IrOpcode::kWord32Shl: | 1969 case IrOpcode::kWord32Shl: |
1969 return VisitShift(selector, value, TryMatchLSL, cont); | 1970 return VisitShift(selector, value, TryMatchLSL, cont); |
1970 case IrOpcode::kWord32Shr: | 1971 case IrOpcode::kWord32Shr: |
1971 return VisitShift(selector, value, TryMatchLSR, cont); | 1972 return VisitShift(selector, value, TryMatchLSR, cont); |
1972 case IrOpcode::kWord32Ror: | 1973 case IrOpcode::kWord32Ror: |
1973 return VisitShift(selector, value, TryMatchROR, cont); | 1974 return VisitShift(selector, value, TryMatchROR, cont); |
1974 default: | 1975 default: |
1975 break; | 1976 break; |
1976 } | 1977 } |
1977 break; | |
1978 } | 1978 } |
1979 | 1979 |
1980 if (user->opcode() == IrOpcode::kWord32Equal) { | 1980 if (user->opcode() == IrOpcode::kWord32Equal) { |
1981 return VisitWordCompare(selector, user, cont); | 1981 return VisitWordCompare(selector, user, cont); |
1982 } | 1982 } |
1983 | 1983 |
1984 // Continuation could not be combined with a compare, emit compare against 0. | 1984 // Continuation could not be combined with a compare, emit compare against 0. |
1985 ArmOperandGenerator g(selector); | 1985 ArmOperandGenerator g(selector); |
1986 InstructionCode const opcode = | 1986 InstructionCode const opcode = |
1987 cont->Encode(kArmTst) | AddressingModeField::encode(kMode_Operand2_R); | 1987 cont->Encode(kArmTst) | AddressingModeField::encode(kMode_Operand2_R); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); | 2282 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); |
2283 req_aligned[0] = MachineType::Float32(); | 2283 req_aligned[0] = MachineType::Float32(); |
2284 req_aligned[1] = MachineType::Float64(); | 2284 req_aligned[1] = MachineType::Float64(); |
2285 return MachineOperatorBuilder::AlignmentRequirements:: | 2285 return MachineOperatorBuilder::AlignmentRequirements:: |
2286 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); | 2286 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); |
2287 } | 2287 } |
2288 | 2288 |
2289 } // namespace compiler | 2289 } // namespace compiler |
2290 } // namespace internal | 2290 } // namespace internal |
2291 } // namespace v8 | 2291 } // namespace v8 |
OLD | NEW |