This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] for [laurent@guerby.net: Re: Slightly different Ada RTS build verify_ssa error]
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, laurent at guerby dot net,kenner at vlsi1 dot ultra dot nyu dot edu
- Date: Sat, 18 Sep 2004 22:20:38 +0200
- Subject: [PATCH] for [laurent@guerby.net: Re: Slightly different Ada RTS build verify_ssa error]
- References: <20040917212826.GC3425@atrey.karlin.mff.cuni.cz>
Hello,
> On Thu, 2004-09-16 at 13:35, Richard Kenner wrote:
> > The latest checkins seem to have fixed a few things, but I now get this error
> > message, which looks slightly different from what I got before:
> >
> > ../../xgcc -B../../ -c -g -O2 -W -Wall -gnatpg g-regexp.adb -o g-regexp.o
> > g-regexp.adb: In function 'GNAT.REGEXP.COMPILE.CREATE_PRIMARY_TABLE.CREATE_SIMPLE':
> > g-regexp.adb:521: error: Missing definition
> > for SSA_NAME: k.111D.2244_174
> > in statement:
> > # C.108D.2240_273 = V_MAY_DEF <C.108D.2240_515>;
> > # TMT.393D.3787_272 = V_MAY_DEF <TMT.393D.3787_491>;
> > # TMT.394D.3788_271 = V_MAY_DEF <TMT.394D.3788_398>;
> > # TMT.395D.3789_270 = V_MAY_DEF <TMT.395D.3789_540>;
> > # TMT.396D.3790_269 = V_MAY_DEF <TMT.396D.3790_120>;
> > # TMT.397D.3791_268 = V_MAY_DEF <TMT.397D.3791_504>;
> > # TMT.398D.3792_264 = V_MAY_DEF <TMT.398D.3792_321>;
> > # VUSE <D.2548_277>;
> > *D.2546_175 = gnat__regexp__set (D.2548, D.2545_170, k.111D.2244_174, D.2211_173);
> >
> > Note that the first line shows how to reproduce this.
I am fairly sure the fix I commited on 2004-09-16
* tree-ssa-loop-ivopts.c
...
(find_interesting_uses_stmt): Handle memory = nontrivial_expression
statements correctly.
should fix this problem; does it still reproduce for you?
> On x86 I still get the original error:
>
> ../../xgcc -B../../ -c -g -O2 -fPIC -W -Wall -gnatpg g-regexp.adb -o g-regexp.o
> g-regexp.adb: In function 'GNAT.REGEXP.COMPILE.CREATE_SECONDARY_TABLE':
> g-regexp.adb:1087: error: Definition in block 5 does not dominate use in block 110
> for SSA_NAME: D.1826_717
> in statement:
> ivtmp.868D.4703_563 = &(*table.51D.1822_144)[J99b.52D.1827_3]{lb: 1 sz: D.1826_717 * 4}[0];
>
> +===========================GNAT BUG DETECTED==============================+
> | 4.0.0 20040917 (experimental) (i686-pc-linux-gnu) verify_ssa failed. |
> | Error detected at g-regexp.adb:1389:1 |
>
> But I'm able to workaround it with the patch at the end of this message.
> Note that permuting the two for loops restores the ICE.
This patch fixes the problem (which was that non-loop invariant lower
bound/step could still leak out of idx_find_step in case the index
of the array was invariant).
Bootstrapped & regtested on i686.
Zdenek
* tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): New function.
(idx_find_step): Check that step is loop invariant even if the
index is loop invariant.
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.11
diff -c -3 -p -r2.11 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 17 Sep 2004 21:54:42 -0000 2.11
--- tree-ssa-loop-ivopts.c 18 Sep 2004 20:07:11 -0000
*************** find_interesting_uses_cond (struct ivopt
*** 1146,1151 ****
--- 1146,1184 ----
record_use (data, cond_p, civ, stmt, USE_COMPARE);
}
+ /* Returns true if expression EXPR is obviously invariant in LOOP,
+ i.e. if all its operands are defined outside of the LOOP. */
+
+ static bool
+ expr_invariant_in_loop_p (struct loop *loop, tree expr)
+ {
+ basic_block def_bb;
+ unsigned i, len;
+
+ if (is_gimple_min_invariant (expr))
+ return true;
+
+ if (TREE_CODE (expr) == SSA_NAME)
+ {
+ def_bb = bb_for_stmt (SSA_NAME_DEF_STMT (expr));
+ if (def_bb
+ && flow_bb_inside_loop_p (loop, def_bb))
+ return false;
+
+ return true;
+ }
+
+ if (!EXPR_P (expr))
+ return false;
+
+ len = first_rtl_op (TREE_CODE (expr));
+ for (i = 0; i < len; i++)
+ if (!expr_invariant_in_loop_p (loop, TREE_OPERAND (expr, i)))
+ return false;
+
+ return true;
+ }
+
/* Cumulates the steps of indices into DATA and replaces their values with the
initial ones. Returns false when the value of the index cannot be determined.
Callback for for_each_index. */
*************** idx_find_step (tree base, tree *idx, voi
*** 1163,1171 ****
struct ifs_ivopts_data *dta = data;
struct iv *iv;
tree step, type, iv_type, iv_step, lbound;
- basic_block def_bb;
struct loop *loop = dta->ivopts_data->current_loop;
!
if (TREE_CODE (*idx) != SSA_NAME)
return true;
--- 1196,1217 ----
struct ifs_ivopts_data *dta = data;
struct iv *iv;
tree step, type, iv_type, iv_step, lbound;
struct loop *loop = dta->ivopts_data->current_loop;
!
! /* If base is array, first check whether we will be able to move the
! reference out of the loop (in order to take its address in strength
! reduction). In order for this to work we need both lower bound
! and step to be loop invariants. */
! if (TREE_CODE (base) == ARRAY_REF)
! {
! step = array_ref_element_size (base);
! lbound = array_ref_low_bound (base);
!
! if (!expr_invariant_in_loop_p (loop, step)
! || !expr_invariant_in_loop_p (loop, lbound))
! return false;
! }
!
if (TREE_CODE (*idx) != SSA_NAME)
return true;
*************** idx_find_step (tree base, tree *idx, voi
*** 1183,1209 ****
if (TREE_CODE (base) == ARRAY_REF)
{
step = array_ref_element_size (base);
- lbound = array_ref_low_bound (base);
/* We only handle addresses whose step is an integer constant. */
if (TREE_CODE (step) != INTEGER_CST)
return false;
-
- /* We need the lower bound to be invariant in loop, since otherwise
- we are unable to initialize a new induction variable created
- in strength reduction -- we need to take the address of the
- reference in front of the loop. */
- if (is_gimple_min_invariant (lbound))
- ; /* Nothing to do. */
- else if (TREE_CODE (lbound) != SSA_NAME)
- return false;
- else
- {
- def_bb = bb_for_stmt (SSA_NAME_DEF_STMT (lbound));
- if (def_bb
- && flow_bb_inside_loop_p (loop, def_bb))
- return false;
- }
}
else
/* The step for pointer arithmetics already is 1 byte. */
--- 1229,1238 ----