Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 695de5d

Browse files
committed
Split Makefile symbol CFLAGS_VECTOR into two symbols.
Replace CFLAGS_VECTOR with CFLAGS_UNROLL_LOOPS and CFLAGS_VECTORIZE, allowing us to distinguish whether we want to apply -funroll-loops, -ftree-vectorize, or both to a particular source file. Up to now the only consumer of the symbol has been checksum.c which wants both, so that there was no need to distinguish; but that's about to change. Amit Khandekar, reviewed and edited a little by me Discussion: https://postgr.es/m/CAJ3gD9evtA_vBo+WMYMyT-u=keHX7-r8p2w7OSRfXf42LTwCZQ@mail.gmail.com
1 parent 784b1ba commit 695de5d

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

configure

+19-13
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,8 @@ CPP
734734
CFLAGS_SL
735735
BITCODE_CXXFLAGS
736736
BITCODE_CFLAGS
737-
CFLAGS_VECTOR
737+
CFLAGS_VECTORIZE
738+
CFLAGS_UNROLL_LOOPS
738739
PERMIT_DECLARATION_AFTER_STATEMENT
739740
LLVM_BINPATH
740741
LLVM_CXXFLAGS
@@ -5266,9 +5267,12 @@ BITCODE_CFLAGS=""
52665267
user_BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
52675268
BITCODE_CXXFLAGS=""
52685269

5269-
# set CFLAGS_VECTOR from the environment, if available
5270-
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
5271-
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
5270+
# set CFLAGS_UNROLL_LOOPS and CFLAGS_VECTORIZE from the environment, if present
5271+
if test "$ac_env_CFLAGS_UNROLL_LOOPS_set" = set; then
5272+
CFLAGS_UNROLL_LOOPS=$ac_env_CFLAGS_UNROLL_LOOPS_value
5273+
fi
5274+
if test "$ac_env_CFLAGS_VECTORIZE_set" = set; then
5275+
CFLAGS_VECTORIZE=$ac_env_CFLAGS_VECTORIZE_value
52725276
fi
52735277

52745278
# Some versions of GCC support some additional useful warning flags.
@@ -6102,16 +6106,16 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fexcess_precision_standard" = x"yes"; then
61026106
fi
61036107

61046108

6105-
# Optimization flags for specific files that benefit from vectorization
6106-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -funroll-loops, for CFLAGS_VECTOR" >&5
6107-
$as_echo_n "checking whether ${CC} supports -funroll-loops, for CFLAGS_VECTOR... " >&6; }
6109+
# Optimization flags for specific files that benefit from loop unrolling
6110+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -funroll-loops, for CFLAGS_UNROLL_LOOPS" >&5
6111+
$as_echo_n "checking whether ${CC} supports -funroll-loops, for CFLAGS_UNROLL_LOOPS... " >&6; }
61086112
if ${pgac_cv_prog_CC_cflags__funroll_loops+:} false; then :
61096113
$as_echo_n "(cached) " >&6
61106114
else
61116115
pgac_save_CFLAGS=$CFLAGS
61126116
pgac_save_CC=$CC
61136117
CC=${CC}
6114-
CFLAGS="${CFLAGS_VECTOR} -funroll-loops"
6118+
CFLAGS="${CFLAGS_UNROLL_LOOPS} -funroll-loops"
61156119
ac_save_c_werror_flag=$ac_c_werror_flag
61166120
ac_c_werror_flag=yes
61176121
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6138,19 +6142,20 @@ fi
61386142
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__funroll_loops" >&5
61396143
$as_echo "$pgac_cv_prog_CC_cflags__funroll_loops" >&6; }
61406144
if test x"$pgac_cv_prog_CC_cflags__funroll_loops" = x"yes"; then
6141-
CFLAGS_VECTOR="${CFLAGS_VECTOR} -funroll-loops"
6145+
CFLAGS_UNROLL_LOOPS="${CFLAGS_UNROLL_LOOPS} -funroll-loops"
61426146
fi
61436147

61446148

