https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86093
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |jakub at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Started with r255021. genmatch emits all checks as x == y || operand_equal_p (x, y, 0), the reason why e.g. long volatile i; long foo (void) { return i - i; } isn't optimized into 0 is that we actually wrap i into a NOP_EXPR to remove quals and only do MINUS_EXPR on the result of those NOP_EXPRs, which don't compare equal as pointers. So I think we should just do the same with POINTER_DIFF_EXPR, cast the operands to unqualified pointers.