Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 718193003: [turbofan] Avoid useless bit masking in typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-operator.h" 7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 context, effect, control)); 102 context, effect, control));
103 ASSERT_TRUE(r.Changed()); 103 ASSERT_TRUE(r.Changed());
104 EXPECT_THAT( 104 EXPECT_THAT(
105 r.replacement(), 105 r.replacement(),
106 IsPhi(kMachAnyTagged, 106 IsPhi(kMachAnyTagged,
107 IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control)); 107 IsBooleanNot(IsNumberEqual(p0, IsNumberConstant(0))), p1, control));
108 } 108 }
109 109
110 110
111 // ----------------------------------------------------------------------------- 111 // -----------------------------------------------------------------------------
112 // JSShiftLeft
113
114
115 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
116 Node* const lhs = Parameter(Type::Signed32());
117 Node* const context = UndefinedConstant();
118 Node* const effect = graph()->start();
119 Node* const control = graph()->start();
120 TRACED_FORRANGE(int32_t, rhs, 0, 31) {
121 Reduction r =
122 Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs,
123 NumberConstant(rhs), context, effect, control));
124 ASSERT_TRUE(r.Changed());
125 EXPECT_THAT(r.replacement(), IsWord32Shl(lhs, IsNumberConstant(rhs)));
126 }
127 }
128
129
130 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) {
131 Node* const lhs = Parameter(Type::Signed32());
132 Node* const rhs = Parameter(Type::Unsigned32());
133 Node* const context = UndefinedConstant();
134 Node* const effect = graph()->start();
135 Node* const control = graph()->start();
136 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(), lhs, rhs,
137 context, effect, control));
138 ASSERT_TRUE(r.Changed());
139 EXPECT_THAT(r.replacement(),
140 IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
141 }
142
143
144 // -----------------------------------------------------------------------------
145 // JSShiftRight
146
147
148 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) {
149 Node* const lhs = Parameter(Type::Signed32());
150 Node* const context = UndefinedConstant();
151 Node* const effect = graph()->start();
152 Node* const control = graph()->start();
153 TRACED_FORRANGE(int32_t, rhs, 0, 31) {
154 Reduction r =
155 Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs,
156 NumberConstant(rhs), context, effect, control));
157 ASSERT_TRUE(r.Changed());
158 EXPECT_THAT(r.replacement(), IsWord32Sar(lhs, IsNumberConstant(rhs)));
159 }
160 }
161
162
163 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) {
164 Node* const lhs = Parameter(Type::Signed32());
165 Node* const rhs = Parameter(Type::Unsigned32());
166 Node* const context = UndefinedConstant();
167 Node* const effect = graph()->start();
168 Node* const control = graph()->start();
169 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(), lhs, rhs,
170 context, effect, control));
171 ASSERT_TRUE(r.Changed());
172 EXPECT_THAT(r.replacement(),
173 IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
174 }
175
176
177 // -----------------------------------------------------------------------------
178 // JSShiftRightLogical
179
180
181 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndConstant) {
182 Node* const lhs = Parameter(Type::Unsigned32());
183 Node* const context = UndefinedConstant();
184 Node* const effect = graph()->start();
185 Node* const control = graph()->start();
186 TRACED_FORRANGE(int32_t, rhs, 0, 31) {
187 Reduction r =
188 Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs,
189 NumberConstant(rhs), context, effect, control));
190 ASSERT_TRUE(r.Changed());
191 EXPECT_THAT(r.replacement(), IsWord32Shr(lhs, IsNumberConstant(rhs)));
192 }
193 }
194
195
196 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
197 Node* const lhs = Parameter(Type::Unsigned32());
198 Node* const rhs = Parameter(Type::Unsigned32());
199 Node* const context = UndefinedConstant();
200 Node* const effect = graph()->start();
201 Node* const control = graph()->start();
202 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(), lhs,
203 rhs, context, effect, control));
204 ASSERT_TRUE(r.Changed());
205 EXPECT_THAT(r.replacement(),
206 IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
207 }
208
209
210 // -----------------------------------------------------------------------------
112 // JSLoadProperty 211 // JSLoadProperty
113 212
114 213
115 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { 214 TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
116 const size_t kLength = 17; 215 const size_t kLength = 17;
117 double backing_store[kLength]; 216 double backing_store[kLength];
118 Handle<JSArrayBuffer> buffer = 217 Handle<JSArrayBuffer> buffer =
119 NewArrayBuffer(backing_store, sizeof(backing_store)); 218 NewArrayBuffer(backing_store, sizeof(backing_store));
120 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(), 219 VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(),
121 FeedbackVectorICSlot::Invalid()); 220 FeedbackVectorICSlot::Invalid());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), 282 IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
184 key, IsNumberConstant(array->length()->Number()), value, 283 key, IsNumberConstant(array->length()->Number()), value,
185 effect, control)); 284 effect, control));
186 } 285 }
187 } 286 }
188 } 287 }
189 288
190 } // namespace compiler 289 } // namespace compiler
191 } // namespace internal 290 } // namespace internal
192 } // namespace v8 291 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698