Blob Blame History Raw
From 138d403b6bb15e687a3fe26d3d967b8ccd1ed97b Mon Sep 17 00:00:00 2001
From: Devin Matthews <damatthews@smu.edu>
Date: Mon, 26 Aug 2019 18:11:27 -0500
Subject: [PATCH] Use -funsafe-math-optimizations and -ffp-contract=fast for
 all reference kernels when using gcc or clang. (#331)

---
 config/amd64/make_defs.mk       | 6 +++++-
 config/arm32/make_defs.mk       | 8 ++++++++
 config/arm64/make_defs.mk       | 8 ++++++++
 config/bgq/make_defs.mk         | 8 ++++++++
 config/bulldozer/make_defs.mk   | 6 +++++-
 config/cortexa15/make_defs.mk   | 8 ++++++++
 config/cortexa53/make_defs.mk   | 8 ++++++++
 config/cortexa57/make_defs.mk   | 8 ++++++++
 config/cortexa9/make_defs.mk    | 8 ++++++++
 config/excavator/make_defs.mk   | 6 +++++-
 config/generic/make_defs.mk     | 6 +++++-
 config/haswell/make_defs.mk     | 6 +++++-
 config/intel64/make_defs.mk     | 6 +++++-
 config/knc/make_defs.mk         | 6 +++++-
 config/knl/make_defs.mk         | 4 ++--
 config/penryn/make_defs.mk      | 6 +++++-
 config/piledriver/make_defs.mk  | 6 +++++-
 config/power7/make_defs.mk      | 8 ++++++++
 config/power9/make_defs.mk      | 8 ++++++++
 config/sandybridge/make_defs.mk | 6 +++++-
 config/skx/make_defs.mk         | 4 ++--
 config/steamroller/make_defs.mk | 6 +++++-
 config/thunderx2/make_defs.mk   | 8 ++++++++
 config/x86_64/make_defs.mk      | 6 +++++-
 config/zen/make_defs.mk         | 6 +++++-
 25 files changed, 149 insertions(+), 17 deletions(-)

diff --git a/config/amd64/make_defs.mk b/config/amd64/make_defs.mk
index 70c0b69..df7cd20 100644
--- a/config/amd64/make_defs.mk
+++ b/config/amd64/make_defs.mk
@@ -75,10 +75,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/arm32/make_defs.mk b/config/arm32/make_defs.mk
index b592851..0b517a1 100644
--- a/config/arm32/make_defs.mk
+++ b/config/arm32/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/arm64/make_defs.mk b/config/arm64/make_defs.mk
index ac1cd69..5ffb081 100644
--- a/config/arm64/make_defs.mk
+++ b/config/arm64/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/bgq/make_defs.mk b/config/bgq/make_defs.mk
index a577a9a..97ea5a5 100644
--- a/config/bgq/make_defs.mk
+++ b/config/bgq/make_defs.mk
@@ -79,7 +79,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Override the default value for LDFLAGS.
 ifeq ($(CC_VENDOR),ibm)
diff --git a/config/bulldozer/make_defs.mk b/config/bulldozer/make_defs.mk
index dec89a4..8f71da3 100644
--- a/config/bulldozer/make_defs.mk
+++ b/config/bulldozer/make_defs.mk
@@ -75,10 +75,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/cortexa15/make_defs.mk b/config/cortexa15/make_defs.mk
index ee4d301..0cbf304 100644
--- a/config/cortexa15/make_defs.mk
+++ b/config/cortexa15/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/cortexa53/make_defs.mk b/config/cortexa53/make_defs.mk
index 9f723bc..3e116cd 100644
--- a/config/cortexa53/make_defs.mk
+++ b/config/cortexa53/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/cortexa57/make_defs.mk b/config/cortexa57/make_defs.mk
index 23bcf51..864872b 100644
--- a/config/cortexa57/make_defs.mk
+++ b/config/cortexa57/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/cortexa9/make_defs.mk b/config/cortexa9/make_defs.mk
index 2adc40e..310b75b 100644
--- a/config/cortexa9/make_defs.mk
+++ b/config/cortexa9/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/excavator/make_defs.mk b/config/excavator/make_defs.mk
index deb85c7..ed73d5d 100644
--- a/config/excavator/make_defs.mk
+++ b/config/excavator/make_defs.mk
@@ -75,10 +75,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/generic/make_defs.mk b/config/generic/make_defs.mk
index 3388291..7f934de 100644
--- a/config/generic/make_defs.mk
+++ b/config/generic/make_defs.mk
@@ -79,10 +79,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/haswell/make_defs.mk b/config/haswell/make_defs.mk
index 3f49f19..6752dde 100644
--- a/config/haswell/make_defs.mk
+++ b/config/haswell/make_defs.mk
@@ -83,10 +83,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) #-funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/intel64/make_defs.mk b/config/intel64/make_defs.mk
index af462fd..f74fb4d 100644
--- a/config/intel64/make_defs.mk
+++ b/config/intel64/make_defs.mk
@@ -79,10 +79,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/knc/make_defs.mk b/config/knc/make_defs.mk
index be3c901..d585219 100644
--- a/config/knc/make_defs.mk
+++ b/config/knc/make_defs.mk
@@ -71,10 +71,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Override the default value for LDFLAGS.
 LDFLAGS        := -mmic
