On Mon, Apr 28, 2025 at 12:34:27PM -0700, Linus Torvalds wrote: > Honestly, the least wrong thing is to just NOT HAVE THE CHECK FOR ZERO AT ALL. > > IOW, just generate the divide instruction. > > I can almost guarantee that that will actually then generate the best > code too, because you'll probably just end up sharing the divide > instruction will all the *normal* cases. > > So the best model is to literally remove that pointless and stupid "is > this a divide by zero" code. It's pointless and stupid because it > literally just makes for more work both for the compiler AND it > generates worse code.
BTW, I've noticed Clang also generates UB for negative shift values. I assume we'd want it to stop checking for those as well. -- Josh