summaryrefslogtreecommitdiff
path: root/gcc/auto-inc-dec.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-10 15:13:54 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-10 15:13:54 +0000
commit8cff878b277f9af6c2827a87581baac5f768e12a (patch)
treed4e178503efd243eed24ff3b753cd998370d75d4 /gcc/auto-inc-dec.c
parent9610b14f8599a9db94822d3f0923b58b2f1177dc (diff)
downloadgcc-8cff878b277f9af6c2827a87581baac5f768e12a.tar.gz
[./]
2016-02-10 Basile Starynkevitch <basile@starynkevitch.net> {{merging with some of GCC 6, using svn merge -r222130:226090 ^/trunk ; UNSTABLE}} [gcc/] 2016-02-10 Basile Starynkevitch <basile@starynkevitch.net> {{ merging with trunk 226090 ; UNSTABLE }} * melt-run.proto.h: include tree-ssa-scopedtables.h * tree-ssa-dom.c: skip second record_edge_info git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@233272 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/auto-inc-dec.c')
-rw-r--r--gcc/auto-inc-dec.c79
1 files changed, 19 insertions, 60 deletions
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index 7e3dd89affe..3b9a1f360fb 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -21,36 +21,20 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "tm.h"
-#include "hash-set.h"
-#include "machmode.h"
-#include "vec.h"
-#include "double-int.h"
-#include "input.h"
-#include "alias.h"
-#include "symtab.h"
-#include "wide-int.h"
-#include "inchash.h"
+#include "backend.h"
+#include "predict.h"
#include "tree.h"
#include "rtl.h"
+#include "df.h"
+#include "alias.h"
#include "tm_p.h"
-#include "hard-reg-set.h"
-#include "predict.h"
-#include "hashtab.h"
-#include "function.h"
-#include "dominance.h"
-#include "cfg.h"
#include "cfgrtl.h"
-#include "basic-block.h"
#include "insn-config.h"
#include "regs.h"
#include "flags.h"
#include "except.h"
#include "diagnostic-core.h"
#include "recog.h"
-#include "statistics.h"
-#include "real.h"
-#include "fixed-value.h"
#include "expmed.h"
#include "dojump.h"
#include "explow.h"
@@ -60,7 +44,6 @@ along with GCC; see the file COPYING3. If not see
#include "stmt.h"
#include "expr.h"
#include "tree-pass.h"
-#include "df.h"
#include "dbgcnt.h"
#include "target.h"
@@ -134,7 +117,6 @@ along with GCC; see the file COPYING3. If not see
before the ref or +c if the increment was after the ref, then if we
can do the combination but switch the pre/post bit. */
-#ifdef AUTO_INC_DEC
enum form
{
@@ -505,9 +487,9 @@ attempt_change (rtx new_addr, rtx inc_reg)
PUT_MODE (mem_tmp, mode);
XEXP (mem_tmp, 0) = new_addr;
- old_cost = (set_src_cost (mem, speed)
+ old_cost = (set_src_cost (mem, mode, speed)
+ set_rtx_cost (PATTERN (inc_insn.insn), speed));
- new_cost = set_src_cost (mem_tmp, speed);
+ new_cost = set_src_cost (mem_tmp, mode, speed);
/* The first item of business is to see if this is profitable. */
if (old_cost < new_cost)
@@ -778,28 +760,6 @@ get_next_ref (int regno, basic_block bb, rtx_insn **next_array)
}
-/* Reverse the operands in a mem insn. */
-
-static void
-reverse_mem (void)
-{
- rtx tmp = mem_insn.reg1;
- mem_insn.reg1 = mem_insn.reg0;
- mem_insn.reg0 = tmp;
-}
-
-
-/* Reverse the operands in a inc insn. */
-
-static void
-reverse_inc (void)
-{
- rtx tmp = inc_insn.reg1;
- inc_insn.reg1 = inc_insn.reg0;
- inc_insn.reg0 = tmp;
-}
-
-
/* Return true if INSN is of a form "a = b op c" where a and b are
regs. op is + if c is a reg and +|- if c is a const. Fill in
INC_INSN with what is found.
@@ -868,7 +828,7 @@ parse_add_or_inc (rtx_insn *insn, bool before_mem)
{
/* Reverse the two operands and turn *_ADD into *_INC since
a = c + a. */
- reverse_inc ();
+ std::swap (inc_insn.reg0, inc_insn.reg1);
inc_insn.form = before_mem ? FORM_PRE_INC : FORM_POST_INC;
return true;
}
@@ -1028,7 +988,7 @@ find_inc (bool first_try)
find this. Only try it once though. */
if (first_try && !mem_insn.reg1_is_const)
{
- reverse_mem ();
+ std::swap (mem_insn.reg0, mem_insn.reg1);
return find_inc (false);
}
else
@@ -1129,7 +1089,7 @@ find_inc (bool first_try)
return false;
if (!rtx_equal_p (mem_insn.reg0, inc_insn.reg0))
- reverse_inc ();
+ std::swap (inc_insn.reg0, inc_insn.reg1);
}
other_insn
@@ -1179,7 +1139,7 @@ find_inc (bool first_try)
/* See comment above on find_inc (false) call. */
if (first_try)
{
- reverse_mem ();
+ std::swap (mem_insn.reg0, mem_insn.reg1);
return find_inc (false);
}
else
@@ -1198,7 +1158,7 @@ find_inc (bool first_try)
{
/* We know that mem_insn.reg0 must equal inc_insn.reg1
or else we would not have found the inc insn. */
- reverse_mem ();
+ std::swap (mem_insn.reg0, mem_insn.reg1);
if (!rtx_equal_p (mem_insn.reg0, inc_insn.reg0))
{
/* See comment above on find_inc (false) call. */
@@ -1237,7 +1197,7 @@ find_inc (bool first_try)
{
if (first_try)
{
- reverse_mem ();
+ std::swap (mem_insn.reg0, mem_insn.reg1);
return find_inc (false);
}
else
@@ -1481,8 +1441,6 @@ merge_in_block (int max_reg, basic_block bb)
}
}
-#endif
-
/* Discover auto-inc auto-dec instructions. */
namespace {
@@ -1510,11 +1468,10 @@ public:
/* opt_pass methods: */
virtual bool gate (function *)
{
-#ifdef AUTO_INC_DEC
+ if (!AUTO_INC_DEC)
+ return false;
+
return (optimize > 0 && flag_auto_inc_dec);
-#else
- return false;
-#endif
}
@@ -1525,7 +1482,9 @@ public:
unsigned int
pass_inc_dec::execute (function *fun ATTRIBUTE_UNUSED)
{
-#ifdef AUTO_INC_DEC
+ if (!AUTO_INC_DEC)
+ return 0;
+
basic_block bb;
int max_reg = max_reg_num ();
@@ -1548,7 +1507,7 @@ pass_inc_dec::execute (function *fun ATTRIBUTE_UNUSED)
free (reg_next_def);
mem_tmp = NULL;
-#endif
+
return 0;
}