[1/12] expr: Small optimization [PR102989]

Message ID ZNPXsZL3/mmxuDT5@tucnak
State Unresolved
Headers
Series GCC _BitInt support [PR102989] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek Aug. 9, 2023, 6:15 p.m. UTC
  Hi!

Small optimization to avoid testing modifier multiple times.

2023-08-09  Jakub Jelinek  <jakub@redhat.com>

	PR c/102989
	* expr.cc (expand_expr_real_1) <case MEM_REF>: Add an early return for
	EXPAND_WRITE or EXPAND_MEMORY modifiers to avoid testing it multiple
	times.


	Jakub
  

Comments

Richard Biener Aug. 10, 2023, 7:18 a.m. UTC | #1
On Wed, 9 Aug 2023, Jakub Jelinek wrote:

> Hi!
> 
> Small optimization to avoid testing modifier multiple times.

OK.

Richard.

> 2023-08-09  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c/102989
> 	* expr.cc (expand_expr_real_1) <case MEM_REF>: Add an early return for
> 	EXPAND_WRITE or EXPAND_MEMORY modifiers to avoid testing it multiple
> 	times.
> 
> --- gcc/expr.cc.jj	2023-08-08 15:55:06.499164554 +0200
> +++ gcc/expr.cc	2023-08-08 15:59:36.594382141 +0200
> @@ -11248,17 +11248,15 @@ expand_expr_real_1 (tree exp, rtx target
>  	set_mem_addr_space (temp, as);
>  	if (TREE_THIS_VOLATILE (exp))
>  	  MEM_VOLATILE_P (temp) = 1;
> -	if (modifier != EXPAND_WRITE
> -	    && modifier != EXPAND_MEMORY
> -	    && !inner_reference_p
> +	if (modifier == EXPAND_WRITE || modifier == EXPAND_MEMORY)
> +	  return temp;
> +	if (!inner_reference_p
>  	    && mode != BLKmode
>  	    && align < GET_MODE_ALIGNMENT (mode))
>  	  temp = expand_misaligned_mem_ref (temp, mode, unsignedp, align,
>  					    modifier == EXPAND_STACK_PARM
>  					    ? NULL_RTX : target, alt_rtl);
> -	if (reverse
> -	    && modifier != EXPAND_MEMORY
> -	    && modifier != EXPAND_WRITE)
> +	if (reverse)
>  	  temp = flip_storage_order (mode, temp);
>  	return temp;
>        }
> 
> 	Jakub
> 
>
  

Patch

--- gcc/expr.cc.jj	2023-08-08 15:55:06.499164554 +0200
+++ gcc/expr.cc	2023-08-08 15:59:36.594382141 +0200
@@ -11248,17 +11248,15 @@  expand_expr_real_1 (tree exp, rtx target
 	set_mem_addr_space (temp, as);
 	if (TREE_THIS_VOLATILE (exp))
 	  MEM_VOLATILE_P (temp) = 1;
-	if (modifier != EXPAND_WRITE
-	    && modifier != EXPAND_MEMORY
-	    && !inner_reference_p
+	if (modifier == EXPAND_WRITE || modifier == EXPAND_MEMORY)
+	  return temp;
+	if (!inner_reference_p
 	    && mode != BLKmode
 	    && align < GET_MODE_ALIGNMENT (mode))
 	  temp = expand_misaligned_mem_ref (temp, mode, unsignedp, align,
 					    modifier == EXPAND_STACK_PARM
 					    ? NULL_RTX : target, alt_rtl);
-	if (reverse
-	    && modifier != EXPAND_MEMORY
-	    && modifier != EXPAND_WRITE)
+	if (reverse)
 	  temp = flip_storage_order (mode, temp);
 	return temp;
       }