]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390: Increase costs for load on condition and change movqicc expander.
authorRobin Dapp <rdapp@linux.ibm.com>
Tue, 8 Feb 2022 13:56:29 +0000 (14:56 +0100)
committerRobin Dapp <rdapp@linux.ibm.com>
Tue, 8 Feb 2022 14:28:53 +0000 (15:28 +0100)
This patch changes the costs for a load on condition from 5 to 6 in
order to ensure that we only if-convert two and not three or more SETS like

if (cond)
{
  a = b;
  c = d;
  e = f;
}

In the movqicc expander we emit a paradoxical subreg directly that
combine would otherwise try to create by using a non-optimal sequence
(which would be too expensive).

Also, fix two oversights in ifcvt testcases.

gcc/ChangeLog:

* config/s390/s390.cc (s390_rtx_costs): Increase costs for load
on condition.
* config/s390/s390.md: Use paradoxical subreg.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ifcvt-two-insns-int.c: Fix array size.
* gcc.target/s390/ifcvt-two-insns-long.c: Dito.

gcc/config/s390/s390.cc
gcc/config/s390/s390.md
gcc/testsuite/gcc.target/s390/ifcvt-two-insns-int.c
gcc/testsuite/gcc.target/s390/ifcvt-two-insns-long.c

index c6cfe41ad7b50dd33c6e9d4d6f1c9cf170573789..d2af6d8813d26d7eb5614387eaa628c7b61eb1e4 100644 (file)
@@ -3636,7 +3636,7 @@ s390_rtx_costs (rtx x, machine_mode mode, int outer_code,
 
        /* It is going to be a load/store on condition.  Make it
           slightly more expensive than a normal load.  */
-       *total = COSTS_N_INSNS (1) + 1;
+       *total = COSTS_N_INSNS (1) + 2;
 
        rtx dst = SET_DEST (x);
        rtx then = XEXP (SET_SRC (x), 1);
index e3ccbac58c090c41a355d3c050f923a2ca3f026f..5eee8e86b423bc3cb778087bed8ecdda6d2479c3 100644 (file)
   if (!CONSTANT_P (els))
     els = simplify_gen_subreg (E_SImode, els, <MODE>mode, 0);
 
-  rtx tmp_target = gen_reg_rtx (E_SImode);
+  rtx tmp_target = simplify_gen_subreg (E_SImode, operands[0], <MODE>mode, 0);
+
   emit_insn (gen_movsicc (tmp_target, operands[1], then, els));
-  emit_move_insn (operands[0], gen_lowpart (<MODE>mode, tmp_target));
   DONE;
 })
 
index 1ced7107de0c93242f5f4f7d1cfdaeb72be8dfaf..031cc433f567c6b82a2985c6fdfdbe4242c61608 100644 (file)
@@ -5,7 +5,6 @@
 
 /* { dg-final { scan-assembler "lochinle\t%r.?,1" } } */
 /* { dg-final { scan-assembler "locrnle\t.*" } } */
-#include <stdbool.h>
 #include <limits.h>
 #include <stdio.h>
 #include <assert.h>
@@ -33,7 +32,7 @@ int main()
 {
   int a[] = {2, 1, -13, INT_MAX, INT_MIN, 0};
 
-  int res = foo (a, sizeof (a));
+  int res = foo (a, sizeof (a) / sizeof (a[0]));
 
   assert (res == (INT_MIN + 1));
 }
index 5a1173fc6efa9cbadb4dbb569076e33e05188c85..cd04d2ad33ebb83429684f5c289535eb4c74a342 100644 (file)
@@ -5,7 +5,6 @@
 
 /* { dg-final { scan-assembler "locghinle\t%r.?,1" } } */
 /* { dg-final { scan-assembler "locgrnle\t.*" } } */
-#include <stdbool.h>
 #include <limits.h>
 #include <stdio.h>
 #include <assert.h>
@@ -33,7 +32,7 @@ int main()
 {
   long a[] = {2, 1, -13, LONG_MAX, LONG_MIN, 0};
 
-  long res = foo (a, sizeof (a));
+  long res = foo (a, sizeof (a) / sizeof (a[0]));
 
   assert (res == (LONG_MIN + 1));
 }