gcc/gcc
Kewen Lin ca6eea0eb3 rs6000: Fix wrong RTL patterns for vector merge high/low short on LE
Commit r12-4496 changes some define_expands and define_insns
for vector merge high/low short, which are altivec_vmrg[hl]h.
These defines are mainly for built-in function vec_merge{h,l}
and some internal gen function needs.  These functions should
consider endianness, taking vec_mergeh as example, as PVIPR
defines, vec_mergeh "Merges the first halves (in element order)
of two vectors", it does note it's in element order.  So it's
mapped into vmrghh on BE while vmrglh on LE respectively.
Although the mapped insns are different, as the discussion in
PR106069, the RTL pattern should be still the same, it is
conformed before commit r12-4496, but gets changed into
different patterns on BE and LE starting from commit r12-4496.
Similar to 32-bit element case in commit log of r15-1504, this
16-bit element pattern on LE doesn't actually match what the
underlying insn is intended to represent, once some optimization
like combine does some changes basing on it, it would cause
the unexpected consequence.  The newly constructed test case
pr106069-2.c is a typical example for this issue on element type
short.

So this patch is to fix the wrong RTL pattern, ensure the
associated RTL patterns become the same as before which can
have the same semantic as their mapped insns.  With the
proposed patch, the expanders like altivec_vmrghh expands
into altivec_vmrghh_direct_be or altivec_vmrglh_direct_le
depending on endianness, "direct" can easily show which
insn would be generated, _be and _le are mainly for the
different RTL patterns as endianness.

Co-authored-by: Xionghu Luo <xionghuluo@tencent.com>

	PR target/106069
	PR target/115355

gcc/ChangeLog:

	* config/rs6000/altivec.md (altivec_vmrghh_direct): Rename to ...
	(altivec_vmrghh_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrghh_direct_le): New define_insn.
	(altivec_vmrglh_direct): Rename to ...
	(altivec_vmrglh_direct_be): ... this.  Add condition BYTES_BIG_ENDIAN.
	(altivec_vmrglh_direct_le): New define_insn.
	(altivec_vmrghh): Adjust by calling gen_altivec_vmrghh_direct_be
	for BE and gen_altivec_vmrglh_direct_le for LE.
	(altivec_vmrglh): Adjust by calling gen_altivec_vmrglh_direct_be
	for BE and gen_altivec_vmrghh_direct_le for LE.
	(vec_widen_umult_hi_v16qi): Adjust the call to
	gen_altivec_vmrghh_direct by gen_altivec_vmrghh for BE
	and by gen_altivec_vmrglh for LE.
	(vec_widen_smult_hi_v16qi): Likewise.
	(vec_widen_umult_lo_v16qi): Adjust the call to
	gen_altivec_vmrglh_direct by gen_altivec_vmrglh for BE
	and by gen_altivec_vmrghh for LE.
	(vec_widen_smult_lo_v16qi): Likewise.
	* config/rs6000/rs6000.cc (altivec_expand_vec_perm_const): Replace
	CODE_FOR_altivec_vmrghh_direct by
	CODE_FOR_altivec_vmrghh_direct_be for BE and
	CODE_FOR_altivec_vmrghh_direct_le for LE.  And replace
	CODE_FOR_altivec_vmrglh_direct by
	CODE_FOR_altivec_vmrglh_direct_be for BE and
	CODE_FOR_altivec_vmrglh_direct_le for LE.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr106069-2.c: New test.

