[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    [Pcc] patch for optim2.c and match.c for one-step comparison and branch
From:       Tim Kelly <gtkelly () dialectronics ! com>
Date:       2022-11-03 12:19:44
Message-ID: 6363B1E0.8050105 () dialectronics ! com
[Download RAW message or body]

Hi All,
Below are two patches to fix an issue with optimization changing a 
comparison without changing the template.  This only occurs with 
one-step comparison and branch architectures (RISC-V, MIPS64) where 
optimization removes all instructions after the comparison and branch. 
   This can occur when the operands to be returned is already in the 
return register.  Without optimization the return result will be moved 
between temp registers; with optimization nothing needs to be done, so 
the instructions are removed.

It doesn't show up in MIPS64 because there is an error that is not 
treating the return register v0 properly, which results in an extra move 
between registers.  It doesn't show up in powerpc and aarch64 because 
they are two-step comparison and branch.

When the conditional is changed, the template for the node needs to be 
matched again, to avoid a situation where the matched template is no 
longer correct.  A call to relops() does the trick.

I also added a slight change to the code to return the value of relops, 
instead of defaulting to 0.

tim

-- 
Some people would rather lead us to death than follow others to safety.



Index: mip/optim2.c
===================================================================
RCS file: /cvsroot/pcc/mip/optim2.c,v
retrieving revision 1.99
diff -r1.99 optim2.c
570c570
< 	int i;
---
 > 	int i,  sh;
612a613,614
 > 				if ((sh = relops(p->dlip->ip_node->n_left)) != 0)
 > 					comperr("could not rematch op after negrel (sh = 0x%x)\n", sh);


Index: mip/match.c
===================================================================
RCS file: /cvsroot/pcc/mip/match.c,v
retrieving revision 1.107
diff -r1.107 match.c
744c748
<       return 0;
---
 >       return sh;

_______________________________________________
Pcc mailing list
Pcc@lists.ludd.ltu.se
https://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic