[polly] Get rid of a couple uses of PointerType::getElementType().

GitOrigin-RevId: 43705149ed8ed1047a5b07706cc7b44ce29e9323
diff --git a/lib/CodeGen/BlockGenerators.cpp b/lib/CodeGen/BlockGenerators.cpp
index 14e85e0..946bc09 100644
--- a/lib/CodeGen/BlockGenerators.cpp
+++ b/lib/CodeGen/BlockGenerators.cpp
@@ -278,8 +278,8 @@
     // the newly generated pointer.
     auto OldPtrTy = ExpectedType->getPointerTo();
     auto NewPtrTy = Address->getType();
-    OldPtrTy = PointerType::get(OldPtrTy->getElementType(),
-                                NewPtrTy->getPointerAddressSpace());
+    OldPtrTy = PointerType::getWithSamePointeeType(
+        OldPtrTy, NewPtrTy->getPointerAddressSpace());
 
     if (OldPtrTy != NewPtrTy)
       Address = Builder.CreateBitOrPointerCast(Address, OldPtrTy);
@@ -801,9 +801,8 @@
 
           // The new Val might have a different type than the old Val due to
           // ScalarEvolution looking through bitcasts.
-          if (Val->getType() != Address->getType()->getPointerElementType())
-            Address = Builder.CreateBitOrPointerCast(
-                Address, Val->getType()->getPointerTo());
+          Address = Builder.CreateBitOrPointerCast(
+              Address, Val->getType()->getPointerTo());
 
           Builder.CreateStore(Val, Address);
         });