diff options
author | elhewaty <mohamedatef1698@gmail.com> | 2024-03-29 08:08:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 14:08:49 +0800 |
commit | 7d3924cee30a87a51f9dc04ec843ae6bc3d1c90e (patch) | |
tree | 7e23e8a759adcd9911b77834c6a79f350685cb4d /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | ba6b2d22af177a72b132cdb8e9350a708f282d2c (diff) | |
download | llvm-7d3924cee30a87a51f9dc04ec843ae6bc3d1c90e.zip llvm-7d3924cee30a87a51f9dc04ec843ae6bc3d1c90e.tar.gz llvm-7d3924cee30a87a51f9dc04ec843ae6bc3d1c90e.tar.bz2 |
[IR] Add nowrap flags for trunc instruction (#85592)
This patch adds the nuw (no unsigned wrap) and nsw (no signed wrap)
poison-generating flags to the trunc instruction.
Discourse thread:
https://discourse.llvm.org/t/rfc-add-nowrap-flags-to-trunc/77453
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 3a3bcde..74cffbc 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -59,6 +59,10 @@ PoisonFlags::PoisonFlags(const Instruction *I) { Disjoint = PDI->isDisjoint(); if (auto *PNI = dyn_cast<PossiblyNonNegInst>(I)) NNeg = PNI->hasNonNeg(); + if (auto *TI = dyn_cast<TruncInst>(I)) { + NUW = TI->hasNoUnsignedWrap(); + NSW = TI->hasNoSignedWrap(); + } } void PoisonFlags::apply(Instruction *I) { @@ -72,6 +76,10 @@ void PoisonFlags::apply(Instruction *I) { PDI->setIsDisjoint(Disjoint); if (auto *PNI = dyn_cast<PossiblyNonNegInst>(I)) PNI->setNonNeg(NNeg); + if (isa<TruncInst>(I)) { + I->setHasNoUnsignedWrap(NUW); + I->setHasNoSignedWrap(NSW); + } } /// ReuseOrCreateCast - Arrange for there to be a cast of V to Ty at IP, |