Skip to content
Snippets Groups Projects
Commit c1fb592f authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

widening_mul: pattern recognize further forms of __builtin_add_overflow [PR95853]

The following patch recognizes some further forms of additions with overflow
checks as shown in the testcase, in particular where the unsigned addition is
performed in a wider mode just to catch overflow with a > narrower_utype_max
check.

2020-11-22  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/95853
	* tree-ssa-math-opts.c (uaddsub_overflow_check_p): Add maxval
	argument, if non-NULL, instead look for r > maxval or r <= maxval
	comparisons.
	(match_uaddsub_overflow): Pattern recognize even other forms of
	__builtin_add_overflow, in particular when addition is performed
	in a wider type and result compared to maximum of the narrower
	type.

	* gcc.dg/pr95853.c: New test.
parent fdd2fb17
No related branches found
No related tags found
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