diff mbox

rs6000: Do not allow GPR0 for addic. if it is split

Message ID a8c9847a4476b2271560398107138ca36bc9f336.1418641560.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool Dec. 15, 2014, 11:11 a.m. UTC
If an addic. is split to addi+cmp (because RA didn't give it CR0), it will
do the wrong thing if the input reg is GPR0 ("addi X,0,N" is "li X,N").
So don't allow such an input.

Spotted visually while investigating PR64268.  Tested etc.; okay for
mainline?


Segher


2014-12-15  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* gcc/config/rs6000/rs6000.md (*add>mode>3_imm_dot,
	*add<mode>3_imm_dot2): Change the constraint for the second
	alternative for operand 1 from "r" to "b".

---
 gcc/config/rs6000/rs6000.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Edelsohn Dec. 15, 2014, 2:19 p.m. UTC | #1
On Mon, Dec 15, 2014 at 6:11 AM, Segher Boessenkool
<segher@kernel.crashing.org> wrote:
> If an addic. is split to addi+cmp (because RA didn't give it CR0), it will
> do the wrong thing if the input reg is GPR0 ("addi X,0,N" is "li X,N").
> So don't allow such an input.
>
> Spotted visually while investigating PR64268.  Tested etc.; okay for
> mainline?
>
>
> Segher
>
>
> 2014-12-15  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
>         * gcc/config/rs6000/rs6000.md (*add>mode>3_imm_dot,
>         *add<mode>3_imm_dot2): Change the constraint for the second
>         alternative for operand 1 from "r" to "b".

Okay.

thanks, David
diff mbox

Patch

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index bb9ab0f..36e6182 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -1569,7 +1569,7 @@  (define_insn_and_split "*add<mode>3_dot2"
 
 (define_insn_and_split "*add<mode>3_imm_dot"
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
-	(compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
+	(compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b")
 			      (match_operand:GPR 2 "short_cint_operand" "I,I"))
 		    (const_int 0)))
    (clobber (match_scratch:GPR 0 "=r,r"))
@@ -1592,7 +1592,7 @@  (define_insn_and_split "*add<mode>3_imm_dot"
 
 (define_insn_and_split "*add<mode>3_imm_dot2"
   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
-	(compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
+	(compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b")
 			      (match_operand:GPR 2 "short_cint_operand" "I,I"))
 		    (const_int 0)))
    (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")