The following self-contained md file generates an infinite loop in genattrtab:
(define_attr "fpsize" "short,long" (const_string "short"))
(define_attr "fplength" ""
(if_then_else
(eq_attr "fpsize" "long")
(const_int 8)
(const_int 4)))
(define_insn "br_pred"
[(set (pc)
(if_then_else
(match_operator 2 "easy_comparison"
[(match_operand:BI 0 "register_operand" "c")
(const_int 0)])
(label_ref (match_operand 1 "" ""))
(pc)))]
""
"brtest"
[(set (attr "fplength") (const_int 4))
(set (attr "fpsize")
(if_then_else (eq_attr "fplength" "4") (const_string "short")
(const_string "long"))
)
])
The infinite loop occurs in genattrtab.c:get_attr_order. The loop inside
get_attr_order never exits. It seems to be a topological sort, and since fpsize
depends on fplength and vice-versa, it keeps looping.
The strange thing is that when genattrtab looks at all the attributes and
instructions, it accumulates all possible values for each attribute, so the
list of attribute values for fpsize and fplength are indeed dependent on each
other even though in the context of br_pred, they are not inter-dependent
because we fixed the value of fplength at 4, so calculating the value of fpsize
should be straightforward.
It feels like this could be improved. Do you agree?
Paulo Matos
> -----Original Message-----
> From: Richard Biener [mailto:[email protected]]
> Sent: 11 February 2013 12:49
> To: Paulo Matos
> Cc: [email protected]
> Subject: Re: genattrtab regression: infinite loop
>
> On Mon, Feb 11, 2013 at 1:36 PM, Paulo Matos <[email protected]> wrote:
> >> -----Original Message-----
> >> From: Richard Biener [mailto:[email protected]]
> >> Sent: 11 February 2013 10:56
> >> To: Paulo Matos
> >> Cc: [email protected]
> >> Subject: Re: genattrtab regression: infinite loop
> >>
> >>
> >> Does it work with -fno-aggressive-loop-optimizations?
> >>
> >
> > That's new in 4.8, right? genattrtab.c is compiled with the host compiler
> which in my case is 4.7.2.
>
> Yes.
>
> > --
> > Paulo Matos