This patch contains two more constraint that aim to reduce the noise cases where we convert CMOV into branch for small gain, and spending more cycles due to overhead.
Added couple of tests that represents the bug in PR33954 and cover the change in the patch.
Notice that I needed to modify one of the previous tests.
I measured the performance manually on a small manually written main function, and noticed improvement with the new decision - as explained in the LIT test pr33954.ll.
Would this be a bit more readable?
if (diff[i] < GainCycleThreashold) return false; bool WorthOptLoop = false; if (Diff == Diff) WorthOptLoop = Diff * 8 >= LoopDepth.Depth; else if (Diff > Diff) WorthOptLoop = (Diff - Diff) * 2 >= (LoopDepth.Depth - LoopDepth.Depth) && (Diff * 8 >= LoopDepth.Depth);
Since the -x86-cmov-converter is invoked explicitly, should the -x86-cmov-converter-threshold=4 flag be added too?
Maybe emphasize that in this case we bail out due to a low absolute gain in *cycles*, despite the *relative* gain being acceptable.
if (t *a> b)
Thanks Zvi for the comments.
Please see answers below.
Actually, I want to guard the threshold, whoever change it, should revisit this test.
Why is this important?