Commit Graph

15 Commits

Author SHA1 Message Date
Marek Polacek faec5f2473 re PR tree-optimization/80079 (Conditional jump or move depends on uninitialised value(s): gimple-ssa-store-merging.c:768)
PR tree-optimization/80079
	* gimple-ssa-store-merging.c (class pass_store_merging): Initialize
	m_stores_head.

Co-Authored-By: Markus Trippelsdorf <markus@trippelsdorf.de>

From-SVN: r246224
2017-03-17 13:14:42 +00:00
Alexandre Oliva 50b6d6761b stabilize store merging
Don't let pointer randomization change the order in which we process
store chains.  This may cause SSA_NAMEs to be released in different
order, and if they're reused later, they may cause differences in SSA
partitioning, leading to differences in expand, and ultimately to
different code.

bootstrap-debug-lean (-fcompare-debug) on i686-linux-gnu has failed in
haifa-sched.c since r245196 exposed the latent ordering problem in
store merging.  In this case, the IR differences (different SSA names
selected for copies in out-of-SSA, resulting in some off-by-one
differences in pseudos) were not significant enough to be visible in
the compiler output.


for  gcc/ChangeLog

	* gimple-ssa-store-merging.c (struct imm_store_chain_info):
	Add linked-list forward and backlinks.  Insert on
	construction, remove on destruction.
	(class pass_store_merging): Add m_stores_head field.
	(pass_store_merging::terminate_and_process_all_chains):
	Iterate over m_stores_head list.
	(pass_store_merging::terminate_all_aliasing_chains):
	Likewise.
	(pass_store_merging::execute): Check for debug stmts first.
	Push new chains onto the m_stores_head stack.

From-SVN: r246213
2017-03-16 23:31:01 +00:00
Jakub Jelinek ad1de65225 re PR tree-optimization/79737 (wrong code at -O2 and -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes))
PR tree-optimization/79737
	* gimple-ssa-store-merging.c (encode_tree_to_bitpos): If bitlen is
	a multiple of BITS_PER_UNIT and !BYTES_BIG_ENDIAN, clear
	tmpbuf[byte_size - 1].  Call natice_encode_expr with byte_size - 1
	instead of byte_size.  Formatting fix.
	(shift_bytes_in_array_right): Formatting fix.

	* gcc.c-torture/execute/pr79737-1.c: New test.
	* gcc.c-torture/execute/pr79737-2.c: New test.

From-SVN: r245795
2017-02-28 23:39:11 +01:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jakub Jelinek 46a6139530 re PR tree-optimization/78436 (incorrect write to larger-than-type bitfield (signed char x:9))
PR tree-optimization/78436
	* gimple-ssa-store-merging.c (zero_char_buf): Removed.
	(shift_bytes_in_array, shift_bytes_in_array_right,
	merged_store_group::apply_stores): Formatting fixes.
	(clear_bit_region): Likewise.  Use memset.
	(encode_tree_to_bitpos): Formatting fixes.  Fix comment typos - EPXR
	instead of EXPR and inerted instead of inserted.  Use memset instead
	of zero_char_buf.  For !BYTES_BIG_ENDIAN decrease byte_size by 1
	if shift_amnt is 0.

	* gcc.c-torture/execute/pr78436.c: New test.

From-SVN: r242691
2016-11-22 11:15:43 +01:00
Kyrylo Tkachov c22d878716 [2/2] Add store merging unit tests
* gimple-ssa-store-merging.c: Include selftest.h
	(verify_array_eq): New function.
	(verify_shift_bytes_in_array): Likewise.
	(verify_shift_bytes_in_array_right): Likewise.
	(verify_clear_bit_region): Likewise.
	(verify_clear_bit_region_be): Likewise.
	(store_merging_c_tests): Likewise.
	* selftest.h (store_merging_c_tests): Declare prototype.
	* selftest-run-tests.c (selftest::run_tests): Run
	store_merging_c_tests.

From-SVN: r241971
2016-11-08 16:04:20 +00:00
Kyrylo Tkachov 1f069ef5a1 [1/2] Fix off-by-one error in clear_bit_region in store merging (PR tree-optimization/78234 ?)
PR tree-optimization/78234
	* gimple-ssa-store-merging.c (clear_bit_region): Fix off-by-one error
	in start != 0 case.

From-SVN: r241962
2016-11-08 12:31:31 +00:00
Richard Biener 20770eb80b re PR tree-optimization/78218 (wrong code at -Os and above on x86_64-linux-gnu (in both 32-bit and 64-bit modes))
2016-11-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/78218
	* gimple-ssa-store-merging.c
	(pass_store_merging::terminate_all_aliasing_chains):
	Drop unused argument, fix alias check to also consider uses.
	(pass_store_merging::execute): Adjust.

	* gcc.dg/torture/pr78218.c: New testcase.

From-SVN: r241900
2016-11-07 12:26:00 +00:00
Kyrylo Tkachov b231822dae Fix for big-endian gcc.c-torture/execute/pr55750.c
* gimple-ssa-store-merging.c (encode_tree_to_bitpos): Don't forget to
	clear padding bits even when they're less than a byte.

