suppose we have insns: ... A B C D ... all congruent insn_compare() The current way the CSE is done is: The first try will be try_to_cse(A,B). If it succeed, A & B have been merged (AB) and the next try will be done with he next instruction: try_to_cse(AB,C). That's good. However, if it fails, the next try will be : try_to_cse(A,C). If this one also fails, the next one will be: try_to_cse(A,D) And so on. In other words, all the tries are done with A. If it happen that A can be eliminated, no elimination are done because the other pairs, not involving A are never tried. Ideally, we should try all possible pairs: A-B, A-C & B-C. But an easy way to improve the current situation is, in case of failure, in the next try to not reuse the original first instruction but the other one. So instead of testing: A-B, A-C, A-D, ... we will test: A-B, B-C, C-D, ... with the result that an 'bad' instruction can't block anymore the following pairs. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- cse.c | 2 ++ validation/optim/cse-cmp-next.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cse.c b/cse.c index 79d37cfd1..06d603ffe 100644 --- a/cse.c +++ b/cse.c @@ -359,6 +359,8 @@ static struct instruction * try_to_cse(struct entrypoint *ep, struct instruction i1 = cse_one_instruction(i2, i1); remove_instruction(&b1->insns, i1, 1); add_instruction_to_end(i1, common); + } else { + i1 = i2; } return i1; diff --git a/validation/optim/cse-cmp-next.c b/validation/optim/cse-cmp-next.c index e7cf16235..50fdbac09 100644 --- a/validation/optim/cse-cmp-next.c +++ b/validation/optim/cse-cmp-next.c @@ -9,7 +9,6 @@ void foo(int p, int i, int f, int *ref, int *dst, int *src) /* * check-name: cse-cmp-next * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(1,2): mul\\. -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html