On 22/11/2019 11:52, Andrew Pinski wrote:
I should say that you need all three options to prevent the code motion from happening: -fno-tree-loop-im -fno-tree-pre -fno-gcse
-fno-tree-ch prevents the code motion from happening too but only on accident; in that all three of the code motion passes (the two on the gimple and one on RTL) won't work with the loop in that form. Disabling copy header optimization for flag_conserve_stack is the wrong approach. Again you need to look into each of the code motion passes to understand the register pressure heuristics and why they do the code motion.
Also I have not looked into why the RTL loop invariant code motion pass did NOTHING here.
Thanks, Andrew Pinski