diff --git a/config/knl/make_defs.mk b/config/knl/make_defs.mk
index b08cf1e..aa74df3 100644
--- a/config/knl/make_defs.mk
+++ b/config/knl/make_defs.mk
@@ -99,13 +99,13 @@ endif
 # Note: We use AVX2 for reference kernels instead of AVX-512.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := -march=knl -mno-avx512f -mno-avx512pf -mno-avx512er -mno-avx512cd -funsafe-math-optimizations
+CRVECFLAGS     := -march=knl -mno-avx512f -mno-avx512pf -mno-avx512er -mno-avx512cd -funsafe-math-optimizations -ffp-contract=fast
 else
 ifeq ($(CC_VENDOR),icc)
 CRVECFLAGS     := -xMIC-AVX512
 else
 ifeq ($(CC_VENDOR),clang)
-CRVECFLAGS     := -march=knl -mno-avx512f -mno-avx512pf -mno-avx512er -mno-avx512cd
+CRVECFLAGS     := -march=knl -mno-avx512f -mno-avx512pf -mno-avx512er -mno-avx512cd -funsafe-math-optimizations -ffp-contract=fast
 else
 $(error gcc, icc, or clang is required for this configuration.)
 endif
diff --git a/config/penryn/make_defs.mk b/config/penryn/make_defs.mk
index 41d2d93..573382e 100644
--- a/config/penryn/make_defs.mk
+++ b/config/penryn/make_defs.mk
@@ -79,10 +79,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/piledriver/make_defs.mk b/config/piledriver/make_defs.mk
index bb23fbe..8cf3ac5 100644
--- a/config/piledriver/make_defs.mk
+++ b/config/piledriver/make_defs.mk
@@ -75,10 +75,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/power7/make_defs.mk b/config/power7/make_defs.mk
index 18f111b..9633b4f 100644
--- a/config/power7/make_defs.mk
+++ b/config/power7/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/power9/make_defs.mk b/config/power9/make_defs.mk
index 3d66f60..b2c78b1 100644
--- a/config/power9/make_defs.mk
+++ b/config/power9/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/sandybridge/make_defs.mk b/config/sandybridge/make_defs.mk
index 285c4d5..896cb89 100644
--- a/config/sandybridge/make_defs.mk
+++ b/config/sandybridge/make_defs.mk
@@ -83,10 +83,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/skx/make_defs.mk b/config/skx/make_defs.mk
index 27bea5e..920b42d 100644
--- a/config/skx/make_defs.mk
+++ b/config/skx/make_defs.mk
@@ -89,13 +89,13 @@ endif
 # to overcome the AVX-512 frequency drop". (Issue #187)
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := -march=skylake-avx512 -mno-avx512f -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -funsafe-math-optimizations
+CRVECFLAGS     := -march=skylake-avx512 -mno-avx512f -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -funsafe-math-optimizations -ffp-contract=fast
 else
 ifeq ($(CC_VENDOR),icc)
 CRVECFLAGS     := -xCORE-AVX2
 else
 ifeq ($(CC_VENDOR),clang)
-CRVECFLAGS     := -march=skylake-avx512 -mno-avx512f -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd
+CRVECFLAGS     := -march=skylake-avx512 -mno-avx512f -mno-avx512vl -mno-avx512bw -mno-avx512dq -mno-avx512cd -funsafe-math-optimizations -ffp-contract=fast
 else
 $(error gcc, icc, or clang is required for this configuration.)
 endif
diff --git a/config/steamroller/make_defs.mk b/config/steamroller/make_defs.mk
index a5b6707..89c7689 100644
--- a/config/steamroller/make_defs.mk
+++ b/config/steamroller/make_defs.mk
@@ -75,10 +75,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/thunderx2/make_defs.mk b/config/thunderx2/make_defs.mk
index 3227fe2..820919d 100644
--- a/config/thunderx2/make_defs.mk
+++ b/config/thunderx2/make_defs.mk
@@ -70,7 +70,15 @@ endif
 
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
+ifeq ($(CC_VENDOR),gcc)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
 CRVECFLAGS     := $(CKVECFLAGS)
+endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/x86_64/make_defs.mk b/config/x86_64/make_defs.mk
index 4d038ff..520cd42 100644
--- a/config/x86_64/make_defs.mk
+++ b/config/x86_64/make_defs.mk
@@ -79,10 +79,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
diff --git a/config/zen/make_defs.mk b/config/zen/make_defs.mk
index f0752e9..1b9db53 100644
--- a/config/zen/make_defs.mk
+++ b/config/zen/make_defs.mk
@@ -83,10 +83,14 @@ endif
 # Flags specific to reference kernels.
 CROPTFLAGS     := $(CKOPTFLAGS)
 ifeq ($(CC_VENDOR),gcc)
-CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
+else
+ifeq ($(CC_VENDOR),clang)
+CRVECFLAGS     := $(CKVECFLAGS) -funsafe-math-optimizations -ffp-contract=fast
 else
 CRVECFLAGS     := $(CKVECFLAGS)
 endif
+endif
 
 # Store all of the variables here to new variables containing the
 # configuration name.
-- 
1.8.3.1