diff options
author | Karl-Johan Karlsson <karl-johan.karlsson@ericsson.com> | 2018-06-01 19:34:35 +0000 |
---|---|---|
committer | Karl-Johan Karlsson <karl-johan.karlsson@ericsson.com> | 2018-06-01 19:34:35 +0000 |
commit | 6d52e5c3e401d5ffad05ad07d51619e37b56a154 (patch) | |
tree | df1daaa1cef5bcb64853f385ac42672a9590260b /llvm/lib/IR/ConstantFold.cpp | |
parent | 66f7e19f6a05ca11f62c9e48f8d6ed0c011a47cf (diff) | |
download | llvm-6d52e5c3e401d5ffad05ad07d51619e37b56a154.zip llvm-6d52e5c3e401d5ffad05ad07d51619e37b56a154.tar.gz llvm-6d52e5c3e401d5ffad05ad07d51619e37b56a154.tar.bz2 |
[ConstantFold] Disallow folding vector geps into bitcasts
Summary:
Getelementptr returns a vector of pointers, instead of a single address,
when one or more of its arguments is a vector. In such case it is not
possible to simplify the expression by inserting a bitcast of operand(0)
into the destination type, as it will create a bitcast between different
sizes.
Reviewers: majnemer, mkuper, mssimpso, spatel
Reviewed By: spatel
Subscribers: lebedev.ri, llvm-commits
Differential Revision: https://reviews.llvm.org/D46379
llvm-svn: 333783
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 2404ce4..218adb4 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -545,7 +545,11 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, opc != Instruction::AddrSpaceCast && // Do not fold bitcast (gep) with inrange index, as this loses // information. - !cast<GEPOperator>(CE)->getInRangeIndex().hasValue()) { + !cast<GEPOperator>(CE)->getInRangeIndex().hasValue() && + // Do not fold if the gep type is a vector, as bitcasting + // operand 0 of a vector gep will result in a bitcast between + // different sizes. + !CE->getType()->isVectorTy()) { // If all of the indexes in the GEP are null values, there is no pointer // adjustment going on. We might as well cast the source pointer. bool isAllNull = true; |