From 00ec6daa3ca775bae5983d6df8d3085726f6c4b0 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 22 Sep 1999 03:40:28 +0200 Subject: [PATCH] Jan Hubicka * genrecog.c (not_both_true): Handle correctly cases when called for tests with different positions in the insn. From-SVN: r29573 --- gcc/ChangeLog | 5 +++++ gcc/genrecog.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 614f1f95995..93f0ee5f703 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 21 18:40:01 1999 Jan Hubicka + + * genrecog.c (not_both_true): Handle correctly cases when called for + tests with different positions in the insn. + Tue Sep 21 18:29:11 1999 Kaveh R. Ghazi * machmode.h (HOST_PTR_PRINTF): Move from here ... diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 4d3d74952dc..d63c8cf8fda 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -685,6 +685,44 @@ not_both_true (d1, d2, toplevel) int toplevel; { struct decision *p1, *p2; + int cmp; + + /* Don't compare strings on the different positions in insn. Doing so + is incorrect and results in false matches from constructs like + + [(set (subreg:HI (match_operand:SI "register_operand" "r") 0) + (subreg:HI (match_operand:SI "register_operand" "r") 0))] + vs + [(set (match_operand:HI "register_operand" "r") + (match_operand:HI "register_operand" "r"))] + + If we are presented with such, we are recursing through the remainder + of a node's success nodes (from the loop at the end of this function). + Skip forward until we come to a position that matches. + + Due to the way position strings are constructed, we know that iterating + forward from the lexically lower position (e.g. "00") will run into + the lexically higher position (e.g. "1") and not the other way around. + This saves a bit of effort. */ + + cmp = strcmp (d1->position, d2->position); + if (cmp != 0) + { + if (toplevel) + abort(); + + /* If the d2->position was lexically lower, swap. */ + if (cmp > 0) + p1 = d1; d1 = d2; d2 = p1; + + if (d1->success.first == 0) + return 0; + for (p1 = d1->success.first; p1; p1 = p1->next) + if (! not_both_true (p1, d2, 0)) + return 0; + + return 1; + } /* If they are both to test modes and the modes are different, they aren't both true. Similarly for codes, integer elements, and vector lengths. */ -- 2.30.2