From b6bf28fae34442b21281286a5feda479ce47bce4 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Fri, 19 May 2023 15:07:31 +0100 Subject: [PATCH] [GVN] No else after return. NFC. --- llvm/lib/Transforms/Scalar/GVN.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 098ea89..3f94cae 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -474,15 +474,17 @@ uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) { uint32_t e = assignExpNewValueNum(exp).first; valueNumbering[C] = e; return e; - } else if (MD && AA->onlyReadsMemory(C) && - // FIXME: Currently the calls which may access the thread id may - // be considered as not accessing the memory. But this is - // problematic for coroutines, since coroutines may resume in a - // different thread. So we disable the optimization here for the - // correctness. However, it may block many other correct - // optimizations. Revert this one when we detect the memory - // accessing kind more precisely. - !C->getFunction()->isPresplitCoroutine()) { + } + + if (MD && AA->onlyReadsMemory(C) && + // FIXME: Currently the calls which may access the thread id may + // be considered as not accessing the memory. But this is + // problematic for coroutines, since coroutines may resume in a + // different thread. So we disable the optimization here for the + // correctness. However, it may block many other correct + // optimizations. Revert this one when we detect the memory + // accessing kind more precisely. + !C->getFunction()->isPresplitCoroutine()) { Expression exp = createExpr(C); auto ValNum = assignExpNewValueNum(exp); if (ValNum.second) { @@ -572,10 +574,10 @@ uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) { uint32_t v = lookupOrAdd(cdep); valueNumbering[C] = v; return v; - } else { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; } + + valueNumbering[C] = nextValueNumber; + return nextValueNumber++; } /// Returns true if a value number exists for the specified value. @@ -1924,7 +1926,9 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) { return true; } return false; - } else if (isa(V)) { + } + + if (isa(V)) { // If it's not false, and constant, it must evaluate to true. This means our // assume is assume(true), and thus, pointless, and we don't want to do // anything more here. @@ -2557,7 +2561,9 @@ bool GVNPass::processInstruction(Instruction *I) { // Failure, just remember this instance for future use. addToLeaderTable(Num, I, I->getParent()); return false; - } else if (Repl == I) { + } + + if (Repl == I) { // If I was the result of a shortcut PRE, it might already be in the table // and the best replacement for itself. Nothing to do. return false; -- 2.7.4