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

Side by Side Diff: test/unittests/compiler/simplified-operator-reducer-unittest.cc

Issue 850013003: [turbofan] Fix truncation/representation sloppiness wrt. bool/bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes/Cleanups Created 5 years, 11 months 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
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/node-properties-inl.h" 7 #include "src/compiler/node-properties-inl.h"
8 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/simplified-operator-reducer.h" 9 #include "src/compiler/simplified-operator-reducer.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 0x69fe3276, 0x6bebf0ba, 0x6e2c69a3, 0x73b84ff7, 0x7b3a1924, 0x7ed032d9, 117 0x69fe3276, 0x6bebf0ba, 0x6e2c69a3, 0x73b84ff7, 0x7b3a1924, 0x7ed032d9,
118 0x84dd734b, 0x8552ea53, 0x8680754f, 0x8e9660eb, 0x94fe2b9c, 0x972d30cf, 118 0x84dd734b, 0x8552ea53, 0x8680754f, 0x8e9660eb, 0x94fe2b9c, 0x972d30cf,
119 0x9b98c482, 0xb158667e, 0xb432932c, 0xb5b70989, 0xb669971a, 0xb7c359d1, 119 0x9b98c482, 0xb158667e, 0xb432932c, 0xb5b70989, 0xb669971a, 0xb7c359d1,
120 0xbeb15c0d, 0xc171c53d, 0xc743dd38, 0xc8e2af50, 0xc98e2df0, 0xd9d1cdf9, 120 0xbeb15c0d, 0xc171c53d, 0xc743dd38, 0xc8e2af50, 0xc98e2df0, 0xd9d1cdf9,
121 0xdcc91049, 0xe46f396d, 0xee991950, 0xef64e521, 0xf7aeefc9, 0xffffffff}; 121 0xdcc91049, 0xe46f396d, 0xee991950, 0xef64e521, 0xf7aeefc9, 0xffffffff};
122 122
123 } // namespace 123 } // namespace
124 124
125 125
126 // ----------------------------------------------------------------------------- 126 // -----------------------------------------------------------------------------
127 // Unary operators
128
129
130 namespace {
131
132 struct UnaryOperator {
133 const Operator* (SimplifiedOperatorBuilder::*constructor)();
134 const char* constructor_name;
135 };
136
137
138 std::ostream& operator<<(std::ostream& os, const UnaryOperator& unop) {
139 return os << unop.constructor_name;
140 }
141
142
143 static const UnaryOperator kUnaryOperators[] = {
144 {&SimplifiedOperatorBuilder::AnyToBoolean, "AnyToBoolean"},
145 {&SimplifiedOperatorBuilder::BooleanNot, "BooleanNot"},
146 {&SimplifiedOperatorBuilder::ChangeBitToBool, "ChangeBitToBool"},
147 {&SimplifiedOperatorBuilder::ChangeBoolToBit, "ChangeBoolToBit"},
148 {&SimplifiedOperatorBuilder::ChangeFloat64ToTagged,
149 "ChangeFloat64ToTagged"},
150 {&SimplifiedOperatorBuilder::ChangeInt32ToTagged, "ChangeInt32ToTagged"},
151 {&SimplifiedOperatorBuilder::ChangeTaggedToFloat64,
152 "ChangeTaggedToFloat64"},
153 {&SimplifiedOperatorBuilder::ChangeTaggedToInt32, "ChangeTaggedToInt32"},
154 {&SimplifiedOperatorBuilder::ChangeTaggedToUint32, "ChangeTaggedToUint32"},
155 {&SimplifiedOperatorBuilder::ChangeUint32ToTagged, "ChangeUint32ToTagged"}};
156
157 } // namespace
158
159
160 typedef SimplifiedOperatorReducerTestWithParam<UnaryOperator>
161 SimplifiedUnaryOperatorTest;
162
163
164 TEST_P(SimplifiedUnaryOperatorTest, Parameter) {
165 const UnaryOperator& unop = GetParam();
166 Reduction reduction = Reduce(graph()->NewNode(
167 (simplified()->*unop.constructor)(), Parameter(Type::Any())));
168 EXPECT_FALSE(reduction.Changed());
169 }
170
171
172 INSTANTIATE_TEST_CASE_P(SimplifiedOperatorReducerTest,
173 SimplifiedUnaryOperatorTest,
174 ::testing::ValuesIn(kUnaryOperators));
175
176
177 // -----------------------------------------------------------------------------
178 // AnyToBoolean 127 // AnyToBoolean
179 128
180 129
181 TEST_F(SimplifiedOperatorReducerTest, AnyToBooleanWithBoolean) { 130 TEST_F(SimplifiedOperatorReducerTest, AnyToBooleanWithBoolean) {
182 Node* p = Parameter(Type::Boolean()); 131 Node* p = Parameter(Type::Boolean());
183 Reduction r = Reduce(graph()->NewNode(simplified()->AnyToBoolean(), p)); 132 Reduction r = Reduce(graph()->NewNode(simplified()->AnyToBoolean(), p));
184 ASSERT_TRUE(r.Changed()); 133 ASSERT_TRUE(r.Changed());
185 EXPECT_EQ(p, r.replacement()); 134 EXPECT_EQ(p, r.replacement());
186 } 135 }
187 136
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 Node* param0 = Parameter(0); 240 Node* param0 = Parameter(0);
292 Reduction reduction = Reduce(graph()->NewNode( 241 Reduction reduction = Reduce(graph()->NewNode(
293 simplified()->ChangeBoolToBit(), 242 simplified()->ChangeBoolToBit(),
294 graph()->NewNode(simplified()->ChangeBitToBool(), param0))); 243 graph()->NewNode(simplified()->ChangeBitToBool(), param0)));
295 ASSERT_TRUE(reduction.Changed()); 244 ASSERT_TRUE(reduction.Changed());
296 EXPECT_EQ(param0, reduction.replacement()); 245 EXPECT_EQ(param0, reduction.replacement());
297 } 246 }
298 247
299 248
300 // ----------------------------------------------------------------------------- 249 // -----------------------------------------------------------------------------
301 // ChangeWord32ToBit
302
303
304 TEST_F(SimplifiedOperatorReducerTest, ChangeWord32ToBitWithBitType) {
305 Handle<Object> zero = factory()->NewNumber(0);
306 Handle<Object> one = factory()->NewNumber(1);
307 Type* const kBitTypes[] = {
308 Type::Constant(zero, zone()), Type::Constant(one, zone()),
309 Type::Range(zero, zero, zone()), Type::Range(one, one, zone()),
310 Type::Range(zero, one, zone())};
311 TRACED_FOREACH(Type*, type, kBitTypes) {
312 Node* param0 = Parameter(type, 0);
313 Reduction reduction =
314 Reduce(graph()->NewNode(simplified()->ChangeWord32ToBit(), param0));
315 ASSERT_TRUE(reduction.Changed());
316 EXPECT_EQ(param0, reduction.replacement());
317 }
318 }
319
320
321 // -----------------------------------------------------------------------------
322 // ChangeFloat64ToTagged 250 // ChangeFloat64ToTagged
323 251
324 252
325 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) { 253 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) {
326 TRACED_FOREACH(double, n, kFloat64Values) { 254 TRACED_FOREACH(double, n, kFloat64Values) {
327 Reduction reduction = Reduce(graph()->NewNode( 255 Reduction reduction = Reduce(graph()->NewNode(
328 simplified()->ChangeFloat64ToTagged(), Float64Constant(n))); 256 simplified()->ChangeFloat64ToTagged(), Float64Constant(n)));
329 ASSERT_TRUE(reduction.Changed()); 257 ASSERT_TRUE(reduction.Changed());
330 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(n))); 258 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(n)));
331 } 259 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), 460 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(),
533 Int32Constant(bit_cast<int32_t>(n)))); 461 Int32Constant(bit_cast<int32_t>(n))));
534 ASSERT_TRUE(reduction.Changed()); 462 ASSERT_TRUE(reduction.Changed());
535 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n)))); 463 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n))));
536 } 464 }
537 } 465 }
538 466
539 } // namespace compiler 467 } // namespace compiler
540 } // namespace internal 468 } // namespace internal
541 } // namespace v8 469 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/change-lowering-unittest.cc ('k') | test/unittests/compiler/simplified-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698