[llvm] [GVN] Replace cmp with not instruction if inv cmp is found (PR #223171)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 05:59:16 PDT 2026
================
@@ -3445,18 +3445,30 @@ bool GVNPass::processInstruction(Instruction *I) {
}
}
- // If the number we were assigned was a brand new VN, then we don't
- // need to do a lookup to see if the number already exists
- // somewhere in the domtree: it can't!
- if (Num >= NextNum) {
- LeaderTable.insert(Num, I, I->getParent());
- return false;
- }
-
// Perform fast-path value-number based elimination of values inherited from
- // dominators.
- Value *Repl = findLeader(I->getParent(), Num);
+ // dominators, unless if the number we were assigned was a brand new VN, then
+ // we don't need to do a lookup to see if the number already exists somewhere
+ // in the domtree: it can't!
+ Value *Repl = Num < NextNum ? findLeader(I->getParent(), Num) : nullptr;
if (!Repl) {
+ // substiut cmp instruction with not if possible.
+ if (CmpInst *Cmp = dyn_cast<CmpInst>(I)) {
+ uint32_t NextNumNot = VN.getNextUnusedValueNumber();
+ uint32_t NotNum =
+ VN.lookupOrAddCmp(Cmp->getOpcode(), Cmp->getInversePredicate(),
----------------
andjo403 wrote:
hmm making a lookupCmp function made the compile time worse GeoMean +0.11% vs before +0.07% sounds like much for what this give maybe
https://github.com/llvm/llvm-project/pull/223171
More information about the llvm-commits
mailing list