Patchwork [committed] Fix PA ior expanders

login
register
mail settings
Submitter John David Anglin
Date March 27, 2011, 10:17 p.m.
Message ID <20110327221734.GA997@hiauly1.hia.nrc.ca>
Download mbox | patch
Permalink /patch/88526/
State New
Headers show

Comments

John David Anglin - March 27, 2011, 10:17 p.m.
The following patch fixes a thinko in the iordi3 expander -- the
expander didn't allow register operands.  I also changed the iorsi3
expander to use the new predicate.

Tested on hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu with no
regressions.  Committed to trunk.

Dave
Richard Henderson - March 28, 2011, 10:10 p.m.
On 03/27/2011 03:17 PM, John David Anglin wrote:
> +(define_predicate "reg_or_ior_operand"
> +  (match_code "subreg,reg,const_int")
> +{
> +  return (register_operand (op, mode)
> +	  || (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op))));
> +})
> +

Better written, IMO, as

  (ior (match_operand 0 "register_operand")
       (and (match_code "const_int")
	    (match_test "ior_mask_p (INTVAL (op))")))


r~
Richard Henderson - March 28, 2011, 10:13 p.m.
On 03/28/2011 03:10 PM, Richard Henderson wrote:
> On 03/27/2011 03:17 PM, John David Anglin wrote:
>> +(define_predicate "reg_or_ior_operand"
>> +  (match_code "subreg,reg,const_int")
>> +{
>> +  return (register_operand (op, mode)
>> +	  || (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op))));
>> +})
>> +
> 
> Better written, IMO, as...

(define_predicate "ior_operand"
  (and (match_code "const_int")
       (match_test "ior_mask_p (INTVAL (op))")))

(define_predicate "reg_or_ior_operand"
  (ior (match_operand 0 "register_operand")
       (match_operand 0 "ior_operand")))


You've already got an ior_operand, which has a redundant test for CONST_INT.
Actually, this is true of quite a few of the PA predicates...


r~

Patch

Index: config/pa/predicates.md
===================================================================
--- config/pa/predicates.md	(revision 171556)
+++ config/pa/predicates.md	(working copy)
@@ -409,6 +409,15 @@ 
 	  || (GET_CODE (op) == CONST_INT && and_mask_p (INTVAL (op))));
 })
 
+;; True iff OP can be used to compute (reg | OP).
+
+(define_predicate "reg_or_ior_operand"
+  (match_code "subreg,reg,const_int")
+{
+  return (register_operand (op, mode)
+	  || (GET_CODE (op) == CONST_INT && ior_mask_p (INTVAL (op))));
+})
+
 ;; True iff depi can be used to compute (reg | OP).
 
 (define_predicate "ior_operand"
Index: config/pa/pa.md
===================================================================
--- config/pa/pa.md	(revision 171556)
+++ config/pa/pa.md	(working copy)
@@ -5686,7 +5686,7 @@ 
 (define_expand "iordi3"
   [(set (match_operand:DI 0 "register_operand" "")
 	(ior:DI (match_operand:DI 1 "register_operand" "")
-		(match_operand:DI 2 "ior_operand" "")))]
+		(match_operand:DI 2 "reg_or_ior_operand" "")))]
   ""
   "
 {
@@ -5726,14 +5726,9 @@ 
 (define_expand "iorsi3"
   [(set (match_operand:SI 0 "register_operand" "")
 	(ior:SI (match_operand:SI 1 "register_operand" "")
-		(match_operand:SI 2 "arith32_operand" "")))]
+		(match_operand:SI 2 "reg_or_ior_operand" "")))]
   ""
-  "
-{
-  if (! (ior_operand (operands[2], SImode)
-         || register_operand (operands[2], SImode)))
-    operands[2] = force_reg (SImode, operands[2]);
-}")
+  "")
 
 (define_insn ""
   [(set (match_operand:SI 0 "register_operand" "=r,r")