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

Side by Side Diff: src/hydrogen-canonicalize.cc

Issue 23496017: Shr should save its Use truncating flag before Canonicalize (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 7 years, 3 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 | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-ia32.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20 matching lines...) Expand all
31 namespace internal { 31 namespace internal {
32 32
33 void HCanonicalizePhase::Run() { 33 void HCanonicalizePhase::Run() {
34 const ZoneList<HBasicBlock*>* blocks(graph()->blocks()); 34 const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
35 // Before removing no-op instructions, save their semantic value. 35 // Before removing no-op instructions, save their semantic value.
36 // We must be careful not to set the flag unnecessarily, because GVN 36 // We must be careful not to set the flag unnecessarily, because GVN
37 // cannot identify two instructions when their flag value differs. 37 // cannot identify two instructions when their flag value differs.
38 for (int i = 0; i < blocks->length(); ++i) { 38 for (int i = 0; i < blocks->length(); ++i) {
39 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) { 39 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
40 HInstruction* instr = it.Current(); 40 HInstruction* instr = it.Current();
41 if (instr->IsArithmeticBinaryOperation()) { 41 if (instr->IsArithmeticBinaryOperation() || instr->IsShr()) {
42 if (instr->representation().IsInteger32()) { 42 if (instr->representation().IsInteger32()) {
43 if (instr->HasAtLeastOneUseWithFlagAndNoneWithout( 43 if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
44 HInstruction::kTruncatingToInt32)) { 44 HInstruction::kTruncatingToInt32)) {
45 instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32); 45 instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32);
46 } 46 }
47 } else if (instr->representation().IsSmi()) { 47 } else if (instr->representation().IsSmi()) {
48 if (instr->HasAtLeastOneUseWithFlagAndNoneWithout( 48 if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
49 HInstruction::kTruncatingToSmi)) { 49 HInstruction::kTruncatingToSmi)) {
50 instr->SetFlag(HInstruction::kAllUsesTruncatingToSmi); 50 instr->SetFlag(HInstruction::kAllUsesTruncatingToSmi);
51 } else if (instr->HasAtLeastOneUseWithFlagAndNoneWithout( 51 } else if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
52 HInstruction::kTruncatingToInt32)) { 52 HInstruction::kTruncatingToInt32)) {
53 // Avoid redundant minus zero check 53 // Avoid redundant minus zero check
54 instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32); 54 instr->SetFlag(HInstruction::kAllUsesTruncatingToInt32);
55 } 55 }
56 } 56 }
57 } 57 }
58 } 58 }
59 } 59 }
60 // Perform actual Canonicalization pass. 60 // Perform actual Canonicalization pass.
61 for (int i = 0; i < blocks->length(); ++i) { 61 for (int i = 0; i < blocks->length(); ++i) {
62 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) { 62 for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
63 HInstruction* instr = it.Current(); 63 HInstruction* instr = it.Current();
64 HValue* value = instr->Canonicalize(); 64 HValue* value = instr->Canonicalize();
65 if (value != instr) instr->DeleteAndReplaceWith(value); 65 if (value != instr) instr->DeleteAndReplaceWith(value);
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 } } // namespace v8::internal 70 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698