https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96370
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-8 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:0307275acc789491bcc33dc67948009ec7d9c51d commit r8-10804-g0307275acc789491bcc33dc67948009ec7d9c51d Author: Richard Biener <rguent...@suse.de> Date: Thu Jul 30 10:24:42 2020 +0200 tree-optimization/96370 - make reassoc expr rewrite more robust In the face of the more complex tricks in reassoc with respect to negate processing it can happen that the expression rewrite is fooled to recurse on a leaf and pick up a bogus expression code. The following patch makes the expression rewrite more robust in providing the expression code to it directly since it is the same for all operations in a chain. 2020-07-30 Richard Biener <rguent...@suse.de> PR tree-optimization/96370 * tree-ssa-reassoc.c (rewrite_expr_tree): Add operation code parameter and use it instead of picking it up from the stmt that is being rewritten. (reassociate_bb): Pass down the operation code. * gcc.dg/pr96370.c: New testcase. (cherry picked from commit a5fff78405c3bfea287434e7711c6f10a770cb0a)