Consider the following testcase, reduced from cfgexpand.c: int foo (int align) { int off = 0 % align; return off ? align - off : 0; }
tree-level: foo (align) { int off; int D.1120; <bb 0>: off = 0 % align; if (off != 0) goto <L0>; else goto <L5>; <L5>:; D.1120 = 0; goto <bb 3> (<L2>); <L0>:; D.1120 = align - off; <L2>:; return D.1120; } RTL on i686-pc-linux-gnu after running the combiner (insn 34 31 40 0 (set (reg/i:SI 0 ax [ <result> ]) (const_int 0 [0x0])) 35 {*movsi_1} (nil) (nil)) (insn 40 34 0 0 (use (reg/i:SI 0 ax [ <result> ])) -1 (insn_list:REG_DEP_TRUE 34 (nil)) (nil)) Notice that "0 % variable" is optimized to 0. The simplification is performed in CSE. -- Summary: "0 % variable" isn't optimized to 0 Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kazu at cs dot umass dot edu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19643