[PATCH] D26060: [ConstantFolding] Don't try to cast vectors to pointer if they have different size

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 15:36:24 PDT 2016

davide added inline comments.

Comment at: lib/Analysis/ConstantFolding.cpp:731
+             SrcElemTy, Ops.slice(1, i - 1)))) &&
+        Ops[i]->getType() != IntPtrTy && IntPtrTy->isVectorTy() &&
+        Ops[i]->getType()->getPrimitiveSizeInBits() ==
filcab wrote:
> Did you mean `Ops[i]->getType()->isVectorTy()`?
> From `DataLayout.h`:
>     /// \brief Returns an integer type with size at least as big as that of a
>     /// pointer in the given address space.
>     IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace = 0) const;
> So `IntPtrTy` will never be a vector type.
> It seems with your initial patch, we're not casting at all. But I might be misunderstanding something here.
There's a different overload which can actually return a `VectorTy`. 
  /// \brief Returns an integer (vector of integer) type with size at least as
  /// big as that of a pointer of the given pointer (vector of pointer) type.
  Type *getIntPtrType(Type *) const;
I also double checked and in my example `IntPtrTy` is a `VectorTy`


More information about the llvm-commits mailing list