From 86efb5cd550babd6bf69ead21cc73f0012c55a97 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Mar 2013 07:04:14 +0100 Subject: re PR rtl-optimization/56494 (ICE in simplify_truncation, at simplify-rtx.c:619) PR rtl-optimization/56494 * simplify-rtx.c (simplify_truncation): If C is narrower than A, optimize (truncate:A (subreg:B (truncate:C X) 0)) into (subreg:A (truncate:C X) 0) instead of (truncate:A X). * gcc.dg/pr56494.c: New test. From-SVN: r196451 --- gcc/simplify-rtx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc/simplify-rtx.c') diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 3f04b8b..43700cf 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -757,8 +757,17 @@ simplify_truncation (enum machine_mode mode, rtx op, && SCALAR_INT_MODE_P (GET_MODE (SUBREG_REG (op))) && GET_CODE (SUBREG_REG (op)) == TRUNCATE && subreg_lowpart_p (op)) - return simplify_gen_unary (TRUNCATE, mode, XEXP (SUBREG_REG (op), 0), - GET_MODE (XEXP (SUBREG_REG (op), 0))); + { + rtx inner = XEXP (SUBREG_REG (op), 0); + if (GET_MODE_PRECISION (mode) + <= GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op)))) + return simplify_gen_unary (TRUNCATE, mode, inner, GET_MODE (inner)); + else + /* If subreg above is paradoxical and C is narrower + than A, return (subreg:A (truncate:C X) 0). */ + return simplify_gen_subreg (mode, SUBREG_REG (op), + GET_MODE (SUBREG_REG (op)), 0); + } /* (truncate:A (truncate:B X)) is (truncate:A X). */ if (GET_CODE (op) == TRUNCATE) -- cgit v1.1