The code assumed that zero-extending the integer constant to the designated alloc size would be fine even for BE targets, but that's not the case as that pulls in zeros from the MSB side while we actually expect the padding zeros to go after the LSB.
I've changed the codepath handling the constant integers to use the store size for both small(er than u64) and big constants and then add zero padding right after that.