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

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

Issue 9177001: Optimize simple constant cases for bitwise &, | and ^. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 HValue* HConstant::Canonicalize() { 781 HValue* HConstant::Canonicalize() {
782 return HasNoUses() && !IsBlockEntry() ? NULL : this; 782 return HasNoUses() && !IsBlockEntry() ? NULL : this;
783 } 783 }
784 784
785 785
786 HValue* HTypeof::Canonicalize() { 786 HValue* HTypeof::Canonicalize() {
787 return HasNoUses() && !IsBlockEntry() ? NULL : this; 787 return HasNoUses() && !IsBlockEntry() ? NULL : this;
788 } 788 }
789 789
790 790
791 HValue* HBitwise::Canonicalize() {
792 if (!representation().IsInteger32()) return this;
793 // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x.
794 int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0;
795 if (left()->IsConstant() &&
796 HConstant::cast(left())->HasInteger32Value() &&
797 HConstant::cast(left())->Integer32Value() == nop_constant) {
798 return right();
799 }
800 if (right()->IsConstant() &&
801 HConstant::cast(right())->HasInteger32Value() &&
802 HConstant::cast(right())->Integer32Value() == nop_constant) {
803 return left();
804 }
805 return this;
806 }
807
808
791 void HTypeof::PrintDataTo(StringStream* stream) { 809 void HTypeof::PrintDataTo(StringStream* stream) {
792 value()->PrintNameTo(stream); 810 value()->PrintNameTo(stream);
793 } 811 }
794 812
795 813
796 void HChange::PrintDataTo(StringStream* stream) { 814 void HChange::PrintDataTo(StringStream* stream) {
797 HUnaryOperation::PrintDataTo(stream); 815 HUnaryOperation::PrintDataTo(stream);
798 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic()); 816 stream->Add(" %s to %s", from().Mnemonic(), to().Mnemonic());
799 817
800 if (CanTruncateToInt32()) stream->Add(" truncating-int32"); 818 if (CanTruncateToInt32()) stream->Add(" truncating-int32");
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2106 2124
2107 2125
2108 void HCheckPrototypeMaps::Verify() { 2126 void HCheckPrototypeMaps::Verify() {
2109 HInstruction::Verify(); 2127 HInstruction::Verify();
2110 ASSERT(HasNoUses()); 2128 ASSERT(HasNoUses());
2111 } 2129 }
2112 2130
2113 #endif 2131 #endif
2114 2132
2115 } } // namespace v8::internal 2133 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698