A lot of old user code clobbers the carry bit without telling the compiler about it. This used to just work, because the compiler never used the bit outside of a single RTL instruction. But that will change. Let's clobber the carry bit in every asm; this isn't very expensive.
2014-12-08 Segher Boessenkool <seg...@kernel.crashing.org> gcc/ PR target/64180 * config/rs6000/rs6000.c (TARGET_MD_ASM_CLOBBERS): Define. (rs6000_md_asm_clobbers): New function. --- gcc/config/rs6000/rs6000.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index cdb9de9..e58fc81 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1556,6 +1556,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP #define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rs6000_loop_align_max_skip +#undef TARGET_MD_ASM_CLOBBERS +#define TARGET_MD_ASM_CLOBBERS rs6000_md_asm_clobbers + #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE rs6000_option_override @@ -3146,6 +3149,19 @@ rs6000_builtin_mask_calculate (void) | ((TARGET_LONG_DOUBLE_128) ? RS6000_BTM_LDBL128 : 0)); } +/* Implement TARGET_MD_ASM_CLOBBERS. All asm statements are considered + to clobber the XER[CA] bit because clobbering that bit without telling + the compiler worked just fine with versions of GCC before GCC 5, and + breaking a lot of older code in ways that are hard to track down is + not such a great idea. */ + +static tree +rs6000_md_asm_clobbers (tree, tree, tree clobbers) +{ + tree s = build_string (strlen (reg_names[CA_REGNO]), reg_names[CA_REGNO]); + return tree_cons (NULL_TREE, s, clobbers); +} + /* Override command line options. Mostly we process the processor type and sometimes adjust other TARGET_ options. */ -- 1.8.1.4