https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95424
--- Comment #1 from Zhao Wei Liew <zhaoweiliew at gmail dot com> --- Created attachment 52091 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52091&action=edit Tested patch for the case of unsigned integer X I tried to tackle the unsigned integer X case by adding an optimization in match.pd. I suppose it can be done similarly for the signed integer X case as well, but I'll need more time to look into that. I've attached the proposed patch. With this patch, GCC generates the same assembly output as Clang. int f(unsigned int x) { return 1 / x; } .LFB0: .cfi_startproc xorl %eax, %eax cmpl $1, %edi sete %al ret