Fix UB in dse.c (PR rtl-optimization/85431)

Message ID 20180417205748.GK8577@tucnak
State New
Headers show
Series
  • Fix UB in dse.c (PR rtl-optimization/85431)
Related show

Commit Message

Jakub Jelinek April 17, 2018, 8:57 p.m.
Hi!

As mentioned, for BLKmode stores with MEM_SIZE of 0 we invoke UB,
lowpart_bitmask (0) is called and that shifts an UHWI by 64.
Zero size MEMs should only appear in inline asm and shouldn't be interesting
to DSE at all, they can't make other stores dead, nor can be removed as dead
themselves.

Fixed by just ignoring them.  Bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2018-04-17  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/85431
	* dse.c (record_store): Ignore zero width stores.


	Jakub

Comments

Eric Botcazou April 17, 2018, 9:09 p.m. | #1
> Fixed by just ignoring them.  Bootstrapped/regtested on x86_64-linux and

> i686-linux, ok for trunk?

> 

> 2018-04-17  Jakub Jelinek  <jakub@redhat.com>

> 

> 	PR rtl-optimization/85431

> 	* dse.c (record_store): Ignore zero width stores.


OK, thanks.

-- 
Eric Botcazou
Jeff Law April 18, 2018, 3:48 p.m. | #2
On 04/17/2018 02:57 PM, Jakub Jelinek wrote:
> Hi!

> 

> As mentioned, for BLKmode stores with MEM_SIZE of 0 we invoke UB,

> lowpart_bitmask (0) is called and that shifts an UHWI by 64.

> Zero size MEMs should only appear in inline asm and shouldn't be interesting

> to DSE at all, they can't make other stores dead, nor can be removed as dead

> themselves.

> 

> Fixed by just ignoring them.  Bootstrapped/regtested on x86_64-linux and

> i686-linux, ok for trunk?

> 

> 2018-04-17  Jakub Jelinek  <jakub@redhat.com>

> 

> 	PR rtl-optimization/85431

> 	* dse.c (record_store): Ignore zero width stores.

OK.
jeff

Patch

--- gcc/dse.c.jj	2018-01-27 07:26:11.826913649 +0100
+++ gcc/dse.c	2018-04-17 17:53:55.019932700 +0200
@@ -1417,6 +1417,9 @@  record_store (rtx body, bb_info_t bb_inf
       return 0;
     }
 
+  if (known_eq (width, 0))
+    return 0;
+
   if (group_id >= 0)
     {
       /* In the restrictive case where the base is a constant or the