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

Side by Side Diff: src/compiler/int64-lowering.cc

Issue 1843123002: [wasm] Int64Lowering of Word64Ror and Word64Rol. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | src/compiler/wasm-compiler.cc » ('j') | 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/int64-lowering.h" 5 #include "src/compiler/int64-lowering.h"
6 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
7 #include "src/compiler/diamond.h" 7 #include "src/compiler/diamond.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
11 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/node-properties.h" 12 #include "src/compiler/node-properties.h"
12 13
13 #include "src/compiler/node.h" 14 #include "src/compiler/node.h"
14 #include "src/wasm/wasm-module.h" 15 #include "src/wasm/wasm-module.h"
15 #include "src/zone.h" 16 #include "src/zone.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 namespace compiler { 20 namespace compiler {
20 21
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 graph()->NewNode(common()->Int32Constant(4)), store, 544 graph()->NewNode(common()->Int32Constant(4)), store,
544 graph()->start()); 545 graph()->start());
545 546
546 Node* low_node = 547 Node* low_node =
547 graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot, 548 graph()->NewNode(machine()->Load(MachineType::Int32()), stack_slot,
548 graph()->NewNode(common()->Int32Constant(0)), store, 549 graph()->NewNode(common()->Int32Constant(0)), store,
549 graph()->start()); 550 graph()->start());
550 ReplaceNode(node, low_node, high_node); 551 ReplaceNode(node, low_node, high_node);
551 break; 552 break;
552 } 553 }
554 case IrOpcode::kWord64Ror: {
titzer 2016/03/30 14:56:35 The names in here are a bit confusing. Fixed have
ahaas 2016/03/31 14:17:12 Done.
555 DCHECK(node->InputCount() == 2);
556 Node* input = node->InputAt(0);
557 Node* shift = HasReplacementLow(node->InputAt(1))
558 ? GetReplacementLow(node->InputAt(1))
559 : node->InputAt(1);
560 Int32Matcher m(shift);
561 if (m.HasValue()) {
562 int32_t shift_value = m.Value() & 0x3f;
563
564 Node* fixed_low;
565 Node* fixed_high;
566 if (shift_value < 32) {
567 fixed_low = GetReplacementLow(input);
568 fixed_high = GetReplacementHigh(input);
569 } else {
570 fixed_low = GetReplacementHigh(input);
571 fixed_high = GetReplacementLow(input);
572 }
573
574 int32_t fixed_shift_value = shift_value & 0x1f;
575 Node* fixed_shift =
576 graph()->NewNode(common()->Int32Constant(fixed_shift_value));
577 Node* inv_shift =
578 graph()->NewNode(common()->Int32Constant(32 - fixed_shift_value));
579 if (fixed_shift_value == 0) {
titzer 2016/03/30 14:56:35 Can you move this case up and save the creation of
ahaas 2016/03/31 14:17:12 Done.
580 ReplaceNode(node, fixed_low, fixed_high);
581 } else {
582 Node* low_node = graph()->NewNode(
583 machine()->Word32Or(),
584 graph()->NewNode(machine()->Word32Shr(), fixed_low, fixed_shift),
585 graph()->NewNode(machine()->Word32Shl(), fixed_high, inv_shift));
586 Node* high_node = graph()->NewNode(
587 machine()->Word32Or(),
588 graph()->NewNode(machine()->Word32Shr(), fixed_high, fixed_shift),
589 graph()->NewNode(machine()->Word32Shl(), fixed_low, inv_shift));
590 ReplaceNode(node, low_node, high_node);
591 }
592 } else {
593 Diamond lt32(graph(), common(),
594 graph()->NewNode(
595 machine()->Int32LessThan(),
596 graph()->NewNode(
597 machine()->Word32And(), shift,
598 graph()->NewNode(common()->Int32Constant(0x3f))),
599 graph()->NewNode(common()->Int32Constant(32))));
600
601 Node* fixed_low =
titzer 2016/03/30 14:56:35 This is probably going to generate some bad code.
ahaas 2016/03/31 14:17:13 I did a complete rework of the lowering. Word64Ror
602 lt32.Phi(MachineRepresentation::kWord32, GetReplacementLow(input),
603 GetReplacementHigh(input));
604 Node* fixed_high =
605 lt32.Phi(MachineRepresentation::kWord32, GetReplacementHigh(input),
606 GetReplacementLow(input));
607
608 Node* fixed_shift =
609 graph()->NewNode(machine()->Word32And(), shift,
610 graph()->NewNode(common()->Int32Constant(0x1f)));
611 Node* inv_shift = graph()->NewNode(
612 machine()->Int32Sub(),
613 graph()->NewNode(common()->Int32Constant(32)), fixed_shift);
614
615 Diamond z(
616 graph(), common(),
617 graph()->NewNode(machine()->Word32Equal(), fixed_shift,
618 graph()->NewNode(common()->Int32Constant(0))));
619
620 Node* low_node =
621 z.Phi(MachineRepresentation::kWord32, fixed_low,
622 graph()->NewNode(machine()->Word32Or(),
623 graph()->NewNode(machine()->Word32Shr(),
624 fixed_low, fixed_shift),
625 graph()->NewNode(machine()->Word32Shl(),
626 fixed_high, inv_shift)));
627
628 Node* high_node =
629 z.Phi(MachineRepresentation::kWord32, fixed_high,
630 graph()->NewNode(machine()->Word32Or(),
631 graph()->NewNode(machine()->Word32Shr(),
632 fixed_high, fixed_shift),
633 graph()->NewNode(machine()->Word32Shl(),
634 fixed_low, inv_shift)));
635
636 ReplaceNode(node, low_node, high_node);
637 }
638 break;
639 }
553 // kExprI64Clz: 640 // kExprI64Clz:
554 case IrOpcode::kWord64Clz: { 641 case IrOpcode::kWord64Clz: {
555 DCHECK(node->InputCount() == 1); 642 DCHECK(node->InputCount() == 1);
556 Node* input = node->InputAt(0); 643 Node* input = node->InputAt(0);
557 Diamond d( 644 Diamond d(
558 graph(), common(), 645 graph(), common(),
559 graph()->NewNode(machine()->Word32Equal(), GetReplacementHigh(input), 646 graph()->NewNode(machine()->Word32Equal(), GetReplacementHigh(input),
560 graph()->NewNode(common()->Int32Constant(0)))); 647 graph()->NewNode(common()->Int32Constant(0))));
561 648
562 Node* low_node = d.Phi( 649 Node* low_node = d.Phi(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 high_node->ReplaceInput(i, GetReplacementHigh(node->InputAt(i))); 704 high_node->ReplaceInput(i, GetReplacementHigh(node->InputAt(i)));
618 } 705 }
619 } else { 706 } else {
620 DefaultLowering(node); 707 DefaultLowering(node);
621 } 708 }
622 break; 709 break;
623 } 710 }
624 711
625 default: { DefaultLowering(node); } 712 default: { DefaultLowering(node); }
626 } 713 }
627 } 714 } // NOLINT(readability/fn_size)
628 715
629 void Int64Lowering::LowerComparison(Node* node, const Operator* high_word_op, 716 void Int64Lowering::LowerComparison(Node* node, const Operator* high_word_op,
630 const Operator* low_word_op) { 717 const Operator* low_word_op) {
631 DCHECK(node->InputCount() == 2); 718 DCHECK(node->InputCount() == 2);
632 Node* left = node->InputAt(0); 719 Node* left = node->InputAt(0);
633 Node* right = node->InputAt(1); 720 Node* right = node->InputAt(1);
634 Node* replacement = graph()->NewNode( 721 Node* replacement = graph()->NewNode(
635 machine()->Word32Or(), 722 machine()->Word32Or(),
636 graph()->NewNode(high_word_op, GetReplacementHigh(left), 723 graph()->NewNode(high_word_op, GetReplacementHigh(left),
637 GetReplacementHigh(right)), 724 GetReplacementHigh(right)),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 common()->Phi(MachineRepresentation::kWord32, value_count), 796 common()->Phi(MachineRepresentation::kWord32, value_count),
710 value_count + 1, inputs_low, false), 797 value_count + 1, inputs_low, false),
711 graph()->NewNode( 798 graph()->NewNode(
712 common()->Phi(MachineRepresentation::kWord32, value_count), 799 common()->Phi(MachineRepresentation::kWord32, value_count),
713 value_count + 1, inputs_high, false)); 800 value_count + 1, inputs_high, false));
714 } 801 }
715 } 802 }
716 } // namespace compiler 803 } // namespace compiler
717 } // namespace internal 804 } // namespace internal
718 } // namespace v8 805 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698