[COMMITTED,MSP430] Fix postinc addressing mode being used for dst operand of CMP insns

Message ID 20191205113236.12752dac@jozef-kubuntu
State New
Headers show
Series
  • [COMMITTED,MSP430] Fix postinc addressing mode being used for dst operand of CMP insns
Related show

Commit Message

Jozef Lawrynowicz Dec. 5, 2019, 11:32 a.m.
MSP430 RTL patterns for conditional branch instructions allow the post
increment addressing mode to be used for the "dest" operand of CMP instructions
used in these patterns.

This is currently causing trunk to FTB for msp430-elf since these instructions
are being generated using an autoinc for the dest operand, and the assembler is
rejecting them:

> ldtoa.s:1104: Error: this addressing mode is not applicable for destination operand


The attached patch fixes this by using the "msp430_general_dst_nonv_operand"
predicate instead of the "nonimmediate_operand" predicate for the offending RTL
patterns.

Successfully regtested for msp430-elf on trunk and committed as obvious.

Comments

Jeff Law Dec. 5, 2019, 3:41 p.m. | #1
On 12/5/19 4:32 AM, Jozef Lawrynowicz wrote:
> MSP430 RTL patterns for conditional branch instructions allow the post

> increment addressing mode to be used for the "dest" operand of CMP instructions

> used in these patterns.

> 

> This is currently causing trunk to FTB for msp430-elf since these instructions

> are being generated using an autoinc for the dest operand, and the assembler is

> rejecting them:

> 

>> ldtoa.s:1104: Error: this addressing mode is not applicable for destination operand

> 

> The attached patch fixes this by using the "msp430_general_dst_nonv_operand"

> predicate instead of the "nonimmediate_operand" predicate for the offending RTL

> patterns.

> 

> Successfully regtested for msp430-elf on trunk and committed as obvious.

> 

Thanks.  I suspect that'll bring the msp430 back to "green" state in my
tester.  I'd been meaning to bisect that, but I'm fighting multiple
other higher priority issues right now.

jeff
Jozef Lawrynowicz Dec. 5, 2019, 5:44 p.m. | #2
On Thu, 5 Dec 2019 08:41:48 -0700
Jeff Law <law@redhat.com> wrote:

> On 12/5/19 4:32 AM, Jozef Lawrynowicz wrote:

> > MSP430 RTL patterns for conditional branch instructions allow the post

> > increment addressing mode to be used for the "dest" operand of CMP instructions

> > used in these patterns.

> > 

> > This is currently causing trunk to FTB for msp430-elf since these instructions

> > are being generated using an autoinc for the dest operand, and the assembler is

> > rejecting them:

> >   

> >> ldtoa.s:1104: Error: this addressing mode is not applicable for destination operand  

> > 

> > The attached patch fixes this by using the "msp430_general_dst_nonv_operand"

> > predicate instead of the "nonimmediate_operand" predicate for the offending RTL

> > patterns.

> > 

> > Successfully regtested for msp430-elf on trunk and committed as obvious.

> >   

> Thanks.  I suspect that'll bring the msp430 back to "green" state in my

> tester.  I'd been meaning to bisect that, but I'm fighting multiple

> other higher priority issues right now.


It looks like it was one of the below commits that exposed the bug, since my
tester showed it occurred between r278653 and r278883 (although I didn't
actually bisect to it).

commit f8c3d03646f08238fe261286470391bb88918660
Author: bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Nov 27 03:31:24 2019 +0000

    Allow autoinc in jumps, but only when using reload.
    
            * auto-inc-dec.c (merge_in_block): Allow autoinc in jumps unless
            LRA is enabled.
            * combine.c (can_combine_p): Disallow autoinc in jumps unless LRA is
            disabled.
    
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@278756
    138bc75d-0d04-0410-961f-82ee72b054a4

commit 713a306a87bce2c8ed3ab3d4d8b0ecbeaf17f91a
Author: bernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Nov 24 13:20:55 2019 +0000

    Allow combiner to create autoinc in jump insns.
    
            * combine.c (can_combine_p): Allow autoinc in jumps.
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@278656
    138bc75d-0d04-0410-961f-82ee72b054a4

> 

> jeff

>

Patch

From 914d2119720344505a6ad2adb51d55fc80ed630c Mon Sep 17 00:00:00 2001
From: jozefl <jozefl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 5 Dec 2019 10:56:02 +0000
Subject: [PATCH] MSP430: Fix postinc addressing mode being used for dst op of
 CMP insns

2019-12-05  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* config/msp430/msp430.md (cbranch<mode>4): Use
	msp430_general_dst_nonv_operand instead of nonimmediate_operand for
	dest operand of CMP instruction.
	(cbranchpsi4_real): Likewise.
	(cbranchqi4_real): Likewise.
	(cbranchhi4_real): Likewise.
	(cbranchpsi4_reversed): Likewise.
	(cbranchqi4_reversed): Likewise.
	(cbranchhi4_reversed): Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@278994 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog               | 12 ++++++++++++
 gcc/config/msp430/msp430.md | 14 +++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f17fc102a07..fca25729778 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@ 
