This is basically D108837 but for jump threading. Free instructions should be ignored for the threading decision. JumpThreading already skips some free instructions (like pointer bitcasts), but does not skip various free intrinsics -- in fact, it currently gives them a fairly large cost of 2.
I can see why it may be good to migrate to proper TTI costs here,
but the main question that raises are:
- in -Oz, should we be checking codesize cost?
- Changing heuristics will obviously affect optimization power. What does this does to the budget? Should we increase it to retain most of the current optimization power?
This caused compiler crash when building Chromium. See https://bugs.chromium.org/p/chromium/issues/detail?id=1252762#c8 for a reproducer, and the top of that bug for the stack dump.
I've reverted in 4604695d7c20e72b551a1a5224f3de877cb41bd3 in the meantime.