(cherry picked from commit 812c70bf49)
2024-07-02 21:01:22 -05:00
..
ada Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
analyzer Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
c Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
c-family Daily bump. 2024-06-21 00:21:02 +00:00
common Workaround possible CPUID bug in Sandy Bridge. 2023-08-09 15:49:23 +08:00
config rs6000: Fix wrong RTL patterns for vector merge high/low short on LE 2024-07-02 21:01:22 -05:00
cp Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
d Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
doc Add support for -mcpu=grace 2024-06-27 10:26:52 +02:00
fortran Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
ginclude
go Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
jit Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
lto Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
objc Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
objcp Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
po Update ChangeLog and version files for release 2024-06-20 08:09:02 +00:00
rtl-ssa rtl-optimization/54052 - RTL SSA PHI insertion compile-time hog 2024-06-12 11:46:03 +02:00
testsuite rs6000: Fix wrong RTL patterns for vector merge high/low short on LE 2024-07-02 21:01:22 -05:00
ABOUT-GCC-NLS
acinclude.m4
aclocal.m4
addresses.h
adjust-alignment.cc
alias.cc Restore RTL alias analysis for hard frame pointer 2022-11-09 12:31:34 +01:00
alias.h
align.h
alloc-pool.cc
alloc-pool.h
array-traits.h
asan.cc asan, v3: Fix up handling of > 32 byte aligned variables with -fsanitize=address -fstack-protector* [PR110027] 2024-06-11 12:35:35 +02:00
asan.h
attr-fnspec.h tree-optimization/109609 - correctly interpret arg size in fnspec 2023-04-26 11:35:14 +02:00
attribs.cc attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] 2024-06-11 12:35:36 +02:00
attribs.h
auto-inc-dec.cc
auto-profile.cc
auto-profile.h
backend.h
BASE-VER Bump BASE-VER. 2024-06-20 10:44:08 +02:00
basic-block.h
bb-reorder.cc bb-reorder: Fix -freorder-blocks-and-partition ICEs on aarch64 with asm goto [PR110079] 2024-06-11 12:35:33 +02:00
bb-reorder.h
bitmap.cc tree-optimization/113910 - huge compile time during PTA 2024-06-04 10:07:30 +02:00
bitmap.h
btfout.cc
builtin-attrs.def
builtin-types.def
builtins.cc builtins: Force SAVE_EXPR for __builtin_{add,sub,mul}_overflow [PR108789] 2024-06-11 12:35:39 +02:00
builtins.def
builtins.h
caller-save.cc
calls.cc
calls.h
ccmp.cc
ccmp.h
cfg-flags.def
cfg.cc
cfg.h
cfganal.cc
cfganal.h
cfgbuild.cc cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719] 2023-02-10 13:41:59 +01:00
cfgbuild.h
cfgcleanup.cc
cfgcleanup.h
cfgexpand.cc cfgexpand: Workaround CSE of ADDR_EXPRs in VAR_DECL partitioning [PR113372] 2024-06-11 12:35:30 +02:00
cfgexpand.h
cfghooks.cc tree-optimization/107833 - invariant motion of uninit uses 2022-12-12 11:28:18 +01:00
cfghooks.h
cfgloop.cc
cfgloop.h
cfgloopanal.cc
cfgloopmanip.cc
cfgloopmanip.h
cfgrtl.cc cfgrtl: Fix MEM_EXPR update in duplicate_insn_chain [PR114924] 2024-06-12 13:41:40 +02:00
cfgrtl.h expand: Fix handling of asm goto outputs vs. PHI argument adjustments [PR113921] 2024-02-15 16:17:09 +01:00
cgraph.cc ipa: Self-DCE of uses of removed call LHSs (PR 108007) 2024-05-15 15:46:01 +02:00
cgraph.h ipa: Self-DCE of uses of removed call LHSs (PR 108007) 2024-05-15 15:46:01 +02:00
cgraphbuild.cc
cgraphclones.cc cgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk [PR108854] 2023-03-19 06:28:52 +01:00
cgraphunit.cc tree-profile: Disable indirect call profiling for IFUNC resolvers 2024-04-15 04:26:13 -07:00
ChangeLog Daily bump. 2024-07-02 00:20:50 +00:00
ChangeLog-1997
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020
ChangeLog-2021
ChangeLog.dataflow
ChangeLog.gimple-classes
ChangeLog.graphite
ChangeLog.jit
ChangeLog.lib
ChangeLog.ptr
ChangeLog.tree-ssa
ChangeLog.tuples
cif-code.def
collect2-aix.cc
collect2-aix.h
collect2.cc
collect2.h
collect-utils.cc
collect-utils.h
color-macros.h
combine-stack-adj.cc
combine.cc combine: Fix up simplify_compare_const [PR115092] 2024-06-11 12:35:38 +02:00
common.md
common.opt
compare-elim.cc
conditions.h
config.build
config.gcc LoongArch: Fix multiarch tuple canonization 2023-02-18 16:55:00 +08:00
config.host
config.in Darwin: Check as for .build_version support and use it if available. 2024-04-18 15:49:24 +01:00
configure Darwin: Check as for .build_version support and use it if available. 2024-04-18 15:49:24 +01:00
configure.ac Darwin: Check as for .build_version support and use it if available. 2024-04-18 15:49:24 +01:00
context.cc
context.h
convert.cc
convert.h
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
coretypes.h
coroutine-builtins.def
coroutine-passes.cc
coverage.cc
coverage.h
cppbuiltin.cc
cppbuiltin.h
cppdefault.cc
cppdefault.h
cprop.cc cprop: Do not set REG_EQUAL note when simplifying paradoxical subreg [PR110206] 2023-07-14 22:04:57 +02:00
cse.cc cse: Fix up CSE const_anchor handling [PR108193] 2023-02-10 13:50:07 +01:00
cselib.cc
cselib.h
cstamp-h.in
ctfc.cc
ctfc.h
ctfout.cc
data-streamer-in.cc
data-streamer-out.cc
data-streamer.cc
data-streamer.h
DATESTAMP Daily bump. 2024-07-03 00:21:39 +00:00
dbgcnt.cc
dbgcnt.def
dbgcnt.h
dbxout.cc
dbxout.h
dce.cc
dce.h
ddg.cc
ddg.h
debug.cc
debug.h
defaults.h
DEV-PHASE
df-core.cc
df-problems.cc
df-scan.cc
df.h
dfp.cc
dfp.h
diagnostic-color.cc
diagnostic-color.h
diagnostic-core.h
diagnostic-event-id.h
diagnostic-format-json.cc
diagnostic-metadata.h
diagnostic-path.h
diagnostic-show-locus.cc
diagnostic-spec.cc
diagnostic-spec.h
diagnostic-url.h
diagnostic.cc
diagnostic.def
diagnostic.h
digraph.cc
digraph.h
dojump.cc
dojump.h
dominance.cc middle-end/108500 - replace recursive domtree DFS traversal 2023-03-15 10:06:51 +01:00
dominance.h
domwalk.cc
domwalk.h
double-int.cc
double-int.h
dse.cc
dump-context.h
dumpfile.cc
dumpfile.h
dwarf2asm.cc
dwarf2asm.h
dwarf2cfi.cc
dwarf2ctf.cc
dwarf2ctf.h
dwarf2out.cc debug/112718 - reset all type units with -ffat-lto-objects 2024-05-17 11:33:30 +02:00
dwarf2out.h
early-remat.cc
edit-context.cc
edit-context.h
emit-rtl.cc
emit-rtl.h
errors.cc
errors.h
escaped_string.h
et-forest.cc
et-forest.h
except.cc
except.h
exec-tool.in
explow.cc Avoid creating (const (reg ...)) [PR108603] 2023-04-03 09:57:07 +01:00
explow.h
expmed.cc
expmed.h
expr.cc expr: Fix up store_expr into SUBREG_PROMOTED_* target [PR108264] 2023-02-10 13:55:53 +01:00
expr.h
fibonacci_heap.cc
fibonacci_heap.h
file-find.cc
file-find.h
file-prefix-map.cc
file-prefix-map.h
final.cc
fixed-value.cc
fixed-value.h
flag-types.h
flags.h
fold-const-call.cc
fold-const-call.h
fold-const.cc fold-const: Fix up CLZ handling in tree_call_nonnegative_warnv_p [PR115337] 2024-06-11 12:35:39 +02:00
fold-const.h
fp-test.cc
FSFChangeLog
FSFChangeLog.10
FSFChangeLog.11
function-abi.cc
function-abi.h
function-tests.cc
function.cc tree-inline: Fix up multiversioning with vector arguments [PR105554] 2023-03-19 06:28:58 +01:00
function.h tree-inline: Fix up multiversioning with vector arguments [PR105554] 2023-03-19 06:28:58 +01:00
fwprop.cc cprop: Do not set REG_EQUAL note when simplifying paradoxical subreg [PR110206] 2023-07-14 22:04:57 +02:00
gcc-ar.cc
gcc-main.cc
gcc-plugin.h
gcc-rich-location.cc
gcc-rich-location.h
gcc-symtab.h
gcc.cc driver: fix environ corruption after putenv() [PR106624] 2023-01-24 11:52:07 +01:00
gcc.h
gcov-counter.def
gcov-dump.cc
gcov-io.cc
gcov-io.h
gcov-tool.cc
gcov.cc
gcse-common.cc
gcse-common.h
gcse.cc
gcse.h
gdbasan.in
gdbhooks.py
gdbinit.in
gen-pass-instances.awk
genattr-common.cc
genattr.cc
genattrtab.cc
genautomata.cc
gencfn-macros.cc
gencheck.cc
genchecksum.cc
gencodes.cc
genconditions.cc
genconfig.cc
genconstants.cc
genemit.cc
genenums.cc
generic-match-head.cc tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C 2024-03-26 15:04:43 +00:00
generic-match.h
genextract.cc
genflags.cc
gengenrtl.cc
gengtype-lex.l
gengtype-parse.cc
gengtype-state.cc
gengtype.cc
gengtype.h
genhooks.cc
genmatch.cc middle-end/110200 - genmatch force-leaf and convert interaction 2023-06-12 11:03:14 +02:00
genmddeps.cc
genmddump.cc
genmodes.cc
genmultilib
genopinit.cc
genoutput.cc
genpeep.cc
genpreds.cc
genrecog.cc
gensupport.cc
gensupport.h
gentarget-def.cc
genversion.cc
ggc-common.cc ggc-common: Fix save PCH assertion 2024-06-11 12:35:31 +02:00
ggc-internal.h
ggc-none.cc
ggc-page.cc
ggc-tests.cc
ggc.h
gimple-array-bounds.cc
gimple-array-bounds.h
gimple-builder.cc
gimple-builder.h
gimple-expr.cc
gimple-expr.h
gimple-fold.cc Fix couple of endianness issues in fold_ctor_reference 2023-06-30 21:48:05 +02:00
gimple-fold.h
gimple-harden-conditionals.cc
gimple-if-to-switch.cc
gimple-isel.cc
gimple-iterator.cc
gimple-iterator.h
gimple-laddress.cc
gimple-loop-interchange.cc
gimple-loop-jam.cc
gimple-loop-versioning.cc
gimple-low.cc
gimple-low.h
gimple-match-head.cc tree-optimization/91838 - fix FAIL of g++.dg/opt/pr91838.C 2024-03-26 15:04:43 +00:00
gimple-match.h
gimple-predicate-analysis.cc
gimple-predicate-analysis.h
gimple-predict.h
gimple-pretty-print.cc
gimple-pretty-print.h
gimple-range-cache.cc gimple-range-cache: Fix ICEs when dumping details [PR111967] 2023-12-16 01:37:10 +01:00
gimple-range-cache.h
gimple-range-edge.cc
gimple-range-edge.h
gimple-range-fold.cc
gimple-range-fold.h
gimple-range-gori.cc Add missing return in gori_compute::logical_combine 2023-09-26 21:02:29 +02:00
gimple-range-gori.h
gimple-range-path.cc
gimple-range-path.h
gimple-range-tests.cc
gimple-range-trace.cc
gimple-range-trace.h
gimple-range.cc
gimple-range.h
gimple-ssa-backprop.cc Fix PR 110386: backprop vs ABSU_EXPR 2024-05-09 00:22:53 -07:00
gimple-ssa-evrp-analyze.cc
gimple-ssa-evrp-analyze.h
gimple-ssa-evrp.cc
gimple-ssa-isolate-paths.cc
gimple-ssa-nonnull-compare.cc
gimple-ssa-split-paths.cc
gimple-ssa-sprintf.cc gimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument [PR114876] 2024-06-11 12:35:37 +02:00
gimple-ssa-store-merging.cc store-merging: Fix up >= 64 bit insertion [PR111015] 2023-08-30 11:43:40 +02:00
gimple-ssa-strength-reduction.cc
gimple-ssa-warn-access.cc warn-access: Fix handling of unnamed types [PR109804] 2024-05-08 10:08:24 -07:00
gimple-ssa-warn-access.h
gimple-ssa-warn-alloca.cc tree-optimization/107898 - ICE with -Walloca-larger-than 2022-12-12 11:29:13 +01:00
gimple-ssa-warn-restrict.cc
gimple-ssa-warn-restrict.h
gimple-ssa.h
gimple-streamer-in.cc
gimple-streamer-out.cc
gimple-streamer.h
gimple-walk.cc
gimple-walk.h
gimple-warn-recursion.cc
gimple.cc
gimple.def
gimple.h
gimplify-me.cc
gimplify-me.h
gimplify.cc gcov-profile/114715 - missing coverage for switch 2024-05-16 11:55:44 +02:00
gimplify.h
glimits.h
godump.cc
graph.cc
graph.h
graphds.cc
graphds.h
graphite-dependences.cc
graphite-isl-ast-to-gimple.cc
graphite-optimize-isl.cc
graphite-poly.cc
graphite-scop-detection.cc
graphite-sese-to-poly.cc
graphite.cc
graphite.h
graphviz.cc
graphviz.h
gsstruct.def
gstab.h
gsyms.h
gsyslimits.h
gtm-builtins.def
haifa-sched.cc
hard-reg-set.h
hash-map-tests.cc
hash-map-traits.h
hash-map.h
hash-set-tests.cc
hash-set.h
hash-table.cc
hash-table.h
hash-traits.h
highlev-plugin-common.h
hooks.cc
hooks.h
host-default.cc
hosthooks-def.h
hosthooks.h
hw-doloop.cc
hw-doloop.h
hwint.cc
hwint.h
ifcvt.cc
ifcvt.h
inchash.cc
inchash.h
incpath.cc
incpath.h
init-regs.cc
input.cc
input.h
insn-addr.h
insn-notes.def
int-vector-builder.h
internal-fn.cc internal-fn: Temporarily disable flag_trapv during .{ADD,SUB,MUL}_OVERFLOW etc. expansion [PR114753] 2024-06-11 12:35:36 +02:00
internal-fn.def
internal-fn.h
intl.cc
intl.h
ipa-comdats.cc
ipa-cp.cc ipa: Compare jump functions in ICF (PR 113907) 2024-05-28 13:47:29 +02:00
ipa-devirt.cc Fix invalid devirtualization when combining final keyword and anonymous types 2023-04-27 13:54:48 +02:00
ipa-fnsummary.cc
ipa-fnsummary.h
ipa-free-lang-data.cc
ipa-icf-gimple.cc ipa: Compare jump functions in ICF (PR 113907) 2024-05-28 13:47:29 +02:00
ipa-icf-gimple.h
ipa-icf.cc icf: Reset SSA_NAME_{PTR,RANGE}_INFO in successfully merged functions [PR113907] 2024-06-11 12:35:33 +02:00
ipa-icf.h
ipa-inline-analysis.cc
ipa-inline-transform.cc
ipa-inline.cc
ipa-inline.h
ipa-modref-tree.cc
ipa-modref-tree.h
ipa-modref.cc
ipa-modref.h
ipa-param-manipulation.cc ipa: Self-DCE of uses of removed call LHSs (PR 108007) 2024-05-15 15:46:01 +02:00
ipa-param-manipulation.h ipa: Self-DCE of uses of removed call LHSs (PR 108007) 2024-05-15 15:46:01 +02:00
ipa-polymorphic-call.cc
ipa-predicate.cc
ipa-predicate.h
ipa-profile.cc
ipa-prop.cc ipa: Compare jump functions in ICF (PR 113907) 2024-05-28 13:47:29 +02:00
ipa-prop.h ipa: Compare jump functions in ICF (PR 113907) 2024-05-28 13:47:29 +02:00
ipa-pure-const.cc ipa/105676 - pure attribute suggestion for const function 2023-04-17 11:13:16 +02:00
ipa-ref.cc
ipa-ref.h
ipa-reference.cc
ipa-reference.h
ipa-split.cc
ipa-sra.cc
ipa-utils.cc
ipa-utils.h
ipa-visibility.cc
ipa.cc
ira-build.cc
ira-color.cc gcc: fix PR rtl-optimization/107482 2022-11-28 19:41:31 -08:00
ira-conflicts.cc
ira-costs.cc IRA: Use minimal cost for hard register movement 2023-03-31 08:14:20 -04:00
ira-emit.cc
ira-int.h
ira-lives.cc
ira.cc IRA: Make sure array is big enough 2022-10-27 09:41:17 +02:00
ira.h
is-a.h
iterator-utils.h
json.cc
json.h
jump.cc
langhooks-def.h
langhooks.cc
langhooks.h
LANGUAGES
lcm.cc
lcm.h
libfuncs.h
limitx.h
limity.h
lists.cc
lock-and-run.sh
loop-doloop.cc
loop-init.cc
loop-invariant.cc loop-invariant: Split preheader edge if the preheader bb ends with jump [PR106751] 2023-02-10 13:46:30 +01:00
loop-iv.cc
loop-unroll.cc
loop-unroll.h
lower-subreg.cc
lower-subreg.h
lra-assigns.cc
lra-coalesce.cc
lra-constraints.cc [PR111497][LRA]: Copy substituted equivalence 2024-06-12 13:39:20 +02:00
lra-eliminations.cc lra: Avoid unfolded plus-0 2023-10-19 10:49:19 +01:00
lra-int.h
lra-lives.cc
lra-remat.cc
lra-spills.cc lra: Replace subregs in bare uses & clobbers [PR108681] 2023-04-03 09:57:08 +01:00
lra.cc [PR111497][LRA]: Copy substituted equivalence 2024-06-12 13:39:20 +02:00
lra.h
lto-cgraph.cc
lto-compress.cc
lto-compress.h
lto-opts.cc
lto-section-in.cc
lto-section-names.h
lto-section-out.cc
lto-streamer-in.cc
lto-streamer-out.cc
lto-streamer.cc
lto-streamer.h
lto-wrapper.cc lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time 2024-05-16 11:55:47 +02:00
machmode.def
machmode.h
main.cc
Makefile.in
match.pd middle-end/110176 - wrong zext (bool) <= (int) 4294967295u folding 2024-05-17 11:40:15 +02:00
mcf.cc
mem-stats-traits.h
mem-stats.h
memmodel.h
memory-block.cc
memory-block.h
mkconfig.sh
mode-classes.def
mode-switching.cc
modulo-sched.cc
multiple_target.cc
mux-utils.h
obstack-utils.h
omp-builtins.def
omp-expand.cc omp-expand.cc: Fix wrong code with non-rectangular loop nest [PR111017] 2023-09-01 14:33:40 +02:00
omp-expand.h
omp-general.cc
omp-general.h
omp-low.cc OpenMP/Fortran: Fix handling of optional is_device_ptr + bind(C) [PR108546] 2023-03-08 10:50:45 +01:00
omp-low.h
omp-oacc-kernels-decompose.cc Make 'c-c++-common/goacc/kernels-decompose-pr100400-1-*.c' behave consistently, regardless of checking level 2022-10-20 18:12:41 +02:00
omp-oacc-neuter-broadcast.cc
omp-offload.cc
omp-offload.h
omp-simd-clone.cc
omp-simd-clone.h
ONEWS
opt-functions.awk
opt-gather.awk
opt-include.awk
opt-problem.cc
opt-problem.h
opt-read.awk
opt-suggestions.cc
opt-suggestions.h
optabs-libfuncs.cc
optabs-libfuncs.h
optabs-query.cc
optabs-query.h
optabs-tree.cc
optabs-tree.h
optabs.cc
optabs.def
optabs.h
optc-gen.awk
optc-save-gen.awk options: fix cl_target_option_print_diff() with strings 2023-02-10 14:25:53 +01:00
opth-gen.awk
optinfo-emit-json.cc
optinfo-emit-json.h
optinfo.cc
optinfo.h
opts-common.cc diagnostics: Fix add_misspelling_candidates [PR115440] 2024-06-20 10:49:42 +02:00
opts-diagnostic.h
opts-global.cc
opts-jobserver.h lto: support --jobserver-style=fifo for recent GNU make 2022-12-22 11:24:47 +01:00
opts.cc opts: SANITIZE_ADDRESS wrongly cleared [PR108543] 2023-01-26 13:39:19 -05:00
opts.h
ordered-hash-map-tests.cc
ordered-hash-map.h
output.h
params.opt Fix typo in -param=vect-induction-float= attributes 2023-04-05 21:24:34 -07:00
pass_manager.h
passes.cc
passes.def
plugin.cc
plugin.def
plugin.h
pointer-query.cc
pointer-query.h
poly-int-types.h
poly-int.h
postreload-gcse.cc
postreload.cc
predict.cc predict: Don't emit -Wsuggest-attribute=cold warning for functions which already have that attribute [PR105685] 2023-04-18 09:15:20 +02:00
predict.def
predict.h
prefix.cc
prefix.h
pretty-print.cc
pretty-print.h
print-rtl-function.cc
print-rtl.cc
print-rtl.h
print-tree.cc
print-tree.h
profile-count.cc
profile-count.h
profile.cc Relax assertion in profiler 2022-10-25 12:25:19 +02:00
profile.h
range-op.cc Fix range-ops operator_addr. 2024-05-13 13:46:08 -04:00
range-op.h
range.cc
range.h
read-md.cc
read-md.h
read-rtl-function.cc
read-rtl-function.h
read-rtl.cc
README.Portability
real.cc
real.h
realmpfr.cc
realmpfr.h
recog.cc
recog.h
ree.cc ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] 2023-02-10 14:34:38 +01:00
reg-notes.def
reg-stack.cc reg-stack: Fix a -fcompare-debug bug in reg-stack [PR107183] 2022-11-20 18:47:09 +01:00
regcprop.cc
regcprop.h
reginfo.cc
regrename.cc
regrename.h
regs.h
regset.h
regstat.cc
reload1.cc
reload.cc
reload.h
reorg.cc
resource.cc
resource.h
rtl-error.cc
rtl-error.h
rtl-iter.h
rtl-ssa.h
rtl-tests.cc
rtl.cc
rtl.def
rtl.h
rtlanal.cc rtlanal: Fix set_noop_p for volatile loads or stores [PR114768] 2024-06-11 12:35:37 +02:00
rtlanal.h cprop: Do not set REG_EQUAL note when simplifying paradoxical subreg [PR110206] 2023-07-14 22:04:57 +02:00
rtlhash.cc
rtlhash.h
rtlhooks-def.h
rtlhooks.cc
rtx-vector-builder.cc
rtx-vector-builder.h
run-rtl-passes.cc
run-rtl-passes.h
sancov.cc
sanitizer.def
sanopt.cc sanopt: Return TODO_cleanup_cfg if any .{UB,HWA,A}SAN_* calls were lowered [PR106190] 2023-04-18 09:15:21 +02:00
sbitmap.cc
sbitmap.h
sched-deps.cc
sched-ebb.cc
sched-int.h
sched-rgn.cc
sel-sched-dump.cc
sel-sched-dump.h
sel-sched-ir.cc
sel-sched-ir.h
sel-sched.cc
sel-sched.h
selftest-diagnostic.cc diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973] 2023-03-19 06:28:54 +01:00
selftest-diagnostic.h
selftest-rtl.cc
selftest-rtl.h
selftest-run-tests.cc
selftest.cc
selftest.h
sese.cc
sese.h
shortest-paths.h
shrink-wrap.cc
shrink-wrap.h
signop.h
simplify-rtx.cc
sort.cc
sparseset.cc
sparseset.h
spellcheck-tree.cc
spellcheck-tree.h
spellcheck.cc
spellcheck.h
splay-tree-utils.cc
splay-tree-utils.h
splay-tree-utils.tcc
sreal.cc
sreal.h
ssa-iterators.h
ssa.h
stab.def
stack-ptr-mod.cc
statistics.cc
statistics.h
stmt.cc
stmt.h
stor-layout.cc
stor-layout.h
store-motion.cc
streamer-hooks.cc
streamer-hooks.h
stringpool.cc
stringpool.h
substring-locations.cc
substring-locations.h
symbol-summary.h
symtab-clones.cc
symtab-clones.h
symtab-thunks.cc
symtab-thunks.h
symtab.cc middle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes 2024-04-15 04:26:13 -07:00
sync-builtins.def
system.h Include safe-ctype.h after C++ standard headers, to avoid over-poisoning 2024-06-11 19:06:42 +01:00
target-def.h
target-globals.cc
target-globals.h
target-hooks-macros.h
target-insns.def
target.def
target.h
targhooks.cc
targhooks.h
timevar.cc
timevar.def
timevar.h
toplev.cc
toplev.h
tracer.cc
tracer.h
trans-mem.cc
trans-mem.h
tree-affine.cc
tree-affine.h
tree-call-cdce.cc
tree-cfg.cc tree-optimization/107865 - ICE with outlining of loops 2022-12-12 11:28:42 +01:00
tree-cfg.h
tree-cfgcleanup.cc
tree-cfgcleanup.h
tree-chrec.cc
tree-chrec.h
tree-complex.cc
tree-core.h
tree-data-ref.cc vect: Fix access size alignment assumption [PR115192] 2024-06-04 08:47:47 +01:00
tree-data-ref.h
tree-dfa.cc
tree-dfa.h
tree-diagnostic-path.cc
tree-diagnostic.cc
tree-diagnostic.h
tree-dump.cc
tree-dump.h
tree-eh.cc
tree-eh.h
tree-emutls.cc
tree-hash-traits.h
tree-hasher.h
tree-if-conv.cc tree-optimization/108076 - if-conversion and forced labels 2023-01-24 14:36:36 +01:00
tree-if-conv.h
tree-inline.cc tree-inline: Remove .ASAN_MARK calls when inlining functions into no_sanitize callers [PR114956] 2024-06-11 12:35:38 +02:00
tree-inline.h
tree-into-ssa.cc middle-end/40635 - SSA update losing PHI arg loations 2024-06-12 13:07:19 +02:00
tree-into-ssa.h
tree-iterator.cc
tree-iterator.h
tree-loop-distribution.cc tree-optimization/112281 - loop distribution and zero dependence distances 2024-05-17 11:35:07 +02:00
tree-nested.cc openmp: Copy DECL_LANG_SPECIFIC and DECL_LANG_FLAG_? to tree-nested decl copy [PR114825] 2024-06-11 12:35:37 +02:00
tree-nested.h
tree-nrv.cc
tree-object-size.cc tree-object-size: Robustify alloc_size attribute handling [PR113013] 2023-12-18 10:15:13 +01:00
tree-object-size.h
tree-outof-ssa.cc
tree-outof-ssa.h
tree-parloops.cc
tree-parloops.h
tree-pass.h
tree-phinodes.cc
tree-phinodes.h
tree-predcom.cc tree-optimization/106892 - avoid invalid pointer association in predcom 2022-10-11 13:22:46 +02:00
tree-pretty-print.cc
tree-pretty-print.h
tree-profile.cc tree-profile: Disable indirect call profiling for IFUNC resolvers 2024-04-15 04:26:13 -07:00
tree-scalar-evolution.cc tree-optimization/111445 - simple_iv simplification fault 2023-11-27 12:51:14 +01:00
tree-scalar-evolution.h
tree-sra.cc sra: Disqualify bases of operands of asm gotos 2024-02-02 13:29:32 +01:00
tree-sra.h
tree-ssa-address.cc
tree-ssa-address.h
tree-ssa-alias-compare.h
tree-ssa-alias.cc tree-optimization/109609 - correctly interpret arg size in fnspec 2023-04-26 11:35:14 +02:00
tree-ssa-alias.h
tree-ssa-ccp.cc tree-ssa-ccp, wide-int: Fix up handling of [LR]ROTATE_EXPR in bitwise ccp [PR109778] 2023-05-09 12:52:01 +02:00
tree-ssa-ccp.h
tree-ssa-coalesce.cc
tree-ssa-coalesce.h
tree-ssa-copy.cc
tree-ssa-dce.cc tree-optimization: [PR108684] ICE in verify_ssa due to simple_dce_from_worklist 2023-03-10 21:52:38 +00:00
tree-ssa-dce.h
tree-ssa-dom.cc tree-ssa-dom: can_infer_simple_equiv fixes [PR108068] 2023-02-10 13:52:09 +01:00
tree-ssa-dom.h
tree-ssa-dse.cc Fix internal error on non-byte-aligned reference in GIMPLE DSE 2024-02-27 19:50:47 +01:00
tree-ssa-dse.h
tree-ssa-forwprop.cc tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR 2023-04-27 14:05:24 +02:00
tree-ssa-ifcombine.cc tree-optimization/111070 - fix ICE with recent ifcombine fix 2024-06-11 09:12:35 +02:00
tree-ssa-live.cc
tree-ssa-live.h
tree-ssa-loop-ch.cc
tree-ssa-loop-im.cc tree-optimization/111019 - invariant motion and aliasing 2023-11-27 11:27:34 +01:00
tree-ssa-loop-ivcanon.cc tree-optimization/110298 - CFG cleanup and stale nb_iterations 2023-06-23 12:34:03 +02:00
tree-ssa-loop-ivopts.cc tree-optimization/110702 - avoid zero-based memory references in IVOPTs 2023-11-27 11:26:58 +01:00
tree-ssa-loop-ivopts.h
tree-ssa-loop-manip.cc
tree-ssa-loop-manip.h
tree-ssa-loop-niter.cc tree-optimization/108793 - niter compute type mismatch 2023-03-15 10:07:57 +01:00
tree-ssa-loop-niter.h
tree-ssa-loop-prefetch.cc rs6000: Fix wrong align passed to build_aligned_type [PR88309] 2024-04-24 21:33:12 -05:00
tree-ssa-loop-split.cc
tree-ssa-loop-unswitch.cc tree-optimization/111917 - bougs IL after guard hoisting 2023-11-27 12:52:27 +01:00
tree-ssa-loop.cc
tree-ssa-loop.h
tree-ssa-math-opts.cc tree-optimization/114672 - WIDEN_MULT_PLUS_EXPR type mismatch 2024-05-02 20:22:54 +01:00
tree-ssa-math-opts.h
tree-ssa-operands.cc
tree-ssa-operands.h
tree-ssa-phiopt.cc PHIOPT: Don't transform minmax if middle bb contains a phi [PR115143] 2024-06-11 10:17:07 -07:00
tree-ssa-phiprop.cc
tree-ssa-pre.cc tree-optimization/110515 - wrong code with LIM + PRE 2023-11-27 11:25:36 +01:00
tree-ssa-propagate.cc
tree-ssa-propagate.h
tree-ssa-reassoc.cc tree-optimization/111614 - missing convert in undistribute_bitref_for_vector 2023-11-27 12:51:54 +01:00
tree-ssa-reassoc.h
tree-ssa-sccvn.cc tree-optimization/109491 - ICE in expressions_equal_p 2023-04-17 11:13:17 +02:00
tree-ssa-sccvn.h
tree-ssa-scopedtables.cc
tree-ssa-scopedtables.h
tree-ssa-sink.cc
tree-ssa-strlen.cc tree-ssa-strlen: Fix up handle_store [PR113603] 2024-06-11 12:35:31 +02:00
tree-ssa-strlen.h
tree-ssa-structalias.cc ipa/109983 - (IPA) PTA speedup 2023-11-27 11:20:59 +01:00
tree-ssa-tail-merge.cc tree-optimization/110556 - tail merging still pre-tuples 2023-11-27 11:26:28 +01:00
tree-ssa-ter.cc
tree-ssa-ter.h
tree-ssa-threadbackward.cc
tree-ssa-threadedge.cc
tree-ssa-threadedge.h
tree-ssa-threadupdate.cc
tree-ssa-threadupdate.h
tree-ssa-uncprop.cc
tree-ssa-uninit.cc tree-optimization/105937 - avoid uninit diagnostics crossing iterations 2022-10-11 13:21:12 +02:00
tree-ssa.cc middle-end/111818 - failed DECL_NOT_GIMPLE_REG_P setting of volatile 2023-11-27 12:52:11 +01:00
tree-ssa.h tree-optimization/107833 - invariant motion of uninit uses 2022-12-12 11:28:18 +01:00
tree-ssanames.cc
tree-ssanames.h
tree-stdarg.cc
tree-stdarg.h
tree-streamer-in.cc
tree-streamer-out.cc
tree-streamer.cc
tree-streamer.h
tree-switch-conversion.cc
tree-switch-conversion.h
tree-tailcall.cc
tree-vect-data-refs.cc tree-optimization/111137 - dependence checking for SLP 2023-12-15 13:18:57 +01:00
tree-vect-generic.cc veclower: improve selection of vector mode when lowering [PR 112787] 2024-02-19 16:15:46 +00:00
tree-vect-loop-manip.cc tree-optimization/108816 - vect versioning check split confusion 2023-03-15 10:08:26 +01:00
tree-vect-loop.cc vect: Don't clear base_misaligned in update_epilogue_loop_vinfo [PR114566] 2024-06-11 12:35:35 +02:00
tree-vect-patterns.cc vect: Tighten vect_determine_precisions_from_range [PR113281] 2024-06-04 08:47:48 +01:00
tree-vect-slp-patterns.cc tree-optimization/107766 - ICE with recent -ffp-contract=off fix 2022-12-12 11:26:53 +01:00
tree-vect-slp.cc tree-optimization/110381 - preserve SLP permutation with in-order reductions 2024-06-04 10:07:30 +02:00
tree-vect-stmts.cc tree-optimization/114375 - disallow SLP discovery of permuted mask loads 2024-05-16 11:55:47 +02:00
tree-vector-builder.cc
tree-vector-builder.h
tree-vectorizer.cc
tree-vectorizer.h
tree-vrp.cc
tree-vrp.h
tree.cc middle-end/112732 - stray TYPE_ALIAS_SET in type variant 2024-06-04 10:07:30 +02:00
tree.def
tree.h tree-optimization/106904 - bogus -Wstringopt-overflow with vectors 2023-03-15 10:04:00 +01:00
treestruct.def
tristate.cc
tristate.h
tsan.cc tsan: Don't instrument non-generic AS accesses [PR111736] 2024-04-23 16:28:23 +02:00
tsan.h
tsystem.h
typeclass.h
typed-splay-tree.cc
typed-splay-tree.h
ubsan.cc ubsan: Use right address space for MEM_REF created for bool/enum sanitization [PR115172] 2024-05-28 19:08:51 +02:00
ubsan.h
valtrack.cc
valtrack.h
value-pointer-equiv.cc
value-pointer-equiv.h
value-prof.cc
value-prof.h
value-query.cc
value-query.h
value-range-equiv.cc
value-range-equiv.h
value-range.cc
value-range.h Fix range-ops operator_addr. 2024-05-13 13:46:08 -04:00
value-relation.cc
value-relation.h
var-tracking.cc
varasm.cc varasm: check float size [PR109359] 2024-02-05 16:39:17 -05:00
varasm.h
varpool.cc
vec-perm-indices.cc
vec-perm-indices.h
vec.cc
vec.h
vector-builder.h
vmsdbg.h
vmsdbgout.cc
vr-values.cc
vr-values.h
vtable-verify.cc
vtable-verify.h
warning-control.cc
web.cc
wide-int-bitmask.h
wide-int-print.cc
wide-int-print.h
wide-int.cc wide-int: Fix up wi::divmod_internal [PR110731] 2023-12-16 01:37:09 +01:00
wide-int.h tree-ssa-ccp, wide-int: Fix up handling of [LR]ROTATE_EXPR in bitwise ccp [PR109778] 2023-05-09 12:52:01 +02:00
xcoff.h
xcoffout.cc
xcoffout.h

