Hi all, In PR58088 the constant folder goes into an infinite recursion and runs out of stack space because of two conflicting optimisations: (X * C1) & C2 plays dirty when nested inside an IOR expression like so: ((X * C1) & C2) | C4. One can undo the other leading to an infinite recursion.
Thanks to Marek for finding the IOR case. This patch fixes that by checking in the IOR case that the change to C2 will not conflict with the AND case transformation. Example testcases in the PR on bugzilla. This issue is present in 4.8.1 as well as trunk. However, I think 4.8 uses a different API for double_int, so this patch will need to be reworked for 4.8. In the meantime, Ok for trunk? Bootstrapped on x86_64-linux-gnu and tested arm-none-eabi on qemu. Thanks, Kyrill 2013-08-07 Kyrylo Tkachov <kyrylo.tkac...@arm.com> * gcc/fold-const.c (mask_with_trailing_zeros): New function. (fold_binary_loc): Make sure we don't recurse infinitely when the X in (X & C1) | C2 is a tree of the form (Y * K1) & K2. Use mask_with_trailing_zeros where appropriate. 2013-08-07 Kyrylo Tkachov <kyrylo.tkac...@arm.com> * gcc.c-torture/compile/pr58088.c: New test.
pr58088.patch
Description: Binary data