Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c (revision 133964) +++ gcc/config/avr/avr.c (working copy) @@ -1123,8 +1123,7 @@ default: if (CONSTANT_ADDRESS_P (addr) - && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr)) - || GET_CODE (addr) == LABEL_REF)) + && text_segment_operand (addr, VOIDmode)) { fprintf (file, "gs("); output_addr_const (file,addr); @@ -4477,8 +4476,7 @@ avr_assemble_integer (rtx x, unsigned int size, int aligned_p) { if (size == POINTER_SIZE / BITS_PER_UNIT && aligned_p - && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x)) - || GET_CODE (x) == LABEL_REF)) + && text_segment_operand (x, VOIDmode) ) { fputs ("\t.word\tgs(", asm_out_file); output_addr_const (asm_out_file, x); Index: gcc/config/avr/predicates.md =================================================================== --- gcc/config/avr/predicates.md (revision 133964) +++ gcc/config/avr/predicates.md (working copy) @@ -71,6 +71,27 @@ (define_predicate "symbol_ref_operand" (match_code "symbol_ref")) +;; Return true if OP is a text segment reference. +;; This is needed in the embedded medium/anywhere code model on V9. +(define_predicate "text_segment_operand" + (match_code "label_ref,symbol_ref,plus,const") +{ + switch (GET_CODE (op)) + { + case LABEL_REF : + return true; + case SYMBOL_REF : + return SYMBOL_REF_FUNCTION_P (op); + case PLUS : + /* Assume canonical format of symbol + constant. + Fall through. */ + case CONST : + return text_segment_operand (XEXP (op, 0), VOIDmode); + default : + gcc_unreachable (); + } +}) + ;; Return true if OP is a constant that contains only one 1 in its ;; binary representation. (define_predicate "single_one_operand"