aboutsummaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorBernd Schmidt <bernds@redhat.com>2016-01-21 18:10:03 +0000
committerBernd Schmidt <bernds@gcc.gnu.org>2016-01-21 18:10:03 +0000
commit9776e6920dec9aa23adbdd7f0c264804c7fe6fdf (patch)
tree66b303926820db0d7a4362846c12773014ef8d1e /gcc/simplify-rtx.c
parenta71c0334f783c44a146b5003a09847571e71f366 (diff)
downloadgcc-9776e6920dec9aa23adbdd7f0c264804c7fe6fdf.zip
gcc-9776e6920dec9aa23adbdd7f0c264804c7fe6fdf.tar.gz
gcc-9776e6920dec9aa23adbdd7f0c264804c7fe6fdf.tar.bz2
Fix PR66178, ICE due to misexpansion of constant expressions involving labels.
PR middle-end/66178 * expr.c (expand_expr_real_2) [PLUS_EXPR, MINUS_EXPR]: Don't drop EXPAND_INITIALIZER. * rtl.h (contains_symbolic_reference_p): Declare. * rtlanal.c (contains_symbolic_reference_p): New function. * simplify-rtx.c (simplify_binary_operation_1): Don't turn a subtraction into a NOT if symbolic constants are involved. testsuite/ PR middle-end/66178 gcc.dg/torture/pr66178.c: New test. From-SVN: r232689
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 1e6e46d..39049e5 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -2277,8 +2277,11 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode,
if (!HONOR_SIGNED_ZEROS (mode) && trueop0 == CONST0_RTX (mode))
return simplify_gen_unary (NEG, mode, op1, mode);
- /* (-1 - a) is ~a. */
- if (trueop0 == constm1_rtx)
+ /* (-1 - a) is ~a, unless the expression avoids symbolic constants,
+ in which case not retaining additions and subtractions could
+ cause invalid assembly to be produced. */
+ if (trueop0 == constm1_rtx
+ && !contains_symbolic_reference_p (op1))
return simplify_gen_unary (NOT, mode, op1, mode);
/* Subtracting 0 has no effect unless the mode has signed zeros