[PATCH] D12559: Fix IRBuilder CreateBitOrPointerCast for vector types
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 17:20:00 PDT 2015
mzolotukhin added inline comments.
================
Comment at: include/llvm/IR/IRBuilder.h:1355
@@ -1354,3 +1354,3 @@
const Twine &Name = "") {
- if (V->getType() == DestTy)
+ if (V->getType()->getScalarType() == DestTy->getScalarType())
return V;
----------------
silviu.baranga wrote:
> mzolotukhin wrote:
> > This doesn't look right. What if we have vectors of different sizes (i.e. `V` is `<8 x i32>` and `DestTy` is `<4 x i32>`)?
> Would calling this function to create a cast from <8 x i32> to <4 xi32> be valid? Perhaps we should add an assert here.
I think we don't need to change this condition, as it only introduces unneeded ambiguity (like in the case above). And, actually, we don't get anything from it, right?
================
Comment at: include/llvm/IR/IRBuilder.h:1357-1361
@@ -1356,5 +1356,7 @@
return V;
- if (V->getType()->isPointerTy() && DestTy->isIntegerTy())
+ if (V->getType()->getScalarType()->isPointerTy() &&
+ DestTy->getScalarType()->isIntegerTy())
return CreatePtrToInt(V, DestTy, Name);
- if (V->getType()->isIntegerTy() && DestTy->isPointerTy())
+ if (V->getType()->getScalarType()->isIntegerTy() &&
+ DestTy->getScalarType()->isPointerTy())
return CreateIntToPtr(V, DestTy, Name);
----------------
These changes look fine (and we don't need to introduce asserts since we have required checks in `CreateCast...` routines).
http://reviews.llvm.org/D12559
More information about the llvm-commits
mailing list