Copyright (C) 2000-2022 Free Software Foundation, Inc.

This file is intended to contain a few notes about writing C code
within GCC so that it compiles without error on the full range of
compilers GCC needs to be able to compile on.

The problem is that many ISO-standard constructs are not accepted by
either old or buggy compilers, and we keep getting bitten by them.
This knowledge until now has been sparsely spread around, so I
thought I'd collect it in one useful place.  Please add and correct
any problems as you come across them.

I'm going to start from a base of the ISO C90 standard, since that is
probably what most people code to naturally.  Obviously using
constructs introduced after that is not a good idea.

For the complete coding style conventions used in GCC, please read
http://gcc.gnu.org/codingconventions.html


String literals
---------------

Some compilers like MSVC++ have fairly low limits on the maximum
length of a string literal; 509 is the lowest we've come across.  You
may need to break up a long printf statement into many smaller ones.


Empty macro arguments
---------------------

ISO C (6.8.3 in the 1990 standard) specifies the following:

If (before argument substitution) any argument consists of no
preprocessing tokens, the behavior is undefined.

This was relaxed by ISO C99, but some older compilers emit an error,
so code like

#define foo(x, y) x y
foo (bar, )

needs to be coded in some other way.


Avoid unnecessary test before free
----------------------------------

Since SunOS 4 stopped being a reasonable portability target,
(which happened around 2007) there has been no need to guard
against "free (NULL)".  Thus, any guard like the following
constitutes a redundant test:

  if (P)
    free (P);

