This patch improves FlattenCFG so that it will invert a branch when indices do not match so that the transform can be applied in more cases. One more operator was added to do branch niversion on asl well. The old way which the branch inversion was used could actually prevent branch merging in some cases.
Details
Diff Detail
Event Timeline
Added check in branch inversion to break if we encounter a block without a single predecessor.
lib/Transforms/Utils/FlattenCFG.cpp | ||
---|---|---|
202 | I think that I'm missing something here: We currently might perform this change when CIdx == Idx, and with this patch, we only ever do it when CIdx != Idx. Don't you want to do it in both cases? |
lib/Transforms/Utils/FlattenCFG.cpp | ||
---|---|---|
202 | I'm not sure why branch inversion should done when CIdx == Idx. It shouldn't matter which block jumps into the other from the last CondBlock, and if branch inversion is done, then the indices will no longer be the same and the optimization does not apply anymore. |
sorry for the really long delay. I don't know enough about this code to review this patch (and won't have time to study it in the near future). You want Tom or Matt to have a look.
I don't know if this is needed anymore. We could probably abandon it if it does not seem useful.
Can you rebase and see if this still makes a difference? I think CodeGenPrepare may also do this in some cases now
I think that I'm missing something here: We currently might perform this change when CIdx == Idx, and with this patch, we only ever do it when CIdx != Idx. Don't you want to do it in both cases?