This is an archive of the discontinued LLVM Phabricator instance.

Fix FlattenCFG to invert test when different index is encountered, and add one more operator to invert.
AbandonedPublic

Authored by jsjodin on Jul 28 2015, 9:55 AM.

Details

Summary

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.

Diff Detail

Event Timeline

jsjodin updated this revision to Diff 30831.Jul 28 2015, 9:55 AM
jsjodin retitled this revision from to Fix FlattenCFG to invert test when different index is encountered, and add one more operator to invert..
jsjodin updated this object.
jsjodin added a reviewer: llvm-commits.
jsjodin added a subscriber: llvm-commits.
jsjodin updated this revision to Diff 31042.Jul 30 2015, 9:57 AM

Added check in branch inversion to break if we encounter a block without a single predecessor.

hfinkel added inline comments.
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?

jsjodin added inline comments.Aug 10 2015, 12:01 PM
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.

jvesely edited reviewers, added: tstellarAMD, arsenm; removed: jvesely.Apr 15 2016, 9:46 AM
jvesely added a subscriber: jvesely.

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.

Is this still necessary?

Is this still needed?

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

arsenm requested changes to this revision.Dec 5 2022, 11:30 AM

Is this still relevant?

This revision now requires changes to proceed.Dec 5 2022, 11:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 11:30 AM
jsjodin abandoned this revision.Mar 31 2023, 5:34 AM

Unlikely to be needed anymore.