On July 27, 2015 5:18:55 PM GMT+02:00, Michael Matz <m...@suse.de> wrote: >Hi, > >On Mon, 27 Jul 2015, Richard Biener wrote: > >> > > static inline tree >> > > gimple_assign_rhs1 (const_gimple gs) >> > > { >> > > GIMPLE_CHECK (gs, GIMPLE_ASSIGN); >> > > return gimple_op (gs, 1); >> > > } >> > > >> > > and the hidden checking is due to gimple_op being >> > > >> > > static inline tree * >> > > gimple_ops (gimple gs) >> > > { >> > > size_t off; >> > > >> > > /* All the tuples have their operand vector at the very bottom >> > > of the structure. Note that those structures that do not >> > > have an operand vector have a zero offset. */ >> > > off = gimple_ops_offset_[gimple_statement_structure (gs)]; >> > > gcc_gimple_checking_assert (off != 0); > >I once experimented with making the multiple checking and removing the >actual memory accesses by exposing the real content of gss_for_code_[] >(for gss_for_code(), used by gimple_statement_structure()) and >gimple_ops_offset_[] to the inlined functions, i.e. by defining them in > >gimple.h, not just declaring them. > >Still wouldn't help the -O0 case, but with -O2 only the first check for > >being GIMPLE_ASSING remains, everything else is constant folded. > >> > > The simplest thing would be to use >> > > >> > > GIMPLE_CHECK (gs, GIMPLE_ASSIGN); >> > > return as_a <const gassign *> (gs)->op[1]; >> > > >> > > but that's not optimal either because we check we have a gassign >> > > again (not optimized in stage1). So I decided to invent a fancy >> > > as_a which reports errors similar to GIMPLE_CHECK and makes the >> > > code look like > >I'm confused. as_a<> already does checking: >as_a (U *p) >{ > gcc_checking_assert (is_a <T> (p)); > return is_a_helper <T>::cast (p); >} > >(were the is_a<> variant here has the same test as GIMPLE_CHECK). >So, if you have the as_a call, you can as well simply remove the >GIMPLE_CHECK, and be done with it, without ... > >> > > const gassign *ass = GIMPLE_CHECK2<const gassign *> (gs); > >... introducing this. What am I missing?
It would remove the fancy checking fail message in favor of a simple ICE. Otherwise nothing, of course. Oh, and the ability to separately turn on/off GIMPLE checking. Richard. > >Ciao, >Michael.