diff mbox

rtl-optimization/71709, strcpy arg optimised out

Message ID 20160701071956.GD6605@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra July 1, 2016, 7:19 a.m. UTC
This patch fixes a thinko in find_call_crossed_cheap_reg.

For functions that return an argument unchanged, like strcat,
find_call_crossed_cheap_reg attempts to find an assignment between
a pseudo reg and the arg reg before the call, so that uses of the
pseudo after the call can instead use the return value.  The exit
condition on the loop looking at previous insns was wrong.  Uses of
the arg reg don't matter.  What matters is the insn setting the arg
reg as any assignment involving the arg reg prior to that insn is
likely a completely unrelated use of the hard reg.

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

	PR rtl-optimization/71709
	* ira-lives.c (find_call_crossed_cheap_reg): Exit loop on arg reg
	being set, not referenced.

Comments

Bernd Schmidt July 1, 2016, 9:48 a.m. UTC | #1
On 07/01/2016 09:19 AM, Alan Modra wrote:
> 	PR rtl-optimization/71709
> 	* ira-lives.c (find_call_crossed_cheap_reg): Exit loop on arg reg
> 	being set, not referenced.

Looks OK.


Bernd
diff mbox

Patch

diff --git a/gcc/ira-lives.c b/gcc/ira-lives.c
index 6950ffb..6b7ee81 100644
--- a/gcc/ira-lives.c
+++ b/gcc/ira-lives.c
@@ -1014,7 +1014,7 @@  find_call_crossed_cheap_reg (rtx_insn *insn)
 		  break;
 		}
 
-	      if (reg_overlap_mentioned_p (reg, PATTERN (prev)))
+	      if (reg_set_p (reg, prev))
 		break;
 	    }
 	  prev = PREV_INSN (prev);