This patch fixes PR4174. Two test-cases included: original one from bugzilla
and a little bit complicated made be myself.

I think you want isSafeToSpeculativelyExecute rather than
mayHaveSideEffects. Otherwise, looks fine.

With isSafeToSpeculativelyExecute "make check" fails on some tests, i.e:
because of PHI (isSafeToSpeculativelyExecute == false).

It seems that LoopIndexSplit doesn't handle some cases, I'll try to send
some patch this week.

You mean like PR3913? Or are you referring to something else?

3913 is a bug. I meant some other cases to optimize. However I'll try to look at it as well.