Skip to content

Instantly share code, notes, and snippets.

@nikic

nikic/lsr.patch Secret

Created December 6, 2020 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikic/7e1301a81542d95953a44243c8ee5b5e to your computer and use it in GitHub Desktop.
Save nikic/7e1301a81542d95953a44243c8ee5b5e to your computer and use it in GitHub Desktop.
commit b8948971566e3742854212b09f83df706e17e475
Author: Nikita Popov <nikita.ppv@gmail.com>
Date: Sun Dec 6 21:03:04 2020 +0100
lsr postinc
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index c7e37fe0d1b..aa23e244bbc 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IntrinsicInst.h"
@@ -1440,6 +1441,10 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) {
assert(LatchBlock && "PostInc mode requires a unique loop latch!");
Result = PN->getIncomingValueForBlock(LatchBlock);
+ if (auto *I = dyn_cast<Instruction>(Result))
+ if (!programUndefinedIfPoison(I))
+ I->dropPoisonGeneratingFlags();
+
// For an expansion to use the postinc form, the client must call
// expandCodeFor with an InsertPoint that is either outside the PostIncLoop
// or dominated by IVIncInsertPos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment