This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Canonicalize branch predicates
AbandonedPublic

Authored by yrouban on Jul 23 2020, 11:57 PM.

Details

Summary

Canonicalize branch predicates as it is done by InstCombine.
This patch is the first step to move the branch predicate canonicalization transformation from InstCombine to SimplifyCFG.
This move is needed to make InstCombine preserve CFG. Currently we have a bug 46098 which reports PostDomTree invalidation once InstCombine swaps branches in a post-order unreachable block. See discussion in D81089.

The new transformation is disabled by default (the new flag simplifycfg-canonicalize-branch-predicates). So the patch is safe but. The sensitive tests are fixed and get additional option -simplifycfg-canonicalize-branch-predicates.

Diff Detail

Event Timeline

yrouban created this revision.Jul 23 2020, 11:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 11:57 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
kuhar added inline comments.Jul 28 2020, 11:35 AM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6047

nit: would it be possible to come up with a more descriptive name? Maybe something like newCond, conditionCandidate, etc.

6053

BI->setCondition(X)?

6064

nit: auto *Cond = ...

yrouban planned changes to this revision.Jul 30 2020, 9:13 PM
yrouban added inline comments.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
6060

m_FCmp should be change to m_Cmp

lebedev.ri requested changes to this revision.Aug 5 2020, 4:05 AM

Abandon now that D84763 has resolved the base problem?

@yrouban abandon patchset now that https://bugs.llvm.org/show_bug.cgi?id=46098 has been addressed?

yrouban abandoned this revision.Aug 13 2020, 8:51 AM