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/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/base/division-by-constant.h" | 6 #include "src/base/division-by-constant.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 effect, control); | 1125 effect, control); |
1126 | 1126 |
1127 Reduction r = Reduce(node); | 1127 Reduction r = Reduce(node); |
1128 ASSERT_TRUE(r.Changed()); | 1128 ASSERT_TRUE(r.Changed()); |
1129 EXPECT_THAT(r.replacement(), | 1129 EXPECT_THAT(r.replacement(), |
1130 IsStore(rep, base, index, value, effect, control)); | 1130 IsStore(rep, base, index, value, effect, control)); |
1131 } | 1131 } |
1132 } | 1132 } |
1133 | 1133 |
1134 | 1134 |
| 1135 TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32SarAndWord32Shl) { |
| 1136 const StoreRepresentation rep(kRepWord8, kNoWriteBarrier); |
| 1137 Node* const base = Parameter(0); |
| 1138 Node* const index = Parameter(1); |
| 1139 Node* const value = Parameter(2); |
| 1140 Node* const effect = graph()->start(); |
| 1141 Node* const control = graph()->start(); |
| 1142 TRACED_FORRANGE(int32_t, x, 1, 24) { |
| 1143 Node* const node = graph()->NewNode( |
| 1144 machine()->Store(rep), base, index, |
| 1145 graph()->NewNode( |
| 1146 machine()->Word32Sar(), |
| 1147 graph()->NewNode(machine()->Word32Shl(), value, Int32Constant(x)), |
| 1148 Int32Constant(x)), |
| 1149 effect, control); |
| 1150 |
| 1151 Reduction r = Reduce(node); |
| 1152 ASSERT_TRUE(r.Changed()); |
| 1153 EXPECT_THAT(r.replacement(), |
| 1154 IsStore(rep, base, index, value, effect, control)); |
| 1155 } |
| 1156 } |
| 1157 |
| 1158 |
1135 TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) { | 1159 TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32And) { |
1136 const StoreRepresentation rep(kRepWord16, kNoWriteBarrier); | 1160 const StoreRepresentation rep(kRepWord16, kNoWriteBarrier); |
1137 Node* const base = Parameter(0); | 1161 Node* const base = Parameter(0); |
1138 Node* const index = Parameter(1); | 1162 Node* const index = Parameter(1); |
1139 Node* const value = Parameter(2); | 1163 Node* const value = Parameter(2); |
1140 Node* const effect = graph()->start(); | 1164 Node* const effect = graph()->start(); |
1141 Node* const control = graph()->start(); | 1165 Node* const control = graph()->start(); |
1142 TRACED_FOREACH(uint32_t, x, kUint32Values) { | 1166 TRACED_FOREACH(uint32_t, x, kUint32Values) { |
1143 Node* const node = | 1167 Node* const node = |
1144 graph()->NewNode(machine()->Store(rep), base, index, | 1168 graph()->NewNode(machine()->Store(rep), base, index, |
1145 graph()->NewNode(machine()->Word32And(), value, | 1169 graph()->NewNode(machine()->Word32And(), value, |
1146 Uint32Constant(x | 0xffffu)), | 1170 Uint32Constant(x | 0xffffu)), |
1147 effect, control); | 1171 effect, control); |
1148 | 1172 |
1149 Reduction r = Reduce(node); | 1173 Reduction r = Reduce(node); |
1150 ASSERT_TRUE(r.Changed()); | 1174 ASSERT_TRUE(r.Changed()); |
1151 EXPECT_THAT(r.replacement(), | 1175 EXPECT_THAT(r.replacement(), |
1152 IsStore(rep, base, index, value, effect, control)); | 1176 IsStore(rep, base, index, value, effect, control)); |
1153 } | 1177 } |
1154 } | 1178 } |
1155 | 1179 |
| 1180 |
| 1181 TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32SarAndWord32Shl) { |
| 1182 const StoreRepresentation rep(kRepWord16, kNoWriteBarrier); |
| 1183 Node* const base = Parameter(0); |
| 1184 Node* const index = Parameter(1); |
| 1185 Node* const value = Parameter(2); |
| 1186 Node* const effect = graph()->start(); |
| 1187 Node* const control = graph()->start(); |
| 1188 TRACED_FORRANGE(int32_t, x, 1, 16) { |
| 1189 Node* const node = graph()->NewNode( |
| 1190 machine()->Store(rep), base, index, |
| 1191 graph()->NewNode( |
| 1192 machine()->Word32Sar(), |
| 1193 graph()->NewNode(machine()->Word32Shl(), value, Int32Constant(x)), |
| 1194 Int32Constant(x)), |
| 1195 effect, control); |
| 1196 |
| 1197 Reduction r = Reduce(node); |
| 1198 ASSERT_TRUE(r.Changed()); |
| 1199 EXPECT_THAT(r.replacement(), |
| 1200 IsStore(rep, base, index, value, effect, control)); |
| 1201 } |
| 1202 } |
| 1203 |
1156 } // namespace compiler | 1204 } // namespace compiler |
1157 } // namespace internal | 1205 } // namespace internal |
1158 } // namespace v8 | 1206 } // namespace v8 |
OLD | NEW |