From-SVN: r241798
2016-11-02 16:03:13 +00:00
Richard Biener aa55dc0ca3 gimple-ssa-store-merging.c: Include gimplify-me.h.
2016-11-02  Richard Biener  <rguenther@suse.de>

	* gimple-ssa-store-merging.c: Include gimplify-me.h.
	(imm_store_chain_info::output_merged_stores): Force base_addr
	to be proper GIMPLE for a MEM_REF address.
	(pass_store_merging::execute): Restrict negative bitpos
	handling to non-MEM_REF bases.  Remove TREE_THIS_VOLATILE
	check.  Take into account non-NULL_TREE offset if the base
	is already addressable.

	* gcc.dg/store_merging_8.c: New testcase.

From-SVN: r241796
2016-11-02 15:00:48 +00:00
Richard Biener b5926e23e4 gimple-ssa-store-merging.c (struct store_immediate_info): Remove redundant val and dest members.
2016-11-02  Richard Biener  <rguenther@suse.de>

	* gimple-ssa-store-merging.c (struct store_immediate_info): Remove
	redundant val and dest members.
	(store_immediate_info::store_immediate_info): Adjust.
	(merged_store_group::merged_store_group): Adjust.
	(merged_store_group::apply_stores): Likewise.
	(struct imm_store_chain_info): Add base_addr field.
	(imm_store_chain_info::imm_store_chain_info): New constructor.
	(imm_store_chain_info::terminate_and_process_chain): Do not pass base.
	(imm_store_chain_info::output_merged_store): Likewise.  Use
	addr_base which is already the address.
	(imm_store_chain_info::output_merged_stores): Likewise.
	(pass_tree_store_merging::terminate_all_aliasing_chains): Take
	imm_store_chain_info instead of base.  Fix alias check.
	(pass_tree_store_merging::terminate_and_release_chain): Likewise.
	(imm_store_chain_info::coalesce_immediate_stores): Adjust.
	(pass_store_merging::execute): Refuse to operate on TARGET_MEM_REF.
	use the address of the base and adjust for other changes.

From-SVN: r241789
2016-11-02 13:05:07 +00:00
Kyrylo Tkachov 4b2c06f49f PR tree-optimization/78170: Truncate sign-extended padding when encoding bitfields
PR tree-optimization/78170
	* gimple-ssa-store-merging.c (encode_tree_to_bitpos): Truncate padding
	introduced by native_encode_expr on little-endian as well.

	* gcc.c-torture/execute/pr78170.c: New test.

From-SVN: r241779
2016-11-02 09:28:35 +00:00
Kyrylo Tkachov 63e523d6f0 PR tree-optimization/78162: Reject negative offsets in store merging early
PR tree-optimization/78162
	* gimple-ssa-store-merging.c (execute): Mark stores with bitpos < 0
	as invalid.

	* gcc.c-torture/compile/pr78162.c: New test.

From-SVN: r241778
2016-11-02 09:25:22 +00:00
Jakub Jelinek a654d5d013 re PR tree-optimization/78148 (r241649 causes -fcompare-debug failure on ppc64le)
PR target/78148
	* gimple-ssa-store-merging.c
	(imm_store_chain_info::output_merged_store): Use build_aligned_type
	instead of SET_TYPE_ALIGN on shared integral type.

	* gcc.dg/pr78148.c: New test.

From-SVN: r241679
2016-10-29 17:55:50 +02:00
Kyrylo Tkachov f663d9ad6e GIMPLE store merging pass
2016-10-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	PR middle-end/22141
	* Makefile.in (OBJS): Add gimple-ssa-store-merging.o.
	* common.opt (fstore-merging): New Optimization option.
	* opts.c (default_options_table): Add entry for
	OPT_ftree_store_merging.
	* fold-const.h (can_native_encode_type_p): Declare prototype.
	* fold-const.c (can_native_encode_type_p): Define.
	* params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Define.
	(PARAM_MAX_STORES_TO_MERGE): Likewise.
	* timevar.def (TV_GIMPLE_STORE_MERGING): New timevar.
	* passes.def: Insert pass_tree_store_merging.
	* tree-pass.h (make_pass_store_merging): Declare extern
	prototype.
	* gimple-ssa-store-merging.c: New file.
	* doc/invoke.texi (Optimization Options): Document
	-fstore-merging.
	(--param documentation): Document store-merging-allow-unaligned
	and max-stores-to-merge.

2016-10-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
            Jakub Jelinek  <jakub@redhat.com>
            Andrew Pinski  <pinskia@gmail.com>

	PR middle-end/22141
	PR rtl-optimization/23684
	* gcc.c-torture/execute/pr22141-1.c: New test.
	* gcc.c-torture/execute/pr22141-2.c: Likewise.
	* gcc.target/aarch64/ldp_stp_1.c: Adjust for -fstore-merging.
	* gcc.target/aarch64/ldp_stp_4.c: Likewise.
	* gcc.dg/store_merging_1.c: New test.
	* gcc.dg/store_merging_2.c: Likewise.
	* gcc.dg/store_merging_3.c: Likewise.
	* gcc.dg/store_merging_4.c: Likewise.
	* gcc.dg/store_merging_5.c: Likewise.
	* gcc.dg/store_merging_6.c: Likewise.
	* gcc.dg/store_merging_7.c: Likewise.
	* gcc.target/i386/pr22141.c: Likewise.
	* gcc.target/i386/pr34012.c: Add -fno-store-merging to dg-options.
	* g++.dg/init/new17.C: Likewise.



Co-Authored-By: Andrew Pinski <pinskia@gmail.com>
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r241649
2016-10-28 14:18:50 +00:00