Skip to content
Snippets Groups Projects
Commit 2291739e authored by Pan Li's avatar Pan Li
Browse files

Widening-Mul: Fix one bug of consume after phi node released


When try to matching saturation related pattern on PHI node, we may have
to try each pattern for all phi node of bb.  Aka:

for each PHI node in bb:
  gphi *phi = xxx;
  try_match_sat_add (, phi);
  try_match_sat_sub (, phi);
  try_match_sat_trunc (, phi);

The PHI node will be removed if one of the above 3 sat patterns are
matched.  There will be a problem that, for example, sat_add is
matched and then the phi is removed(freed), and the next 2 sat_sub and
sat_trunc will depend on the removed(freed) phi node.

This patch would like to fix this consume after phi node released issue.
To ensure at most one pattern of the above will be matched.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

	* tree-ssa-math-opts.cc (build_saturation_binary_arith_call): Rename
	to...
	(build_saturation_binary_arith_call_and_replace): ...this.
	(build_saturation_binary_arith_call_and_insert): ...this.
	(match_unsigned_saturation_add): Leverage renamed func.
	(match_unsigned_saturation_sub): Ditto.
	(match_saturation_add): Return bool on matched and leverage
	renamed func.
	(match_saturation_sub): Ditto.
	(match_saturation_trunc): Ditto.
	(math_opts_dom_walker::after_dom_children): Ensure at most one
	pattern will be matched for each phi node.

Signed-off-by: default avatarPan Li <pan2.li@intel.com>
parent f9f57df8
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment