https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89794
--- Comment #8 from Segher Boessenkool <segher at gcc dot gnu.org> --- Author: segher Date: Mon Apr 15 11:33:29 2019 New Revision: 270368 URL: https://gcc.gnu.org/viewcvs?rev=270368&root=gcc&view=rev Log: combine: Count auto_inc properly (PR89794) The code that checks if an auto-increment from i0 or i1 is not lost is a bit shaky. The code to check the same for i2 is non-existent, and cannot be implemented in a similar way at all. So, this patch counts all auto-increments, and makes sure we end up with the same number as we started with. This works because we still have a check that we will not duplicate any. We should do this some better way, but not while we are in stage 4. PR rtl-optimization/89794 * combine.c (count_auto_inc): New function. (try_combine): Count how many auto_inc expressions there were in the original instructions. Ensure we have the same number in the new instructions. Remove the code that tried to ensure auto_inc side effects on i1 and i0 are not lost. gcc/testsuite/ PR rtl-optimization/89794 * gcc.dg/torture/pr89794.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr89794.c Modified: trunk/ChangeLog trunk/gcc/combine.c trunk/gcc/testsuite/ChangeLog