[RFC] memfill and memtransfer intrinsics for generalized memset/memcpy

I like the idea of a memfill intrinsic.

Since recently, PreISelIntrinsicLowering will lower large/unknown-size memcpy/memset to loops for targets that don’t support these libcalls. It would be straightforward to extend that to memfill for non-Darwin targets.

Regarding code size, I think the comparison point here is “the frontend directly emits the loop”, which is what would happen right now. In that case a loop legalization isn’t really worse than the current situation. Just need to be careful that intrinsic is costed appropriately.


I’m not a fan of the memtransfer proposal. Especially when I see this in conjunction with [RFC] Correct implementation of memcpy with metadata, which is a proposal in the same area, but the reverse goal, it seems like we should really be focusing on adding the byte type.

3 Likes