https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77824
Bug ID: 77824 Summary: unreachable code in SLSR GIMPLE pass Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ebotcazou at gcc dot gnu.org Target Milestone: --- I played a little with the SLSR GIMPLE pass and, while it's clearly written and very well documented, it contains an oversight which deactivates a small part of the processing: /* Given GS which is a copy of a scalar integer type, make at least one appropriate entry in the candidate table. This interface is included for completeness, but is unnecessary if this pass immediately follows a pass that performs copy propagation, such as DOM. */ static void slsr_process_copy (gimple *gs, tree rhs1, bool speed) slsr_process_copy is never invoked because it's called from: case MODIFY_EXPR: slsr_process_copy (gs, rhs1, speed); break; and there are no MODIFY_EXPRs left in GIMPLE. I think that all occurrences of MODIFY_EXPR should be replaced with SSA_NAME in the file. And, at least in the case I played with, the additional processing makes a difference because there are unpropagated copies in the GIMPLE IR. Another minor nit: in replace_mult_candidate if (wi::fits_shwi_p (bump) && bump.to_shwi () != HOST_WIDE_INT_MIN /* It is not useful to replace casts, copies, or adds of an SSA name and a constant. */ && cand_code != MODIFY_EXPR && !CONVERT_EXPR_CODE_P (cand_code) && cand_code != PLUS_EXPR && cand_code != POINTER_PLUS_EXPR && cand_code != MINUS_EXPR) Why not just testing c->kind instead of cand_code?