aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-01-17 16:59:23 +0100
committerNikita Popov <npopov@redhat.com>2022-01-17 17:01:47 +0100
commitf104cc38f45ebbca065e78959c23d09f16b65bd5 (patch)
tree2ef69be5e3eb609e05cf377391d73d9ccdff4691 /llvm/lib/Analysis/ConstantFolding.cpp
parent4cdf30d9d36ea6a6dfee967414f9f0e1748350af (diff)
downloadllvm-f104cc38f45ebbca065e78959c23d09f16b65bd5.zip
llvm-f104cc38f45ebbca065e78959c23d09f16b65bd5.tar.gz
llvm-f104cc38f45ebbca065e78959c23d09f16b65bd5.tar.bz2
[ConstantFold] Don't fold load from non-byte-sized vector
Following up on https://github.com/llvm/llvm-project/commit/1470f94d71c544327f76b85c55cb6f7cb43a6cbb#r63981173: The result here (probably) depends on endianness. Don't bother trying to handle this exotic case, just bail out.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index b504d33..253a724 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -399,6 +399,12 @@ Constant *llvm::ConstantFoldLoadThroughBitcast(Constant *C, Type *DestTy,
} while (ElemC && DL.getTypeSizeInBits(ElemC->getType()).isZero());
C = ElemC;
} else {
+ // For non-byte-sized vector elements, the first element is not
+ // necessarily located at the vector base address.
+ if (auto *VT = dyn_cast<VectorType>(SrcTy))
+ if (!DL.typeSizeEqualsStoreSize(VT->getElementType()))
+ return nullptr;
+
C = C->getAggregateElement(0u);
}
} while (C);