Hi Steven/Vladimir, > It's hard to say what the correct fix should be, but it sounds like > the address you get after the substitutions should be simplified > (folded).
Coming back to the original testcase and re-analyzing the problem, it appears that there is, indeed, a missing case for simplification of LO_SUM/HIGH pair. The patch attached resolves the issue. Although the testcase is not reproducible on the trunk, I think it is still worth to include it in case the ICE reoccurred. The patch has been bootstrapped and regtested on x86_64-unknown-linux-gnu target and similarly tested against SVN revision r212763 where it can be reproduced. Regards, Robert 2015-01-08 Robert Suchanek <robert.sucha...@imgtec.com> gcc/ * simplify-rtx.c (simplify_replace_fn_rtx): Simplify (lo_sum (high x) (const (plus x offset))) to (const (plus x offset)). gcc/testsuite/ * gcc.target/mips/20150108.c: New test. --- gcc/simplify-rtx.c | 6 ++++++ gcc/testsuite/gcc.target/mips/20150108.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.target/mips/20150108.c diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 04af01e..7621316 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -503,6 +503,12 @@ simplify_replace_fn_rtx (rtx x, const_rtx old_rtx, if (GET_CODE (op0) == HIGH && rtx_equal_p (XEXP (op0, 0), op1)) return op1; + /* (lo_sum (high x) (const (plus x ofs))) -> (const (plus x ofs)) */ + if (GET_CODE (op0) == HIGH && GET_CODE (op1) == CONST + && GET_CODE(XEXP (op1, 0)) == PLUS + && rtx_equal_p (XEXP (XEXP (op1, 0), 0), XEXP (op0, 0))) + return op1; + if (op0 == XEXP (x, 0) && op1 == XEXP (x, 1)) return x; return gen_rtx_LO_SUM (mode, op0, op1); diff --git a/gcc/testsuite/gcc.target/mips/20150108.c b/gcc/testsuite/gcc.target/mips/20150108.c new file mode 100644 index 0000000..f18dbe7 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/20150108.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-mips32r2" } */ + +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; + +NOMIPS16 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]; +} -- 1.7.9.5