niosHD added a comment. Thank you for finding the flaw in my thinking. I obviously missed that everything falls apart due to the sign extension of the LUI instruction... I'll update the patch to use the ADDIW instruction again. https://reviews.llvm.org/D46118