This patch fixes an oversight in the tabort. pattern (only generated via the __builtin_tabort (cause) builtin), which currently allows using r0. The problem is that if r0 is used, the "cause" argument value passed in by the user will be ignored, since using r0 means the value zero and not the contents of r0 (similar to base registers in loads/stores, addi, etc.). This patch restricts the tabort. pattern to only use base registers.
This has passed bootstrapping and regtesting on trunk. Ok for mainline? I'd like to also backport this to the release branches. Is this ok for them once bootstrapping and regtesting are complete on them? Peter gcc/ * config/rs6000/htm.md (tabort.): Restrict the source operand to using a base register. gcc/testsuite/ * gcc.target/powerpc/htm-tabort-no-r0.c: New test. Index: gcc/config/rs6000/htm.md =================================================================== --- gcc/config/rs6000/htm.md (revision 226516) +++ gcc/config/rs6000/htm.md (working copy) @@ -48,7 +48,7 @@ (define_insn "tabort" [(set (match_operand:CC 1 "cc_reg_operand" "=x") - (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")] + (unspec_volatile:CC [(match_operand:SI 0 "base_reg_operand" "b")] UNSPECV_HTM_TABORT))] "TARGET_HTM" "tabort. %0" Index: gcc/testsuite/gcc.target/powerpc/htm-tabort-no-r0.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/htm-tabort-no-r0.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/htm-tabort-no-r0.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_htm_ok } */ +/* { dg-options "-O2 -mhtm -ffixed-r3 -ffixed-r4 -ffixed-r5 -ffixed-r6 -ffixed-r7 -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11 -ffixed-r12" } */ + +/* { dg-final { scan-assembler-not "tabort\\.\[ \t\]0" } } */ + +int +foo (void) +{ + return __builtin_tabort (10); +}