aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Sawdey <acsawdey@linux.ibm.com>2018-10-30 17:05:37 +0000
committerAaron Sawdey <acsawdey@gcc.gnu.org>2018-10-30 12:05:37 -0500
commit320314dba395437c41c2b4e65acb62dbb816d8f9 (patch)
tree4d8697b8f8621d5b4369b3888c5e4501d5408fe8
parentd2bfc447e80b028f860149439e48544d967af685 (diff)
downloadgcc-320314dba395437c41c2b4e65acb62dbb816d8f9.zip
gcc-320314dba395437c41c2b4e65acb62dbb816d8f9.tar.gz
gcc-320314dba395437c41c2b4e65acb62dbb816d8f9.tar.bz2
rs6000.md (bswapdi2): Force address into register if not in indexed or indirect form.
2018-10-30 Aaron Sawdey <acsawdey@linux.ibm.com> * config/rs6000/rs6000.md (bswapdi2): Force address into register if not in indexed or indirect form. (bswapdi2_load): Change predicate to indexed_or_indirect_operand. (bswapdi2_store): Ditto. * config/rs6000/rs6000.c (rs6000_force_indexed_or_indirect_mem): New helper function. * config/rs6000/rs6000-protos.h (rs6000_force_indexed_or_indirect_mem): Prototype for helper function. From-SVN: r265632
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/rs6000/rs6000-protos.h1
-rw-r--r--gcc/config/rs6000/rs6000.c16
-rw-r--r--gcc/config/rs6000/rs6000.md14
4 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 851502e..01e58aa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2018-10-30 Aaron Sawdey <acsawdey@linux.ibm.com>
+
+ * config/rs6000/rs6000.md (bswapdi2): Force address into register
+ if not in indexed or indirect form.
+ (bswapdi2_load): Change predicate to indexed_or_indirect_operand.
+ (bswapdi2_store): Ditto.
+ * config/rs6000/rs6000.c (rs6000_force_indexed_or_indirect_mem): New
+ helper function.
+ * config/rs6000/rs6000-protos.h (rs6000_force_indexed_or_indirect_mem):
+ Prototype for helper function.
+
2018-10-30 Martin Sebor <msebor@redhat.com>
* doc/extend.texi (optimize): Clarify/expand attribute documentation.
diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index bb2584b..30dc896 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -47,6 +47,7 @@ extern bool legitimate_constant_pool_address_p (const_rtx, machine_mode,
extern bool legitimate_indirect_address_p (rtx, int);
extern bool legitimate_indexed_address_p (rtx, int);
extern bool avoiding_indexed_address_p (machine_mode);
+extern rtx rs6000_force_indexed_or_indirect_mem (rtx x);
extern rtx rs6000_got_register (rtx);
extern rtx find_addr_reg (rtx);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4f113cb..30b7266 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -8423,6 +8423,22 @@ rs6000_const_not_ok_for_debug_p (rtx x)
return false;
}
+/* Helper function for making sure we will make full
+ use of indexed addressing. */
+
+rtx
+rs6000_force_indexed_or_indirect_mem (rtx x)
+{
+ machine_mode m = GET_MODE (x);
+ if (!indexed_or_indirect_operand (x, m))
+ {
+ rtx addr = XEXP (x, 0);
+ addr = force_reg (Pmode, addr);
+ x = replace_equiv_address_nv (x, addr);
+ }
+ return x;
+}
+
/* Implement the TARGET_LEGITIMATE_COMBINED_INSN hook. */
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 0e7cf35..4feb18a 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -2512,9 +2512,15 @@
if (TARGET_POWERPC64 && TARGET_LDBRX)
{
if (MEM_P (src))
- emit_insn (gen_bswapdi2_load (dest, src));
+ {
+ src = rs6000_force_indexed_or_indirect_mem (src);
+ emit_insn (gen_bswapdi2_load (dest, src));
+ }
else if (MEM_P (dest))
- emit_insn (gen_bswapdi2_store (dest, src));
+ {
+ dest = rs6000_force_indexed_or_indirect_mem (dest);
+ emit_insn (gen_bswapdi2_store (dest, src));
+ }
else if (TARGET_P9_VECTOR)
emit_insn (gen_bswapdi2_xxbrd (dest, src));
else
@@ -2535,13 +2541,13 @@
;; Power7/cell has ldbrx/stdbrx, so use it directly
(define_insn "bswapdi2_load"
[(set (match_operand:DI 0 "gpc_reg_operand" "=r")
- (bswap:DI (match_operand:DI 1 "memory_operand" "Z")))]
+ (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "Z")))]
"TARGET_POWERPC64 && TARGET_LDBRX"
"ldbrx %0,%y1"
[(set_attr "type" "load")])
(define_insn "bswapdi2_store"
- [(set (match_operand:DI 0 "memory_operand" "=Z")
+ [(set (match_operand:DI 0 "indexed_or_indirect_operand" "=Z")
(bswap:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
"TARGET_POWERPC64 && TARGET_LDBRX"
"stdbrx %1,%y0"