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

Unified Diff: src/x64/macro-assembler-x64.cc

Issue 946423003: [x64] Improve materialization of certain double constants (i.e. -0.0). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 295f89106f1dac07c3a62f585c9c922b0502be0c..86915e951b729c77d152542c692ee445fedcc6b7 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -2578,24 +2578,43 @@ void MacroAssembler::Move(XMMRegister dst, uint32_t src) {
if (src == 0) {
xorps(dst, dst);
} else {
- movl(kScratchRegister, Immediate(src));
- movq(dst, kScratchRegister);
+ unsigned pop = base::bits::CountPopulation32(src);
+ DCHECK_NE(0u, pop);
+ if (pop == 32) {
+ pcmpeqd(dst, dst);
+ } else {
+ movl(kScratchRegister, Immediate(src));
+ movq(dst, kScratchRegister);
+ }
}
}
void MacroAssembler::Move(XMMRegister dst, uint64_t src) {
- uint32_t lower = static_cast<uint32_t>(src);
- uint32_t upper = static_cast<uint32_t>(src >> 32);
- if (upper == 0) {
- Move(dst, lower);
+ if (src == 0) {
+ xorps(dst, dst);
} else {
- if (lower == 0) {
- Move(dst, upper);
- psllq(dst, 32);
+ unsigned nlz = base::bits::CountLeadingZeros64(src);
+ unsigned ntz = base::bits::CountTrailingZeros64(src);
+ unsigned pop = base::bits::CountPopulation64(src);
+ DCHECK_NE(0u, pop);
+ if (pop == 64) {
+ pcmpeqd(dst, dst);
+ } else if (pop + ntz == 64) {
+ pcmpeqd(dst, dst);
+ psllq(dst, ntz);
+ } else if (pop + nlz == 64) {
+ pcmpeqd(dst, dst);
+ psrlq(dst, nlz);
} else {
- movq(kScratchRegister, src);
- movq(dst, kScratchRegister);
+ uint32_t lower = static_cast<uint32_t>(src);
+ uint32_t upper = static_cast<uint32_t>(src >> 32);
+ if (upper == 0) {
+ Move(dst, lower);
+ } else {
+ movq(kScratchRegister, src);
+ movq(dst, kScratchRegister);
+ }
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698