6145-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -ftree-vectorize, for CFLAGS_VECTOR" >&5
6146-
$as_echo_n "checking whether ${CC} supports -ftree-vectorize, for CFLAGS_VECTOR... " >&6; }
6149+
# Optimization flags for specific files that benefit from vectorization
6150+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -ftree-vectorize, for CFLAGS_VECTORIZE" >&5
6151+
$as_echo_n "checking whether ${CC} supports -ftree-vectorize, for CFLAGS_VECTORIZE... " >&6; }
61476152
if ${pgac_cv_prog_CC_cflags__ftree_vectorize+:} false; then :
61486153
$as_echo_n "(cached) " >&6
61496154
else
61506155
pgac_save_CFLAGS=$CFLAGS
61516156
pgac_save_CC=$CC
61526157
CC=${CC}
6153-
CFLAGS="${CFLAGS_VECTOR} -ftree-vectorize"
6158+
CFLAGS="${CFLAGS_VECTORIZE} -ftree-vectorize"
61546159
ac_save_c_werror_flag=$ac_c_werror_flag
61556160
ac_c_werror_flag=yes
61566161
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6177,7 +6182,7 @@ fi
61776182
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__ftree_vectorize" >&5
61786183
$as_echo "$pgac_cv_prog_CC_cflags__ftree_vectorize" >&6; }
61796184
if test x"$pgac_cv_prog_CC_cflags__ftree_vectorize" = x"yes"; then
6180-
CFLAGS_VECTOR="${CFLAGS_VECTOR} -ftree-vectorize"
6185+
CFLAGS_VECTORIZE="${CFLAGS_VECTORIZE} -ftree-vectorize"
61816186
fi
61826187

61836188

@@ -6782,6 +6787,7 @@ fi
67826787

67836788

67846789

6790+
67856791
# Determine flags used to emit bitcode for JIT inlining. Need to test
67866792
# for behaviour changing compiler flags, to keep compatibility with
67876793
# compiler used for normal postgres code.

configure.ac

+11-6
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,12 @@ BITCODE_CFLAGS=""
466466
user_BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
467467
BITCODE_CXXFLAGS=""
468468

469-
# set CFLAGS_VECTOR from the environment, if available
470-
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
471-
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
469+
# set CFLAGS_UNROLL_LOOPS and CFLAGS_VECTORIZE from the environment, if present
470+
if test "$ac_env_CFLAGS_UNROLL_LOOPS_set" = set; then
471+
CFLAGS_UNROLL_LOOPS=$ac_env_CFLAGS_UNROLL_LOOPS_value
472+
fi
473+
if test "$ac_env_CFLAGS_VECTORIZE_set" = set; then
474+
CFLAGS_VECTORIZE=$ac_env_CFLAGS_VECTORIZE_value
472475
fi
473476

474477
# Some versions of GCC support some additional useful warning flags.
@@ -512,9 +515,10 @@ if test "$GCC" = yes -a "$ICC" = no; then
512515
# Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
513516
PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
514517
PGAC_PROG_CXX_CFLAGS_OPT([-fexcess-precision=standard])
518+
# Optimization flags for specific files that benefit from loop unrolling
519+
PGAC_PROG_CC_VAR_OPT(CFLAGS_UNROLL_LOOPS, [-funroll-loops])
515520
# Optimization flags for specific files that benefit from vectorization
516-
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
517-
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
521+
PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTORIZE, [-ftree-vectorize])
518522
# We want to suppress clang's unhelpful unused-command-line-argument warnings
519523
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
520524
# test for the positive form and if that works, add the negative form
@@ -555,7 +559,8 @@ elif test "$PORTNAME" = "hpux"; then
555559
PGAC_PROG_CXX_CFLAGS_OPT([+Olibmerrno])
556560
fi
557561

558-
AC_SUBST(CFLAGS_VECTOR)
562+
AC_SUBST(CFLAGS_UNROLL_LOOPS)
563+
AC_SUBST(CFLAGS_VECTORIZE)
559564

560565
# Determine flags used to emit bitcode for JIT inlining. Need to test
561566
# for behaviour changing compiler flags, to keep compatibility with

src/Makefile.global.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ SUN_STUDIO_CC = @SUN_STUDIO_CC@
259259
CXX = @CXX@
260260
CFLAGS = @CFLAGS@
261261
CFLAGS_SL = @CFLAGS_SL@
262-
CFLAGS_VECTOR = @CFLAGS_VECTOR@
262+
CFLAGS_UNROLL_LOOPS = @CFLAGS_UNROLL_LOOPS@
263+
CFLAGS_VECTORIZE = @CFLAGS_VECTORIZE@
263264
CFLAGS_SSE42 = @CFLAGS_SSE42@
264265
CFLAGS_ARMV8_CRC32C = @CFLAGS_ARMV8_CRC32C@
265266
PERMIT_DECLARATION_AFTER_STATEMENT = @PERMIT_DECLARATION_AFTER_STATEMENT@

src/backend/storage/page/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ OBJS = \
1919

2020
include $(top_srcdir)/src/backend/common.mk
2121

22-
# important optimizations flags for checksum.c
23-
checksum.o: CFLAGS += ${CFLAGS_VECTOR}
22+
# Provide special optimization flags for checksum.c
23+
checksum.o: CFLAGS += ${CFLAGS_UNROLL_LOOPS} ${CFLAGS_VECTORIZE}

0 commit comments

Comments
 (0)