summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:46:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:46:28 +0000
commit2cedf089162d7ff08af2fb09e4adea44608e7233 (patch)
treeba6ce010fd991778200b43335a161f546d953a55 /llvm/lib/Analysis/ConstantFolding.cpp
parentcfca06d7963fa0909f90483b42a6d7d194d01e08 (diff)
Notes
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 8c66decaaf58d..6feffcbb98e1f 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -342,8 +342,12 @@ Constant *llvm::ConstantFoldLoadThroughBitcast(Constant *C, Type *DestTy,
// pointers legally).
if (C->isNullValue() && !DestTy->isX86_MMXTy())
return Constant::getNullValue(DestTy);
- if (C->isAllOnesValue() && !DestTy->isX86_MMXTy() &&
- !DestTy->isPtrOrPtrVectorTy()) // Don't get ones for ptr types!
+ if (C->isAllOnesValue() &&
+ (DestTy->isIntegerTy() || DestTy->isFloatingPointTy() ||
+ DestTy->isVectorTy()) &&
+ !DestTy->isX86_MMXTy() && !DestTy->isPtrOrPtrVectorTy())
+ // Get ones when the input is trivial, but
+ // only for supported types inside getAllOnesValue.
return Constant::getAllOnesValue(DestTy);
// If the type sizes are the same and a cast is legal, just directly