diff mbox series

[2/2] fix rem_usage()

Message ID 20201227092759.30999-3-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series fix rem_usage() | expand

Commit Message

Luc Van Oostenryck Dec. 27, 2020, 9:27 a.m. UTC
rem_usage() is used to remove an element from a def-use chain. Optionally,
if the chain become empty, the defining instruction can also be killed.

This optional part is currently be done on all pseudos but only those
having a definition should be concerned.

Fix this by adding a check so that only PSEUDO_REGs and PSEUDO_PHIs are killed.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ramsay Jones Dec. 28, 2020, 5:22 p.m. UTC | #1
On 27/12/2020 09:27, Luc Van Oostenryck wrote:
> rem_usage() is used to remove an element from a def-use chain. Optionally,

Hmm, rename this to 'remove_usage()' at the same time?

ATB,
Ramsay Jones

> if the chain become empty, the defining instruction can also be killed.
> 
> This optional part is currently be done on all pseudos but only those
> having a definition should be concerned.
> 
> Fix this by adding a check so that only PSEUDO_REGs and PSEUDO_PHIs are killed.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  simplify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/simplify.c b/simplify.c
> index a877b693b610..12482d787189 100644
> --- a/simplify.c
> +++ b/simplify.c
> @@ -271,7 +271,7 @@ static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill)
>  {
>  	if (has_use_list(p)) {
>  		delete_pseudo_user_list_entry(&p->users, usep, 1);
> -		if (kill && !p->users)
> +		if (kill && !p->users && has_definition(p))
>  			kill_instruction(p->def);
>  	}
>  }
>
Luc Van Oostenryck Dec. 28, 2020, 9:39 p.m. UTC | #2
On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
> 
> 
> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
> > rem_usage() is used to remove an element from a def-use chain. Optionally,
> 
> Hmm, rename this to 'remove_usage()' at the same time?

It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
for internal uses than 'remove_usage()'.

-- Luc
Ramsay Jones Dec. 28, 2020, 10:09 p.m. UTC | #3
On 28/12/2020 21:39, Luc Van Oostenryck wrote:
> On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
>>
>>
>> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
>>> rem_usage() is used to remove an element from a def-use chain. Optionally,
>>
>> Hmm, rename this to 'remove_usage()' at the same time?
> 
> It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
> for internal uses than 'remove_usage()'.

Ugh! I just took a quick look. Ugly. ;-)

Well, I think I would rename it 'remove_use()' or somesuch instead.

ATB,
Ramsay Jones
Ramsay Jones Dec. 28, 2020, 10:30 p.m. UTC | #4
On 28/12/2020 22:09, Ramsay Jones wrote:
> 
> 
> On 28/12/2020 21:39, Luc Van Oostenryck wrote:
>> On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
>>>
>>>
>>> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
>>>> rem_usage() is used to remove an element from a def-use chain. Optionally,
>>>
>>> Hmm, rename this to 'remove_usage()' at the same time?
>>
>> It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
>> for internal uses than 'remove_usage()'.
> 
> Ugh! I just took a quick look. Ugly. ;-)
> 
> Well, I think I would rename it 'remove_use()' or somesuch instead.

Ahem, except you can't, because it is already used ... (facepalm).

Ho Hum. ;-)

ATB,
Ramsay Jones
diff mbox series

Patch

diff --git a/simplify.c b/simplify.c
index a877b693b610..12482d787189 100644
--- a/simplify.c
+++ b/simplify.c
@@ -271,7 +271,7 @@  static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill)
 {
 	if (has_use_list(p)) {
 		delete_pseudo_user_list_entry(&p->users, usep, 1);
-		if (kill && !p->users)
+		if (kill && !p->users && has_definition(p))
 			kill_instruction(p->def);
 	}
 }