https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68590
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Not sure how this changed with the code but this is <= folding into == and then (simplify (eq @0 @0) (if (! FLOAT_TYPE_P (TREE_TYPE (@0)) || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (@0)))) { constant_boolean_node (true, type); })) where @0 is "omitted". if (op1 == op0 || operand_equal_p (op1, op0, 0)) { { /* #line 1857 "/space/rguenther/src/svn/trunk/gcc/match.pd" */ tree captures[1] ATTRIBUTE_UNUSED = { op0 }; /* #line 1857 "/space/rguenther/src/svn/trunk/gcc/match.pd" */ if (! FLOAT_TYPE_P (TREE_TYPE (captures[0])) || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (captures[0])))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Applying pattern match.pd:1859, %s:%d\n", __FILE__, __LINE__); tree res; res = constant_boolean_node (true, type); if (TREE_SIDE_EFFECTS (captures[0])) res = build2_loc (loc, COMPOUND_EXPR, type, fold_ignored_result (captures[0]), res); return res; so the save_expr doesn't originate here. Instead it originates from (for cmp (ge le) (simplify (cmp @0 @0) (eq @0 @0))) hmm. Yes, we use @0 twice here. But we also use a matching capture, sth we (unfortunately) don't record (yet). We _do_ have a load that we compare so avoiding the redundant computation when we duplicate an operand makes sense even when there is no side-effect present (that was the objective of the change). Simplifying (le s1->length s1->length) to (eq save_expr <s1->length> save_expr <s1->length>) looks like a win. Now simplifying that down to (save_expr <s1->length>, 1) is "correct" as well. And we can't just drop random save_exprs here because of the comment in save_expr: /* This expression might be placed ahead of a jump to ensure that the value was computed on both sides of the jump. So make sure it isn't eliminated as dead. */ TREE_SIDE_EFFECTS (t) = 1; not sure what this is refering to... it sounds confusing - if it was placed there and did not have side-effects it better should have a user via a data dependence.