This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, this patch is for a specific case in RTX simplification where infinite recursion ensues, causing the out-of-stack segfault in PR49720. Tracking back the origin of this bug, the exact revision causing this was rev.92429, back in 2004. The clause in simplify-rtx.c:simplify_relational_operation_1(), transforming X + cst1 == cst2 into X == cst2 - cst1 can cause an oscillating recursive cycle like this: A + B == C <===> C - B == A When all A, B, and C are CONSTANT_P, but not simplifiable (in the PR testcase, they are all SYMBOL_REFs). The switching of XEXP(op0,1) to the other side of the equation, plus commutative canonicalizing then completes the cycle. This can be solved by using simplify_binary_relation() and returning NULL_RTX when simplification of the constant PLUS/MINUS fails, but I'm not sure that further working on X == CST2-CST1 will never yield more optimization, so the patch here just tries to plug the recursion hole for the exact condition. Bootstrapped and tested on i686 and x86_64 without regressions. Is this okay for trunk? Thanks, Chung-Lin 2011-10-27 Chung-Lin Tang <cltang@codesourcery.com> PR rtl-optimization/49720 * simplify-rtx.c (simplify_relational_operation_1): Detect infinite recursion condition in "(eq/ne (plus x cst1) cst2) simplifies to (eq/ne x (cst2 - cst1))" case. testsuite/ * g++.dg/torture/pr49720.C: New test.
Attachment:
pr49720.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |