On Wed, Apr 16, 2025 at 08:52:17PM +0200, Jakub Jelinek wrote: > The following testcase ICEs since r15-1579 (addition of late combiner), > because *clrmem_short can't be split. > The problem is that the define_insn uses > (use (match_operand 1 "nonmemory_operand" "n,a,a,a")) > (use (match_operand 2 "immediate_operand" "X,R,X,X")) > (clobber (match_scratch:P 3 "=X,X,X,&a")) > and define_split assumed that if operands[1] is const_int_operand, > match_scratch will be always scratch, and it will be reg only if > it was the last alternative where operands[1] is a reg. > The pattern doesn't guarantee it though, of course RA will not try to > uselessly assign a reg there if it is not needed, but during RA > on the testcase below we match the last alternative, but then comes > late combiner and propagates const_int 3 into operands[1]. And that > matches fine, match_scratch matches either scratch or reg and the constraint > in that case is X for the first variant, so still just fine. But we won't > split that because the splitters only expect scratch. > > The following patch fixes it by using match_scratch instead of scratch, > so that it accepts either. > > Bootstrapped on s390x-linux, ok for trunk if regtesting passes as well?
Regtested successfully as well. > 2025-04-16 Jakub Jelinek <ja...@redhat.com> > > PR target/119834 > * config/s390/s390.md (define_split after *cpymem_short): Use > (clobber (match_scratch N)) instead of (clobber (scratch)). Use > (match_dup 4) and operands[4] instead of (match_dup 3) and operands[3] > in the last of those. > (define_split after *clrmem_short): Use (clobber (match_scratch N)) > instead of (clobber (scratch)). > (define_split after *cmpmem_short): Likewise. > > * g++.target/s390/pr119834.C: New test. Jakub