aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-09-10 09:10:34 +0930
committerAlan Modra <amodra@gcc.gnu.org>2013-09-10 09:10:34 +0930
commitb6872a13898d89eb0d52a2d306ae754d677b7819 (patch)
treeae6cc003997d65562a22922705a5239896f8ec90 /gcc
parent904e9dbbabdd2184894afbf63edcf6b6a4544055 (diff)
downloadgcc-b6872a13898d89eb0d52a2d306ae754d677b7819.zip
gcc-b6872a13898d89eb0d52a2d306ae754d677b7819.tar.gz
gcc-b6872a13898d89eb0d52a2d306ae754d677b7819.tar.bz2
predicates.md (add_cint_operand): New.
gcc/ * config/rs6000/predicates.md (add_cint_operand): New. (reg_or_add_cint_operand, small_toc_ref): Use add_cint_operand. * config/rs6000/rs6000.md (largetoc_high_plus): Restrict offset using add_cint_operand. (largetoc_high_plus_aix): Likewise. gcc/testsuite/ * gcc.target/powerpc/medium_offset.c: New. From-SVN: r202417
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/rs6000/predicates.md12
-rw-r--r--gcc/config/rs6000/rs6000.md4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/powerpc/medium_offset.c12
5 files changed, 35 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dd9a3e0..42d1dc7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2013-09-10 Alan Modra <amodra@gmail.com>
+
+ * config/rs6000/predicates.md (add_cint_operand): New.
+ (reg_or_add_cint_operand, small_toc_ref): Use add_cint_operand.
+ * config/rs6000/rs6000.md (largetoc_high_plus): Restrict offset
+ using add_cint_operand.
+ (largetoc_high_plus_aix): Likewise.
+
2013-09-09 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/58364
diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 7338e76..b5bff04 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -376,12 +376,18 @@
(ior (match_code "const_int")
(match_operand 0 "gpc_reg_operand")))
+;; Return 1 if op is a constant integer valid for addition with addis, addi.
+(define_predicate "add_cint_operand"
+ (and (match_code "const_int")
+ (match_test "(unsigned HOST_WIDE_INT)
+ (INTVAL (op) + (mode == SImode ? 0x80000000 : 0x80008000))
+ < (unsigned HOST_WIDE_INT) 0x100000000ll")))
+
;; Return 1 if op is a constant integer valid for addition
;; or non-special register.
(define_predicate "reg_or_add_cint_operand"
(if_then_else (match_code "const_int")
- (match_test "(unsigned HOST_WIDE_INT) (INTVAL (op) + 0x80008000)
- < (unsigned HOST_WIDE_INT) 0x100000000ll")
+ (match_operand 0 "add_cint_operand")
(match_operand 0 "gpc_reg_operand")))
;; Return 1 if op is a constant integer valid for subtraction
@@ -1697,7 +1703,7 @@
(define_predicate "small_toc_ref"
(match_code "unspec,plus")
{
- if (GET_CODE (op) == PLUS && CONST_INT_P (XEXP (op, 1)))
+ if (GET_CODE (op) == PLUS && add_cint_operand (XEXP (op, 1), mode))
op = XEXP (op, 0);
return GET_CODE (op) == UNSPEC && XINT (op, 1) == UNSPEC_TOCREL;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3880f91..0757d4d 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -12207,7 +12207,7 @@
(unspec [(match_operand:DI 1 "" "")
(match_operand:DI 2 "gpc_reg_operand" "b")]
UNSPEC_TOCREL)
- (match_operand 3 "const_int_operand" "n"))))]
+ (match_operand:DI 3 "add_cint_operand" "n"))))]
"TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
"addis %0,%2,%1+%3@toc@ha")
@@ -12218,7 +12218,7 @@
(unspec [(match_operand:P 1 "" "")
(match_operand:P 2 "gpc_reg_operand" "b")]
UNSPEC_TOCREL)
- (match_operand 3 "const_int_operand" "n"))))]
+ (match_operand:P 3 "add_cint_operand" "n"))))]
"TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
"addis %0,%1+%3@u(%2)")
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7da1444..61d1469 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-09-10 Alan Modra <amodra@gmail.com>
+
+ * gcc.target/powerpc/medium_offset.c: New.
+
2013-09-09 Jakub Jelinek <jakub@redhat.com>
PR c++/58325
diff --git a/gcc/testsuite/gcc.target/powerpc/medium_offset.c b/gcc/testsuite/gcc.target/powerpc/medium_offset.c
new file mode 100644
index 0000000..f29eba0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/medium_offset.c
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler-not "\\+4611686018427387904" } } */
+
+static int x;
+
+unsigned long
+foo (void)
+{
+ return ((unsigned long) &x) - 0xc000000000000000;
+}