aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorvporpo <vporpodas@google.com>2024-10-29 15:37:03 -0700
committerGitHub <noreply@github.com>2024-10-29 15:37:03 -0700
commitca998b071eba1c92bf8535964183c7c4c3b258c3 (patch)
treec6e3b26a3f12cf21c87fd1e20a5d6b4e1f3f5ee3 /llvm/lib
parent8b55162e195783dd27e1c69fb4d97971ef76725b (diff)
downloadllvm-ca998b071eba1c92bf8535964183c7c4c3b258c3.zip
llvm-ca998b071eba1c92bf8535964183c7c4c3b258c3.tar.gz
llvm-ca998b071eba1c92bf8535964183c7c4c3b258c3.tar.bz2
[SandboxVec][Legality] Check wrap flags (#113975)
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index 346d8a90..1cc6356 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -55,6 +55,21 @@ LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(
return ResultReason::DiffMathFlags;
}
+ // TODO: Allow vectorization by using common flags.
+ // For now Pack if they don't have the same wrap flags.
+ bool CanHaveWrapFlags =
+ isa<OverflowingBinaryOperator>(I0) || isa<TruncInst>(I0);
+ if (CanHaveWrapFlags) {
+ bool NUW0 = I0->hasNoUnsignedWrap();
+ bool NSW0 = I0->hasNoSignedWrap();
+ if (any_of(drop_begin(Bndl), [NUW0, NSW0](auto *V) {
+ return cast<Instruction>(V)->hasNoUnsignedWrap() != NUW0 ||
+ cast<Instruction>(V)->hasNoSignedWrap() != NSW0;
+ })) {
+ return ResultReason::DiffWrapFlags;
+ }
+ }
+
// TODO: Missing checks
return std::nullopt;