This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Use ADD if result isn't used in memory address
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Cc: Uros Bizjak <ubizjak at gmail dot com>
- Date: Tue, 14 Sep 2010 07:02:01 -0700
- Subject: PATCH: Use ADD if result isn't used in memory address
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
When result of ADD isn't used in memory address, we should use ADD
instead of LEA. OK for trunk?
Thanks.
H.J.
---
2010-09-14 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.c (ix86_lea_for_add_ok): Return false if
result isn't used in memory address.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 734ff3d..0b542fa 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14969,15 +14969,19 @@ ix86_lea_for_add_ok (rtx insn, rtx operands[])
else
{
int dist_define, dist_use;
+
+ /* Return false if REGNO0 isn't used in memory address. */
+ dist_use = distance_agu_use (regno0, insn);
+ if (dist_use <= 0)
+ return false;
+
dist_define = distance_non_agu_define (regno1, regno2, insn);
if (dist_define <= 0)
return true;
/* If this insn has both backward non-agu dependence and forward
agu dependence, the one with short distance take effect. */
- dist_use = distance_agu_use (regno0, insn);
- if (dist_use <= 0
- || (dist_define + IX86_LEA_PRIORITY) < dist_use)
+ if ((dist_define + IX86_LEA_PRIORITY) < dist_use)
return false;
return true;