News for hackers. Stuff that matters.
Re:An ex-ARM engineer critiques RISC-V by saagarjha on Sunday November 01, 2020 @05:02PM (#24962922)
Right, but you don't need to sign extend it.
Re:An ex-ARM engineer critiques RISC-V by kllrnohj on Sunday November 01, 2020 @05:09PM (#24962974)
Eh? The problem with using unsigned is identical to using size_t. size_t doesn't have any special carveouts that eg. say that wrapping is undefined behavior. It's defined as an unsigned integer type. Meaning it has unsigned integer type behaviors.
Re:An ex-ARM engineer critiques RISC-V by saagarjha on Sunday November 01, 2020 @05:13PM (#24963001)
unsigned is 32-bit, which means you need to have it overflow in the lower 32 bits since you're working on it through a 64-bit register. If you use a full size_t then this check is not necessary.
Re:An ex-ARM engineer critiques RISC-V by brandmeyer on Sunday November 01, 2020 @05:59PM (#24963307)
You have a typo: size_t doesn't need zero extension. RISC-V does have 32-bit signed integer arithmetic that unconditionally sign-extends the result from bit 31. So using a signed integer as a counter (bad practice IMO, but widely recommended in style guides) doesn't need anything extra at all.
Re:An ex-ARM engineer critiques RISC-V by saagarjha on Sunday November 01, 2020 @06:02PM (#24963329)
Uh, wrong subthread?