Re: [PATCH] S/390: Allow immediates in loc expander

2018-10-26 Thread Andreas Krebbel
On 10/26/18 5:31 PM, Robin Dapp wrote:
> Hi,
> 
> this is v2 of the patch.  The Z13 check has been moved from the
> predicate to the expander.  In addition, it changes a test case to
> always run with -march=zEC12 because from z13 on the load immediate on
> condition will prevent loop hoisting that the test requires.
> 
> Regards
>  Robin
> 
> --
> 
> gcc/ChangeLog:
> 
> 2018-10-26  Robin Dapp  
> 
>   * config/s390/predicates.md: Fix typo.
>   * config/s390/s390.md: Allow immediates for load on condition.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-10-26  Robin Dapp  
> 
>   * gcc.dg/loop-8.c: On s390, always run the test with -march=zEC12.
> 

Ok. Thanks!

Andreas



Re: [PATCH] S/390: Allow immediates in loc expander

2018-10-26 Thread Robin Dapp
Hi,

this is v2 of the patch.  The Z13 check has been moved from the
predicate to the expander.  In addition, it changes a test case to
always run with -march=zEC12 because from z13 on the load immediate on
condition will prevent loop hoisting that the test requires.

Regards
 Robin

--

gcc/ChangeLog:

2018-10-26  Robin Dapp  

* config/s390/predicates.md: Fix typo.
* config/s390/s390.md: Allow immediates for load on condition.

gcc/testsuite/ChangeLog:

2018-10-26  Robin Dapp  

* gcc.dg/loop-8.c: On s390, always run the test with -march=zEC12.
diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index 98a824e77b7..97f717c558d 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -212,7 +212,7 @@
 (INTVAL (op), false, GET_MODE_BITSIZE (mode), NULL, NULL);
 })
 
-;; Return true if OP is ligitimate for any LOC instruction.
+;; Return true if OP is legitimate for any LOC instruction.
 
 (define_predicate "loc_operand"
   (ior (match_operand 0 "nonimmediate_operand")
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 3bd18acb456..ba1fa0c6ff3 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -6582,10 +6582,16 @@
 (define_expand "movcc"
   [(set (match_operand:GPR 0 "nonimmediate_operand" "")
 	(if_then_else:GPR (match_operand 1 "comparison_operator" "")
-			  (match_operand:GPR 2 "nonimmediate_operand" "")
-			  (match_operand:GPR 3 "nonimmediate_operand" "")))]
+			  (match_operand:GPR 2 "loc_operand" "")
+			  (match_operand:GPR 3 "loc_operand" "")))]
   "TARGET_Z196"
 {
+  if (!TARGET_Z13 && CONSTANT_P (operands[2]))
+operands[2] = force_reg (mode, operands[2]);
+
+  if (!TARGET_Z13 && CONSTANT_P (operands[3]))
+operands[3] = force_reg (mode, operands[3]);
+
   /* Emit the comparison insn in case we do not already have a comparison result.  */
   if (!s390_comparison (operands[1], VOIDmode))
 operands[1] = s390_emit_compare (GET_CODE (operands[1]),
diff --git a/gcc/testsuite/gcc.dg/loop-8.c b/gcc/testsuite/gcc.dg/loop-8.c
index 842c0e773b2..1eefccc1a3b 100644
--- a/gcc/testsuite/gcc.dg/loop-8.c
+++ b/gcc/testsuite/gcc.dg/loop-8.c
@@ -1,6 +1,10 @@
 /* { dg-do compile } */
 /* { dg-options "-O1 -fdump-rtl-loop2_invariant" } */
 /* { dg-skip-if "unexpected IV" { "hppa*-*-* mips*-*-* visium-*-* powerpc*-*-* riscv*-*-*" } } */
+/* Load immediate on condition is available from z13 on and prevents moving
+   the load out of the loop, so always run this test with -march=zEC12 that
+   does not have load immediate on condition.  */
+/* { dg-additional-options "-march=zEC12" { target { s390*-*-* } } } */
 
 void
 f (int *a, int *b)


[PATCH] S/390: Allow immediates in loc expander

2018-10-17 Thread Robin Dapp
Hi,

this allows immediates in the load-on-condition expander on z13 or later.

Regtested on z14.

Regards
 Robin

--

gcc/ChangeLog:

2018-10-17  Robin Dapp  

* config/s390/predicates.md:
Allow immediate operand in loc_operand for z13.
* config/s390/s390.md: Use loc_operand instead of nonimmediate_operand.
diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index 98a824e77b7..b4e7724c265 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -216,8 +216,9 @@
 
 (define_predicate "loc_operand"
   (ior (match_operand 0 "nonimmediate_operand")
-  (and (match_code "const_int")
-	   (match_test "INTVAL (op) <= 32767 && INTVAL (op) >= -32768"
+  (and (match_test "TARGET_Z13")
+   (and (match_code "const_int")
+	(match_test "INTVAL (op) <= 32767 && INTVAL (op) >= -32768")
 
 (define_predicate "reload_const_wide_int_operand"
   (and (match_code "const_wide_int")
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 3bd18acb456..70a619f06f5 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -6583,7 +6583,7 @@
   [(set (match_operand:GPR 0 "nonimmediate_operand" "")
 	(if_then_else:GPR (match_operand 1 "comparison_operator" "")
 			  (match_operand:GPR 2 "nonimmediate_operand" "")
-			  (match_operand:GPR 3 "nonimmediate_operand" "")))]
+			  (match_operand:GPR 3 "loc_operand" "")))]
   "TARGET_Z196"
 {
   /* Emit the comparison insn in case we do not already have a comparison result.  */