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/compiler/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/base/division-by-constant.h" | 7 #include "src/base/division-by-constant.h" |
8 #include "src/base/ieee754.h" | 8 #include "src/base/ieee754.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 } | 1176 } |
1177 } | 1177 } |
1178 TRACED_FORRANGE(int32_t, shift, 1, 30) { | 1178 TRACED_FORRANGE(int32_t, shift, 1, 30) { |
1179 Reduction const r = | 1179 Reduction const r = |
1180 Reduce(graph()->NewNode(machine()->Int32Mod(), p0, | 1180 Reduce(graph()->NewNode(machine()->Int32Mod(), p0, |
1181 Int32Constant(1 << shift), graph()->start())); | 1181 Int32Constant(1 << shift), graph()->start())); |
1182 int32_t const mask = (1 << shift) - 1; | 1182 int32_t const mask = (1 << shift) - 1; |
1183 ASSERT_TRUE(r.Changed()); | 1183 ASSERT_TRUE(r.Changed()); |
1184 EXPECT_THAT( | 1184 EXPECT_THAT( |
1185 r.replacement(), | 1185 r.replacement(), |
1186 IsSelect(MachineRepresentation::kWord32, | 1186 IsPhi( |
1187 IsInt32LessThan(p0, IsInt32Constant(0)), | 1187 MachineRepresentation::kWord32, |
1188 IsInt32Sub(IsInt32Constant(0), | 1188 IsInt32Sub(IsInt32Constant(0), |
1189 IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), | 1189 IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), |
1190 IsInt32Constant(mask))), | 1190 IsInt32Constant(mask))), |
1191 IsWord32And(p0, IsInt32Constant(mask)))); | 1191 IsWord32And(p0, IsInt32Constant(mask)), |
| 1192 IsMerge(IsIfTrue(IsBranch(IsInt32LessThan(p0, IsInt32Constant(0)), |
| 1193 graph()->start())), |
| 1194 IsIfFalse(IsBranch(IsInt32LessThan(p0, IsInt32Constant(0)), |
| 1195 graph()->start()))))); |
1192 } | 1196 } |
1193 TRACED_FORRANGE(int32_t, shift, 1, 31) { | 1197 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
1194 Reduction const r = Reduce(graph()->NewNode( | 1198 Reduction const r = Reduce(graph()->NewNode( |
1195 machine()->Int32Mod(), p0, | 1199 machine()->Int32Mod(), p0, |
1196 Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift), | 1200 Uint32Constant(bit_cast<uint32_t, int32_t>(-1) << shift), |
1197 graph()->start())); | 1201 graph()->start())); |
1198 int32_t const mask = bit_cast<int32_t, uint32_t>((1U << shift) - 1); | 1202 int32_t const mask = bit_cast<int32_t, uint32_t>((1U << shift) - 1); |
1199 ASSERT_TRUE(r.Changed()); | 1203 ASSERT_TRUE(r.Changed()); |
1200 EXPECT_THAT( | 1204 EXPECT_THAT( |
1201 r.replacement(), | 1205 r.replacement(), |
1202 IsSelect(MachineRepresentation::kWord32, | 1206 IsPhi( |
1203 IsInt32LessThan(p0, IsInt32Constant(0)), | 1207 MachineRepresentation::kWord32, |
1204 IsInt32Sub(IsInt32Constant(0), | 1208 IsInt32Sub(IsInt32Constant(0), |
1205 IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), | 1209 IsWord32And(IsInt32Sub(IsInt32Constant(0), p0), |
1206 IsInt32Constant(mask))), | 1210 IsInt32Constant(mask))), |
1207 IsWord32And(p0, IsInt32Constant(mask)))); | 1211 IsWord32And(p0, IsInt32Constant(mask)), |
| 1212 IsMerge(IsIfTrue(IsBranch(IsInt32LessThan(p0, IsInt32Constant(0)), |
| 1213 graph()->start())), |
| 1214 IsIfFalse(IsBranch(IsInt32LessThan(p0, IsInt32Constant(0)), |
| 1215 graph()->start()))))); |
1208 } | 1216 } |
1209 TRACED_FOREACH(int32_t, divisor, kInt32Values) { | 1217 TRACED_FOREACH(int32_t, divisor, kInt32Values) { |
1210 if (divisor == 0 || base::bits::IsPowerOfTwo32(Abs(divisor))) continue; | 1218 if (divisor == 0 || base::bits::IsPowerOfTwo32(Abs(divisor))) continue; |
1211 Reduction const r = Reduce(graph()->NewNode( | 1219 Reduction const r = Reduce(graph()->NewNode( |
1212 machine()->Int32Mod(), p0, Int32Constant(divisor), graph()->start())); | 1220 machine()->Int32Mod(), p0, Int32Constant(divisor), graph()->start())); |
1213 ASSERT_TRUE(r.Changed()); | 1221 ASSERT_TRUE(r.Changed()); |
1214 EXPECT_THAT(r.replacement(), | 1222 EXPECT_THAT(r.replacement(), |
1215 IsInt32Sub(p0, IsInt32Mul(IsTruncatingDiv(p0, Abs(divisor)), | 1223 IsInt32Sub(p0, IsInt32Mul(IsTruncatingDiv(p0, Abs(divisor)), |
1216 IsInt32Constant(Abs(divisor))))); | 1224 IsInt32Constant(Abs(divisor))))); |
1217 } | 1225 } |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 Reduction r = Reduce(node); | 2177 Reduction r = Reduce(node); |
2170 ASSERT_TRUE(r.Changed()); | 2178 ASSERT_TRUE(r.Changed()); |
2171 EXPECT_THAT(r.replacement(), | 2179 EXPECT_THAT(r.replacement(), |
2172 IsStore(rep, base, index, value, effect, control)); | 2180 IsStore(rep, base, index, value, effect, control)); |
2173 } | 2181 } |
2174 } | 2182 } |
2175 | 2183 |
2176 } // namespace compiler | 2184 } // namespace compiler |
2177 } // namespace internal | 2185 } // namespace internal |
2178 } // namespace v8 | 2186 } // namespace v8 |
OLD | NEW |