+2019-12-05  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+	* config/msp430/msp430.md (cbranch<mode>4): Use
+	msp430_general_dst_nonv_operand instead of nonimmediate_operand for
+	dest operand of CMP instruction.
+	(cbranchpsi4_real): Likewise.
+	(cbranchqi4_real): Likewise.
+	(cbranchhi4_real): Likewise.
+	(cbranchpsi4_reversed): Likewise.
+	(cbranchqi4_reversed): Likewise.
+	(cbranchhi4_reversed): Likewise.
+
 2019-12-05  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/92803
diff --git a/gcc/config/msp430/msp430.md b/gcc/config/msp430/msp430.md
index c3d85071a58..48515b9c26b 100644
--- a/gcc/config/msp430/msp430.md
+++ b/gcc/config/msp430/msp430.md
@@ -1247,7 +1247,7 @@ 
 (define_expand "cbranch<mode>4"
   [(parallel [(set (pc) (if_then_else
 			 (match_operator 0 ""
-					 [(match_operand:QHI 1 "nonimmediate_operand")
+					 [(match_operand:QHI 1 "msp430_general_dst_nonv_operand")
 					  (match_operand:QHI 2 "general_operand")])
 			 (label_ref (match_operand 3 "" ""))
 			 (pc)))
@@ -1260,7 +1260,7 @@ 
 (define_insn "cbranchpsi4_real"
   [(set (pc) (if_then_else
 	      (match_operator                     0 "msp430_cmp_operator"
-			      [(match_operand:PSI 1 "nonimmediate_operand" "r,rYs,rm")
+			      [(match_operand:PSI 1 "msp430_general_dst_nonv_operand" "r,rYs,rm")
 			       (match_operand:PSI 2 "general_operand"      "rLs,rYsi,rmi")])
               (label_ref (match_operand           3 "" ""))
 	      (pc)))
@@ -1276,7 +1276,7 @@ 
 (define_insn "cbranchqi4_real"
   [(set (pc) (if_then_else
 	      (match_operator                    0 "msp430_cmp_operator"
-			      [(match_operand:QI 1 "nonimmediate_operand" "rYsYx,rm")
+			      [(match_operand:QI 1 "msp430_general_dst_nonv_operand" "rYsYx,rm")
 			       (match_operand:QI 2 "general_operand"      "rYsYxi,rmi")])
               (label_ref (match_operand          3 "" ""))
 	      (pc)))
@@ -1291,7 +1291,7 @@ 
 (define_insn "cbranchhi4_real"
   [(set (pc) (if_then_else
 	      (match_operator                    0 "msp430_cmp_operator"
-			      [(match_operand:HI 1 "nonimmediate_operand" "rYsYx,rm")
+			      [(match_operand:HI 1 "msp430_general_dst_nonv_operand" "rYsYx,rm")
 			       (match_operand:HI 2 "general_operand"      "rYsYxi,rmi")])
               (label_ref (match_operand          3 "" ""))
 	      (pc)))
@@ -1330,7 +1330,7 @@ 
   [(set (pc) (if_then_else
 	      (match_operator                     0 "msp430_reversible_cmp_operator"
 			      [(match_operand:PSI 1 "general_operand" "rLs,rYsi,rmi")
-			       (match_operand:PSI 2 "general_operand" "r,rYs,rm")])
+			       (match_operand:PSI 2 "msp430_general_dst_nonv_operand" "r,rYs,rm")])
               (label_ref (match_operand           3 "" ""))
 	      (pc)))
    (clobber (reg:BI CARRY))
@@ -1346,7 +1346,7 @@ 
   [(set (pc) (if_then_else
 	      (match_operator                    0 "msp430_reversible_cmp_operator"
 			      [(match_operand:QI 1 "general_operand" "rYsYxi,rmi")
-			       (match_operand:QI 2 "general_operand" "rYsYx,rm")])
+			       (match_operand:QI 2 "msp430_general_dst_nonv_operand" "rYsYx,rm")])
               (label_ref (match_operand          3 "" ""))
 	      (pc)))
    (clobber (reg:BI CARRY))
@@ -1361,7 +1361,7 @@ 
   [(set (pc) (if_then_else
 	      (match_operator                    0 "msp430_reversible_cmp_operator"
 			      [(match_operand:HI 1 "general_operand" "rYsYxi,rmi")
-			       (match_operand:HI 2 "general_operand" "rYsYx,rm")])
+			       (match_operand:HI 2 "msp430_general_dst_nonv_operand" "rYsYx,rm")])
               (label_ref (match_operand          3 "" ""))
 	      (pc)))
    (clobber (reg:BI CARRY))
-- 
2.17.1