diff mbox

[RS6000] Don't expand strcmp and strncmp inline when -Os

Message ID 20170119121712.GR32333@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Jan. 19, 2017, 12:17 p.m. UTC
The inline expansions are non-trivial, so aren't really appropriate
for -Os.

Bootstrapped and regression tested powerpc64le-linux.  OK to apply?

	* config/rs6000/rs6000.md (cmpstrnsi, cmpstrsi): Fail if
	optimizing for size.

Comments

Segher Boessenkool Jan. 19, 2017, 10:46 p.m. UTC | #1
On Thu, Jan 19, 2017 at 10:47:12PM +1030, Alan Modra wrote:
> --- a/gcc/config/rs6000/rs6000.md
> +++ b/gcc/config/rs6000/rs6000.md
> @@ -9102,7 +9102,8 @@ (define_expand "cmpstrnsi"
>  	      (use (match_operand:SI 4))])]
>    "TARGET_CMPB && (BYTES_BIG_ENDIAN || TARGET_LDBRX)"
>  {
> -  if (expand_strn_compare (operands, 0))
> +  if (!optimize_insn_for_size_p ()
> +      && expand_strn_compare (operands, 0))
>      DONE;
>    else	
>      FAIL;

Please do either

{
  if (optimize_insn_for_speed_p () && expand_strn_compare (operands, 0))
    DONE;
  else
    FAIL;
}

or

{
  if (optimize_insn_for_size_p ())
    FAIL;

  if (expand_strn_compare (operands, 0))
    DONE;
  else
    FAIL;
}

(i.e. use a positive condition).

(Please remove the trailing tab while you're touching this code, too).

Okay with such a change.  Thanks,


Segher
diff mbox

Patch

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 9ef3b11..d729f40 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -9102,7 +9102,8 @@  (define_expand "cmpstrnsi"
 	      (use (match_operand:SI 4))])]
   "TARGET_CMPB && (BYTES_BIG_ENDIAN || TARGET_LDBRX)"
 {
-  if (expand_strn_compare (operands, 0))
+  if (!optimize_insn_for_size_p ()
+      && expand_strn_compare (operands, 0))
     DONE;
   else	
     FAIL;
@@ -9121,7 +9122,8 @@  (define_expand "cmpstrsi"
 	      (use (match_operand:SI 3))])]
   "TARGET_CMPB && (BYTES_BIG_ENDIAN || TARGET_LDBRX)"
 {
-  if (expand_strn_compare (operands, 1))
+  if (!optimize_insn_for_size_p ()
+      && expand_strn_compare (operands, 1))
     DONE;
   else	
     FAIL;