aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRobert Suchanek <robert.suchanek@imgtec.com>2015-01-16 12:31:01 +0000
committerMatthew Fortune <mpf@gcc.gnu.org>2015-01-16 12:31:01 +0000
commitece4d1aca6232a26f44e8fa5435f429f9bcde6db (patch)
tree24118a1005abdf80d65240f679378bcda19c1867 /gcc
parent4baa25d3fbee279835c1e7e53ef1460d41291b28 (diff)
downloadgcc-ece4d1aca6232a26f44e8fa5435f429f9bcde6db.zip
gcc-ece4d1aca6232a26f44e8fa5435f429f9bcde6db.tar.gz
gcc-ece4d1aca6232a26f44e8fa5435f429f9bcde6db.tar.bz2
Account for high/lo_sum simplification with displacements
gcc/ * simplify-rtx.c (simplify_replace_fn_rtx): Simplify (lo_sum (high x) y) to y if x and y have the same base. gcc/testsuite/ * gcc.c-torture/compile/20150108.c: New test. From-SVN: r219729
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/simplify-rtx.c12
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20150108.c22
4 files changed, 40 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 621223d..b9f45a0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-16 Robert Suchanek <robert.suchanek@imgtec.com>
+
+ * simplify-rtx.c (simplify_replace_fn_rtx): Simplify (lo_sum
+ (high x) y) to y if x and y have the same base.
+
2015-01-16 James Greenhalgh <james.greenhalgh@arm.com>
* config/arm/cortex-a57.md: New.
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 4ee63d2..d26267d 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -539,9 +539,15 @@ simplify_replace_fn_rtx (rtx x, const_rtx old_rtx,
op0 = simplify_replace_fn_rtx (XEXP (x, 0), old_rtx, fn, data);
op1 = simplify_replace_fn_rtx (XEXP (x, 1), old_rtx, fn, data);
- /* (lo_sum (high x) x) -> x */
- if (GET_CODE (op0) == HIGH && rtx_equal_p (XEXP (op0, 0), op1))
- return op1;
+ /* (lo_sum (high x) y) -> y where x and y have the same base. */
+ if (GET_CODE (op0) == HIGH)
+ {
+ rtx base0, base1, offset0, offset1;
+ split_const (XEXP (op0, 0), &base0, &offset0);
+ split_const (op1, &base1, &offset1);
+ if (rtx_equal_p (base0, base1))
+ return op1;
+ }
if (op0 == XEXP (x, 0) && op1 == XEXP (x, 1))
return x;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ac7c7f2..ffc6794 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-16 Robert Suchanek <robert.suchanek@imgtec.com>
+
+ * gcc.c-torture/compile/20150108.c: New test.
+
2015-01-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc.target/visium: New directory.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20150108.c b/gcc/testsuite/gcc.c-torture/compile/20150108.c
new file mode 100644
index 0000000..62ba372
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20150108.c
@@ -0,0 +1,22 @@
+long long a[10];
+long long b, c, d, k, m, n, o, p, q, r, s, t, u, v, w;
+int e, f, g, h, i, j, l, x;
+
+int fn1 () {
+ for (; x; x++)
+ if (x & 1)
+ s = h | g;
+ else
+ s = f | e;
+ l = ~0;
+ m = 1 | k;
+ n = i;
+ o = j;
+ p = f | e;
+ q = h | g;
+ w = d | c | a[1];
+ t = c;
+ v = b | c;
+ u = v;
+ r = b | a[4];
+ return e;