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

Unified Diff: src/compiler/ppc/code-generator-ppc.cc

Issue 2888533003: PPC: Work around unintended snan to qnan conversion (Closed)
Patch Set: Rephrase the comment to make more sense Created 3 years, 7 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 | src/ppc/simulator-ppc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ppc/code-generator-ppc.cc
diff --git a/src/compiler/ppc/code-generator-ppc.cc b/src/compiler/ppc/code-generator-ppc.cc
index f21d579a3e1268168ae508189ace2005c3644e31..2967ad73ede92d20a1f782d6c9722da3c9b25b0c 100644
--- a/src/compiler/ppc/code-generator-ppc.cc
+++ b/src/compiler/ppc/code-generator-ppc.cc
@@ -2453,21 +2453,30 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
? g.ToDoubleRegister(destination)
: kScratchDoubleReg;
double value;
-// bit_cast of snan is converted to qnan on ia32/x64
#if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
- intptr_t valueInt = (src.type() == Constant::kFloat32)
- ? src.ToFloat32AsInt()
- : src.ToFloat64AsInt();
- if (valueInt == ((src.type() == Constant::kFloat32)
- ? 0x7fa00000
- : 0x7fa0000000000000)) {
- value = bit_cast<double, int64_t>(0x7ff4000000000000L);
+ // casting double precision snan to single precision
+ // converts it to qnan on ia32/x64
+ if (src.type() == Constant::kFloat32) {
+ int32_t val = src.ToFloat32AsInt();
+ if ((val & 0x7f800000) == 0x7f800000) {
+ int64_t dval = static_cast<int64_t>(val);
+ dval = ((dval & 0xc0000000) << 32) | ((dval & 0x40000000) << 31) |
+ ((dval & 0x40000000) << 30) | ((dval & 0x7fffffff) << 29);
+ value = bit_cast<double, int64_t>(dval);
+ } else {
+ value = src.ToFloat32();
+ }
} else {
-#endif
- value = (src.type() == Constant::kFloat32) ? src.ToFloat32()
- : src.ToFloat64();
-#if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
+ int64_t val = src.ToFloat64AsInt();
+ if ((val & 0x7f80000000000000) == 0x7f80000000000000) {
+ value = bit_cast<double, int64_t>(val);
+ } else {
+ value = src.ToFloat64();
+ }
}
+#else
+ value = (src.type() == Constant::kFloat32) ? src.ToFloat32()
+ : src.ToFloat64();
#endif
__ LoadDoubleLiteral(dst, value, kScratchReg);
if (destination->IsFPStackSlot()) {
« no previous file with comments | « no previous file | src/ppc/simulator-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698