[PATCH] Canonicalize addrspacecast ConstExpr between different pointer types

Matt Arsenault Matthew.Arsenault at amd.com
Fri Jun 13 11:24:47 PDT 2014


================
Comment at: lib/IR/Constants.cpp:1708-1709
@@ +1707,4 @@
+    Type *MidTy = PointerType::get(DstElemTy, SrcScalarTy->getAddressSpace());
+    if (DstTy->isVectorTy()) // Handle vectors of pointers.
+      MidTy = VectorType::get(MidTy, DstTy->getVectorNumElements());
+    C = getBitCast(C, MidTy);
----------------
This is a good place to use dyn_cast<VectorType> instead of checking for a vector and then cast<> inside of the getVectorNumElements

http://reviews.llvm.org/D4138






More information about the llvm-commits mailing list