https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93013
Bill Schmidt <wschmidt at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2019-12-19 CC| |meissner at gcc dot gnu.org, | |segher at gcc dot gnu.org Component|c++ |tree-optimization Ever confirmed|0 |1 --- Comment #1 from Bill Schmidt <wschmidt at gcc dot gnu.org> --- The branch is removed by the middle end, as the optimized dump shows: ;; Function mod (_Z3modiiRi, funcdef_no=0, decl_uid=3256, cgraph_uid=1, symbol_\ order=0) mod (int x, int y, int & z) { int _1; bool _3; int _9; <bb 2> [local count: 1073741824]: _1 = x_4(D) % y_5(D); *z_7(D) = _1; _3 = y_5(D) == 0; _9 = (int) _3; return _9; } On POWER9 we will get the expected answer given the use of the modsw instruction. For POWER8 we get the codegen with divw which is indeed undefined for these inputs. I guess the issue would be in the expander for mod<mode>3. Confirmed.