It is better to avoid the test.[*]
Instead, simply free P, regardless of whether it is NULL.

[*] However, if your profiling exposes a test like this in a
performance-critical loop, say where P is nearly always NULL, and
the cost of calling free on a NULL pointer would be prohibitively
high, consider using __builtin_expect, e.g., like this:

  if (__builtin_expect (ptr != NULL, 0))
    free (ptr);



Trigraphs
---------

You weren't going to use them anyway, but some otherwise ISO C
compliant compilers do not accept trigraphs.


Suffixes on Integer Constants
-----------------------------

You should never use a 'l' suffix on integer constants ('L' is fine),
since it can easily be confused with the number '1'.


			Common Coding Pitfalls
			======================

errno
-----

errno might be declared as a macro.


Implicit int
------------

In C, the 'int' keyword can often be omitted from type declarations.
For instance, you can write

  unsigned variable;

as shorthand for

  unsigned int variable;

There are several places where this can cause trouble.  First, suppose
'variable' is a long; then you might think

  (unsigned) variable

would convert it to unsigned long.  It does not.  It converts to
unsigned int.  This mostly causes problems on 64-bit platforms, where
long and int are not the same size.

Second, if you write a function definition with no return type at
all:

  operate (int a, int b)
  {
    ...
  }

that function is expected to return int, *not* void.  GCC will warn
about this.

