PR66178 has some testcases where we construct expressions involving additions and subtractions of label addresses, and we crash when trying to expand these. There are two different issues here, shown by various testcases in the PR: * expand_expr_real_2 can drop EXPAND_INITIALIZER and then go into a path where it wants to gen_reg_rtx. * simplify-rtx can turn subtractions into NOT operations in some cases. That seems inadvisable for symbolic expressions. The following was bootstrapped and tested on x86_64-linux. Ok for all branches? 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.