https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116278
--- Comment #6 from Li Pan <pan2.li at intel dot com> --- (In reply to Andrew Pinski from comment #4) > lb a1,0(a5) // load -40 > lui a0,%hi(.LC0) > lui a4,%hi(c) > addi a5,a1,9 //a5 = -31 > slli a5,a5,48 > srli a5,a5,48 // a5 = -31 > sltu a1,a5,a1 // -31 <u -40 ? false > neg a1,a1 // 0 > or a1,a1,a5 // -31 > slli a1,a1,48 > srli a1,a1,48 > > I don't see anything wrong here ... Unless I missed something (is lb a > signed load byte?) I think the problem comes from the lb side 0x1014c <main+16> lb a1,0(a5) // a1 is -40, aka 0xffffffffffffffd8 ││ 0x10150 <main+20> lui a0,0x1a ││ 0x10152 <main+22> addi a5,a1,9 ││ 0x10156 <main+26> slli a5,a5,0x30 ││ 0x10158 <main+28> srli a5,a5,0x30 // a5 is 65505 ││ >0x1015a <main+30> sltu a1,a5,a1 // compare 65505 and 0xffffffffffffffd8 => TRUE, and then get max 65535. It should be one backend code-gen issue, will take care of this.