Skip to content

Commit

Permalink
Use ARCH_CPU_X86_FAMILY instead of SSE, for subnormal float disabler
Browse files Browse the repository at this point in the history
MSC doesn't define SSE, so this wasn't working properly on Windows

Bug: 686253
Change-Id: I5e49e9dec43228288261160d8e9eede9b4a6bf75
Reviewed-on: https://chromium-review.googlesource.com/570351
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486517}
  • Loading branch information
Fernando Serboncini authored and Commit Bot committed Jul 13, 2017
1 parent 36fd391 commit a9563a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cc/base/math_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <algorithm>
#include <cmath>
#include <limits>
#ifdef __SSE__
#if defined(ARCH_CPU_X86_FAMILY)
#include <xmmintrin.h>
#endif

Expand Down Expand Up @@ -810,15 +810,15 @@ gfx::Vector3dF MathUtil::GetYAxis(const gfx::Transform& transform) {
}

ScopedSubnormalFloatDisabler::ScopedSubnormalFloatDisabler() {
#ifdef __SSE__
#if defined(ARCH_CPU_X86_FAMILY)
// Turn on "subnormals are zero" and "flush to zero" CSR flags.
orig_state_ = _mm_getcsr();
_mm_setcsr(orig_state_ | 0x8040);
#endif
}

ScopedSubnormalFloatDisabler::~ScopedSubnormalFloatDisabler() {
#ifdef __SSE__
#if defined(ARCH_CPU_X86_FAMILY)
_mm_setcsr(orig_state_);
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion cc/base/math_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <vector>

#include "base/logging.h"
#include "build/build_config.h"
#include "cc/base/base_export.h"
#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/point3_f.h"
Expand Down Expand Up @@ -330,7 +331,7 @@ class CC_BASE_EXPORT ScopedSubnormalFloatDisabler {
~ScopedSubnormalFloatDisabler();

private:
#ifdef __SSE__
#if defined(ARCH_CPU_X86_FAMILY)
unsigned int orig_state_;
#endif
DISALLOW_COPY_AND_ASSIGN(ScopedSubnormalFloatDisabler);
Expand Down

0 comments on commit a9563a8

Please sign in to comment.