diff options
author | Philip Reames <preames@rivosinc.com> | 2023-10-31 09:33:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-31 09:33:07 -0700 |
commit | f8742b8d6a3489dc8974f4166d413a66cb8d9c21 (patch) | |
tree | cd33bfb899226d1363d90de7dd727dd945cde072 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | 6be0e979896f7dd610abf263f845c532f1be3762 (diff) | |
download | llvm-f8742b8d6a3489dc8974f4166d413a66cb8d9c21.zip llvm-f8742b8d6a3489dc8974f4166d413a66cb8d9c21.tar.gz llvm-f8742b8d6a3489dc8974f4166d413a66cb8d9c21.tar.bz2 |
[SCEV] Teach SCEVExpander to use zext nneg when possible (#70815)
zext nneg was recently added to the IR in #67982. Teaching SCEVExpander
to emit nneg when possible is valuable since SCEV may have proved
non-trivial facts about loop bounds which would otherwise be lost when
materializing the value.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 5c976d5..c8cd9c4 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1293,7 +1293,10 @@ Value *SCEVExpander::visitTruncateExpr(const SCEVTruncateExpr *S) { Value *SCEVExpander::visitZeroExtendExpr(const SCEVZeroExtendExpr *S) { Value *V = expand(S->getOperand()); - return Builder.CreateZExt(V, S->getType()); + auto *Res = Builder.CreateZExt(V, S->getType()); + if (auto *I = dyn_cast<Instruction>(Res)) + I->setNonNeg(SE.isKnownNonNegative(S->getOperand())); + return Res; } Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) { |