https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30314
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Keywords| |missed-optimization Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2021-08-11 Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- starting in GCC 11, we produce: movl $140, %edx movq %rdi, %rax mulq %rdx jo .L11 Which corresponds to this gimple: _7 = .MUL_OVERFLOW (num_3(D), 140); _8 = IMAGPART_EXPR <_7>; if (_8 != 0) So it is definitely better than before. BUT this is not the best code, clang produces (for 64bit): movabsq $131762457669353941, %rax # imm = 0x1D41D41D41D41D5 cmpq %rax, %rdi jb .LBB0_2 So basically ULONGMAX/140 as described. So something like: (simplify (imagpart (IFN_MUL_OVERFLOW:s @0 INTEGER_CST@1)) (if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST) (convert (le @0 (trunc_div { TYPE_MAX_VALUE (type); } @1))))