In some specific scenarios, `Ptr.getElementType()` won't be a primitive
type or a vector of primitive types, and thus `getScalarSizeInBits()`
returns zero.
Use the datalayout to get the proper size of the type instead of making
an implicit assumption that the type is a simple primitive type.
Solves SWDEV-534184