On Thu, 2020-08-20 at 21:36 +0530, Senthil Kumar Selvaraj via Gcc wrote: > Pip Cet writes: > > > On Tue, Aug 18, 2020 at 6:52 AM Senthil Kumar Selvaraj > > <senthil.theco...@gmail.com> wrote: > > > > recognize such insns, but as it stands that define_insn would > > > > recognize the incorrect insn: > > > > > > > > [(set (reg:QI 0) (const_int 0)) > > > > (clobber (scratch:CC))] > > > > > > get_cc_reg_clobber_rtx also looks at the insn itself (i.e. whatever > > > the erstwhile NOTICE_UPDATE_CC hook did), so if the cc attribute is LDI, > > > and operands[1] is const0_rtx, it would return cc_reg_rtx as the clobber > > > reg. > > > > > > AFAICT, some passes after reload verify if operands match constraints, > > > and that would work in this case - I'm not sure if the pattern you > > > mentioned could show up, outside of wrong splitters/peepholes in the md > > > file. > > > > I don't think they can, but it's still another case of lying to GCC. > > > > At the very least, output_movqi should assert that it isn't asked to > > produce code for this situation. > > I agree. > > > Another approach would be to conservatively use a 'c' constraint and > > > clobber REG_CC for all reg-reg moves. > > > > I'd prefer splitting the constraint alternatives to have one clear-r0 > > alternative, an ldi alternative, and a clear -r1_31 alternative. > > > > As for define_subst, is it really worth it? If I'm reading the > > documentation correctly, it's not powerful enough to deal with scratch > > operands on its own, so we'd probably need three or four variants of > > define_subst just to handle those cases. > > Is this related to cmpelim not looking at REG_CC clobber if there are > other (clobber scratch..) preceding it? > > I'm probably missing something obvious, but what's the reason for > > keeping the CC-clobbering post-reload splitter when we already have a > > CC-setting one? Are there significant post-reload optimizations that > > can deal with a clobber but not an arbitrary assignment to CC? If so, > > wouldn't it be better to fix those optimizations? > > The post-reload splitter introduces the clobber. The wiki > suggests that approach if most insns clobber REG_CC, perhaps because of > the missed optimizations you describe below? If most patterns set/clobber the flags, then yes, it's slightly better to only expose them after reload. Various passes that directly grub through RTL rather than using helpers like single_set will optimize things better.
That's the approach I've taken with the H8 conversion, which is basically working at this point and when I have the time I walk through various minor codegen inefficiences. Jeff