Implicit function declarations always have return type int.  So if you
correct the above definition to

  void
  operate (int a, int b)
  ...

but operate() is called above its definition, you will get an error
about a "type mismatch with previous implicit declaration".  The cure
is to prototype all functions at the top of the file, or in an
appropriate header.

Char vs unsigned char vs int
----------------------------

In C, unqualified 'char' may be either signed or unsigned; it is the
implementation's choice.  When you are processing 7-bit ASCII, it does
not matter.  But when your program must handle arbitrary binary data,
or fully 8-bit character sets, you have a problem.  The most obvious
issue is if you have a look-up table indexed by characters.

For instance, the character '\341' in ISO Latin 1 is SMALL LETTER A
WITH ACUTE ACCENT.  In the proper locale, isalpha('\341') will be
true.  But if you read '\341' from a file and store it in a plain
char, isalpha(c) may look up character 225, or it may look up
character -31.  And the ctype table has no entry at offset -31, so
your program will crash.  (If you're lucky.)

It is wise to use unsigned char everywhere you possibly can.  This
avoids all these problems.  Unfortunately, the routines in <string.h>
take plain char arguments, so you have to remember to cast them back
and forth - or avoid the use of strxxx() functions, which is probably
a good idea anyway.

Another common mistake is to use either char or unsigned char to
receive the result of getc() or related stdio functions.  They may
return EOF, which is outside the range of values representable by
char.  If you use char, some legal character value may be confused
with EOF, such as '\377' (SMALL LETTER Y WITH UMLAUT, in Latin-1).
The correct choice is int.

A more subtle version of the same mistake might look like this:

  unsigned char pushback[NPUSHBACK];
  int pbidx;
  #define unget(c) (assert(pbidx < NPUSHBACK), pushback[pbidx++] = (c))
  #define get(c) (pbidx ? pushback[--pbidx] : getchar())
  ...
  unget(EOF);

which will mysteriously turn a pushed-back EOF into a SMALL LETTER Y
WITH UMLAUT.


Other common pitfalls
---------------------

o Expecting 'plain' char to be either sign or unsigned extending.

o Shifting an item by a negative amount or by greater than or equal to
  the number of bits in a type (expecting shifts by 32 to be sensible
  has caused quite a number of bugs at least in the early days).

o Expecting ints shifted right to be sign extended.

o Modifying the same value twice within one sequence point.

o Host vs. target floating point representation, including emitting NaNs
  and Infinities in a form that the assembler handles.

o qsort being an unstable sort function (unstable in the sense that
  multiple items that sort the same may be sorted in different orders
  by different qsort functions).

o Passing incorrect types to fprintf and friends.

o Adding a function declaration for a module declared in another file to
  a .c file instead of to a .h file.