gcc/0191-Revert-feature-mull64.patch
2025-01-15 14:11:04 +08:00

2836 lines
99 KiB
Diff

From e8e3963f5c7c0bf4741a734ecae6293401332ab8 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:57:43 +0800
Subject: [PATCH 01/18] Revert "[phiopt][testsuite] Add -ftree-fold-phiopt
option to 5 test cases."
This reverts commit 1f4d422fd8008f0af015df53f496c6dce3534b26.
---
gcc/testsuite/g++.dg/opt/pr99305.C | 2 +-
gcc/testsuite/g++.dg/tree-ssa/mull64.C | 2 +-
gcc/testsuite/gcc.dg/pr107190.c | 2 +-
gcc/testsuite/gcc.dg/pr45416.c | 2 +-
gcc/testsuite/gcc.target/i386/pr65871-3.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gcc/testsuite/g++.dg/opt/pr99305.C b/gcc/testsuite/g++.dg/opt/pr99305.C
index 06295116f..6fcdef391 100644
--- a/gcc/testsuite/g++.dg/opt/pr99305.C
+++ b/gcc/testsuite/g++.dg/opt/pr99305.C
@@ -1,6 +1,6 @@
// PR tree-optimization/99305
// { dg-do compile }
-// { dg-options "-O3 -ftree-fold-phiopt -fno-ipa-icf -fdump-tree-optimized" }
+// { dg-options "-O3 -fno-ipa-icf -fdump-tree-optimized" }
// { dg-final { scan-tree-dump-times " = \\\(unsigned char\\\) c_\[0-9]*\\\(D\\\);" 3 "optimized" { target { ! unsigned_char } } } }
// { dg-final { scan-tree-dump-times " = \[^\n\r]* \\+ \[0-9]*;" 3 "optimized" } }
// { dg-final { scan-tree-dump-times " = \[^\n\r]* <= 9;" 3 "optimized" } }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/mull64.C b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
index ec359f2ba..cad891e62 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/mull64.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -fmerge-mull -Wno-psabi -fdump-tree-forwprop1-details -fdump-tree-forwprop4-details" } */
+/* { dg-options "-O2 -fmerge-mull -Wno-psabi -fdump-tree-forwprop1-details -fdump-tree-forwprop4-details" } */
# define BN_BITS4 32
# define BN_MASK2 (0xffffffffffffffffL)
diff --git a/gcc/testsuite/gcc.dg/pr107190.c b/gcc/testsuite/gcc.dg/pr107190.c
index d4e5fa0d0..d1e72e5df 100644
--- a/gcc/testsuite/gcc.dg/pr107190.c
+++ b/gcc/testsuite/gcc.dg/pr107190.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -fmerge-mull -fexpensive-optimizations -fdump-tree-phiopt2-details" } */
+/* { dg-options "-O2 -fmerge-mull -fexpensive-optimizations -fdump-tree-phiopt2-details" } */
# define BN_BITS4 32
# define BN_MASK2 (0xffffffffffffffffL)
diff --git a/gcc/testsuite/gcc.dg/pr45416.c b/gcc/testsuite/gcc.dg/pr45416.c
index dd37ec534..a3f6a759d 100644
--- a/gcc/testsuite/gcc.dg/pr45416.c
+++ b/gcc/testsuite/gcc.dg/pr45416.c
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-skip-if "Skip for Thumb1." { { arm*-*-* } && { arm_thumb1_ok } } } */
-/* { dg-options "-O2 -ftree-fold-phiopt" } */
+/* { dg-options "-O2" } */
int foo(long long a)
{
diff --git a/gcc/testsuite/gcc.target/i386/pr65871-3.c b/gcc/testsuite/gcc.target/i386/pr65871-3.c
index 4fd3b48f8..c7d9bdd96 100644
--- a/gcc/testsuite/gcc.target/i386/pr65871-3.c
+++ b/gcc/testsuite/gcc.target/i386/pr65871-3.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -mbmi" } */
+/* { dg-options "-O2 -mbmi" } */
int foo (int x, int y)
{
--
2.33.0
From 84369dee2a57a36f12494668bdd8f5d3dea0e88c Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:58:06 +0800
Subject: [PATCH 02/18] Revert "[test] Add option -ftree-fold-phiopt to avoid
fail, NFC"
This reverts commit 1d0bbeb4171f21baf18db6a802bd0b9685e2d25b.
---
gcc/testsuite/c-c++-common/ubsan/pr85213.c | 2 +-
gcc/testsuite/gcc.dg/uninit-8.c | 2 +-
gcc/testsuite/gcc.target/aarch64/bics_3.c | 2 +-
gcc/testsuite/gcc.target/aarch64/scalar-vca.c | 2 +-
gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c | 2 +-
gcc/testsuite/gcc.target/aarch64/simd/int_comparisons_1.c | 2 +-
gcc/testsuite/gcc.target/aarch64/simd/vcaled_f64.c | 2 +-
gcc/testsuite/gcc.target/aarch64/simd/vcales_f32.c | 2 +-
gcc/testsuite/gcc.target/aarch64/simd/vcaltd_f64.c | 2 +-
gcc/testsuite/gcc.target/aarch64/simd/vcalts_f32.c | 2 +-
10 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr85213.c b/gcc/testsuite/c-c++-common/ubsan/pr85213.c
index 804c29da7..8a6be81d2 100644
--- a/gcc/testsuite/c-c++-common/ubsan/pr85213.c
+++ b/gcc/testsuite/c-c++-common/ubsan/pr85213.c
@@ -1,6 +1,6 @@
/* PR sanitizer/85213 */
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fsanitize=undefined -fcompare-debug" } */
+/* { dg-options "-O1 -fsanitize=undefined -fcompare-debug" } */
int
foo (int x)
diff --git a/gcc/testsuite/gcc.dg/uninit-8.c b/gcc/testsuite/gcc.dg/uninit-8.c
index e8fd942cf..98700f4aa 100644
--- a/gcc/testsuite/gcc.dg/uninit-8.c
+++ b/gcc/testsuite/gcc.dg/uninit-8.c
@@ -3,7 +3,7 @@
May be the same as uninit-1.c. */
/* { dg-do compile } */
-/* { dg-options "-O -ftree-fold-phiopt -Wuninitialized" } */
+/* { dg-options "-O -Wuninitialized" } */
#include <limits.h>
diff --git a/gcc/testsuite/gcc.target/aarch64/bics_3.c b/gcc/testsuite/gcc.target/aarch64/bics_3.c
index ab6f0210e..3257df622 100644
--- a/gcc/testsuite/gcc.target/aarch64/bics_3.c
+++ b/gcc/testsuite/gcc.target/aarch64/bics_3.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-O2 -ftree-fold-phiopt --save-temps" } */
+/* { dg-options "-O2 --save-temps" } */
extern void abort (void);
diff --git a/gcc/testsuite/gcc.target/aarch64/scalar-vca.c b/gcc/testsuite/gcc.target/aarch64/scalar-vca.c
index 58ce99328..40a359725 100644
--- a/gcc/testsuite/gcc.target/aarch64/scalar-vca.c
+++ b/gcc/testsuite/gcc.target/aarch64/scalar-vca.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-O3 -ftree-fold-phiopt --save-temps" } */
+/* { dg-options "-O3 --save-temps" } */
#include <arm_neon.h>
diff --git a/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c b/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c
index bcd7e4c83..c2e13b651 100644
--- a/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c
+++ b/gcc/testsuite/gcc.target/aarch64/scalar_intrinsics.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -dp" } */
+/* { dg-options "-O2 -dp" } */
#include <arm_neon.h>
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/int_comparisons_1.c b/gcc/testsuite/gcc.target/aarch64/simd/int_comparisons_1.c
index 3f989257b..f2c55922f 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/int_comparisons_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/int_comparisons_1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O3 -ftree-fold-phiopt -fno-inline" } */
+/* { dg-options "-O3 -fno-inline" } */
/* Scan-assembler test, so, incorporate as little other code as possible. */
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vcaled_f64.c b/gcc/testsuite/gcc.target/aarch64/simd/vcaled_f64.c
index 357d0f61a..198b18b4e 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/vcaled_f64.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/vcaled_f64.c
@@ -1,7 +1,7 @@
/* Test the vcaled_f64 AArch64 SIMD intrinsic. */
/* { dg-do run } */
-/* { dg-options "-save-temps -O3 -ftree-fold-phiopt" } */
+/* { dg-options "-save-temps -O3" } */
#include "arm_neon.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vcales_f32.c b/gcc/testsuite/gcc.target/aarch64/simd/vcales_f32.c
index a2b5a5f50..6b58501f3 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/vcales_f32.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/vcales_f32.c
@@ -1,7 +1,7 @@
/* Test the vcales_f32 AArch64 SIMD intrinsic. */
/* { dg-do run } */
-/* { dg-options "-save-temps -O3 -ftree-fold-phiopt" } */
+/* { dg-options "-save-temps -O3" } */
#include "arm_neon.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vcaltd_f64.c b/gcc/testsuite/gcc.target/aarch64/simd/vcaltd_f64.c
index d77f68378..50a3b2718 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/vcaltd_f64.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/vcaltd_f64.c
@@ -1,7 +1,7 @@
/* Test the vcaltd_f64 AArch64 SIMD intrinsic. */
/* { dg-do run } */
-/* { dg-options "-save-temps -O3 -ftree-fold-phiopt" } */
+/* { dg-options "-save-temps -O3" } */
#include "arm_neon.h"
diff --git a/gcc/testsuite/gcc.target/aarch64/simd/vcalts_f32.c b/gcc/testsuite/gcc.target/aarch64/simd/vcalts_f32.c
index d723b9ac5..1807e0b95 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd/vcalts_f32.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd/vcalts_f32.c
@@ -1,7 +1,7 @@
/* Test the vcalts_f32 AArch64 SIMD intrinsic. */
/* { dg-do run } */
-/* { dg-options "-save-temps -O3 -ftree-fold-phiopt" } */
+/* { dg-options "-save-temps -O3" } */
#include "arm_neon.h"
--
2.33.0
From 3a9586ab41c46bf11cbe2d35ca3f10c240a78df2 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:58:21 +0800
Subject: [PATCH 03/18] Revert "[phiopt2] Add option to control the simplify"
This reverts commit bc6537191e91c854cc6bee3319290d7a86768957.
---
gcc/common.opt | 4 ----
gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/bool-1.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/bool-2.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr18134.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr21829.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c | 4 ++--
gcc/tree-ssa-phiopt.c | 3 ---
13 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 73234dcc3..948806cd0 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2832,10 +2832,6 @@ ftree-store-ccp
Common Ignore
Does nothing. Preserved for backward compatibility.
-ftree-fold-phiopt
-Common Report Var(flag_fold_phiopt) Init(0) Optimization
-Attempt to simply the phi node with ssa form.
-
ftree-ch
Common Report Var(flag_tree_ch) Optimization
Enable loop header copying on trees.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
index b04316d55..364ce6a69 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040514-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-phiopt2-details" } */
+/* { dg-options "-O1 -fdump-tree-phiopt2-details" } */
int t( int i)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
index 892654108..401357f2f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
int f(_Bool x)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c b/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
index 5ead90f06..add9cca1e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/bool-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
int f(_Bool x)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
index 7b678fafc..4c190e6af 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-10.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
int nem1_phi (unsigned long a) { return a ? -1 : 0; }
int eqm1_phi (unsigned long a) { return a ? 0 : -1; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
index 23b679644..fd3706666 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-22.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/97690 */
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-phiopt2" } */
+/* { dg-options "-O2 -fdump-tree-phiopt2" } */
int foo (_Bool d) { return d ? 2 : 0; }
int bar (_Bool d) { return d ? 1 : 0; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
index 4efd9afc4..3bdb85609 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-4.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
_Bool t();
_Bool t1();
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
index 60dcc6733..18ecbd52a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
int g(int,int);
int f(int t, int c)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
index aaa71a317..98c596b6a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-8.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O -ftree-fold-phiopt -fdump-tree-optimized -fdump-tree-phiopt2" } */
+/* { dg-options "-O -fdump-tree-optimized -fdump-tree-phiopt2" } */
int g(int,int);
int f(int t, int c)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
index efb1907cf..cd40ab2c1 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr18134.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
int foo (int a)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
index 8c8ada905..8f5ae5127 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21829.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
int test(int v)
{
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
index 88c13806a..a2770e5e8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
@@ -1,9 +1,9 @@
/* PR tree-optimization/96928 */
/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-fold-phiopt -fdump-tree-phiopt2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-phiopt2" } */
/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-times " = ~c_\[0-9]*\\\(D\\\);" 1 "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " = ~" 1 "phiopt2" } } */
/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 535dfc70a..21ac08145 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -838,9 +838,6 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
tree result;
gimple *stmt_to_move = NULL;
- if (!flag_fold_phiopt)
- return false;
-
/* Special case A ? B : B as this will always simplify to B. */
if (operand_equal_for_phi_arg_p (arg0, arg1))
return false;
--
2.33.0
From af3bc83c31e5b34b934d045bb1ed3cb3c3c719d6 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:58:34 +0800
Subject: [PATCH 04/18] Revert "[Backport] Fix typo in tree-ssa-reassoc.c."
This reverts commit 2f117a3b333ecc8a1fa529e86285ad71c98b03a4.
---
gcc/tree-ssa-reassoc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 1ad43dba1..62e7c8dca 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3839,7 +3839,7 @@ ovce_extract_ops (tree var, gassign **rets, bool *reti, tree *type,
gassign *stmt = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (var));
if (stmt == NULL)
return ERROR_MARK;
- if (vcond)
+ if (*vcond)
*vcond = stmt;
/* ??? If we start creating more COND_EXPR, we could perform
--
2.33.0
From 8cdf3ac3a3ca87e3e1f07471b6504e1d2a1019a7 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:58:39 +0800
Subject: [PATCH 05/18] Revert "[Backport] tree-optimization/97238 - fix typo
causing ICE"
This reverts commit ae15300352b0fa47a533af852f88e7244c2820cc.
---
gcc/testsuite/gcc.dg/pr97238.c | 12 ------------
gcc/tree-ssa-reassoc.c | 2 +-
2 files changed, 1 insertion(+), 13 deletions(-)
delete mode 100644 gcc/testsuite/gcc.dg/pr97238.c
diff --git a/gcc/testsuite/gcc.dg/pr97238.c b/gcc/testsuite/gcc.dg/pr97238.c
deleted file mode 100644
index 746e93a97..000000000
--- a/gcc/testsuite/gcc.dg/pr97238.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O -Wno-psabi -w" } */
-
-typedef int __attribute__ ((__vector_size__ (8))) V;
-int b, c, e;
-V d;
-
-V
-foo (void)
-{
- return (b || e) | c > d | ((b || e) | c > d);
-}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 62e7c8dca..5f978ac78 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -3853,7 +3853,7 @@ ovce_extract_ops (tree var, gassign **rets, bool *reti, tree *type,
return ERROR_MARK;
gassign *assign = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (cond));
- if (assign == NULL
+ if (stmt == NULL
|| TREE_CODE_CLASS (gimple_assign_rhs_code (assign)) != tcc_comparison)
return ERROR_MARK;
--
2.33.0
From 2b679ed1d6bcee51d97b9c36757b3feeb05bffdc Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:58:55 +0800
Subject: [PATCH 06/18] Revert "[MULL64] Disable mull64 transformation by
default"
This reverts commit fb86109ebb10cdb82e1e3ffa37bb7e770fb7c066.
---
gcc/match.pd | 2 +-
gcc/opts.c | 1 +
gcc/testsuite/g++.dg/tree-ssa/mull64.C | 2 +-
gcc/testsuite/gcc.dg/pr107190.c | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index 2d9705eae..f21bd3f81 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3464,7 +3464,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(cond @0 (op:s @1 integer_pow2p@2) @1)
/* powerof2cst */
- (if (flag_merge_mull && INTEGRAL_TYPE_P (type))
+ (if (INTEGRAL_TYPE_P (type))
(with {
tree shift = build_int_cst (integer_type_node, tree_log2 (@2));
}
diff --git a/gcc/opts.c b/gcc/opts.c
index f12b13599..751965e46 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -511,6 +511,7 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_CHEAP },
{ OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_fmerge_mull, NULL, 1 },
/* -O2 and above optimizations, but not -Os or -Og. */
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_functions, NULL, 1 },
diff --git a/gcc/testsuite/g++.dg/tree-ssa/mull64.C b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
index cad891e62..f61cf5e6f 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/mull64.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fmerge-mull -Wno-psabi -fdump-tree-forwprop1-details -fdump-tree-forwprop4-details" } */
+/* { dg-options "-O2 -Wno-psabi -fdump-tree-forwprop1-details -fdump-tree-forwprop4-details" } */
# define BN_BITS4 32
# define BN_MASK2 (0xffffffffffffffffL)
diff --git a/gcc/testsuite/gcc.dg/pr107190.c b/gcc/testsuite/gcc.dg/pr107190.c
index d1e72e5df..235b2761a 100644
--- a/gcc/testsuite/gcc.dg/pr107190.c
+++ b/gcc/testsuite/gcc.dg/pr107190.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fmerge-mull -fexpensive-optimizations -fdump-tree-phiopt2-details" } */
+/* { dg-options "-O2 -fexpensive-optimizations -fdump-tree-phiopt2-details" } */
# define BN_BITS4 32
# define BN_MASK2 (0xffffffffffffffffL)
--
2.33.0
From 31eeb95c946337be82c85ed43dc1809186d043ac Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 20:59:07 +0800
Subject: [PATCH 07/18] Revert "[FORWPROP] Fold series of instructions into
umulh"
This reverts commit 315911bd3ae6f42366779e262ab76d9ed79359a0.
---
gcc/match.pd | 56 --------------------------
gcc/testsuite/g++.dg/tree-ssa/mull64.C | 5 +--
2 files changed, 2 insertions(+), 59 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index f21bd3f81..51bdc8ab8 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3475,62 +3475,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
)
#endif
-#if GIMPLE
-/* These patterns are mostly used by FORWPROP4 to move some operations outside of
- the if statements. They should be done late because it gives jump threading
- and few other passes to reduce what is going on. */
-/* Mul64 is defined as a multiplication algorithm which compute two 64-bit
- integers to one 128-bit integer. Try to match the high part of mul pattern
- after the low part of mul pattern is simplified. The following scenario
- should be matched:
- (i64 ResLo, i64 ResHi) = Mul64(i64 In0, i64 In1) {
- In0Lo = In0(D) & 4294967295; -- bit_and@4 SSA_NAME@0 @2
- In0Hi = In0(D) >> 32; -- rshift@5 SSA_NAME@0 @3
- In1Lo = In1(D) & 4294967295; -- bit_and@6 SSA_NAME@1 INTEGER_CST@2
- In1Hi = In1(D) >> 32; -- rshift@7 SSA_NAME@1 INTEGER_CST@3
- Mull_01 = In0Hi * In1Lo; -- mult@8 @5 @6
- Addc = In0Lo * In1Hi + Mull_01; -- plus@9 (mult (@4 @7) @8
- AddH = (Addc >> 32) + In0Hi * In1Hi -- (plus@11 (rshift @9 @3) (mult @5 @7))
- addc32 = Addc << 32; -- lshift@10 @9 @3
- ResLo = In0(D) * In1(D); -- mult @0 @1
- ResHi = ((long unsigned int) (addc32 > ResLo)) +
- (((long unsigned int) (Mull_01 > Addc)) << 32) + AddH;
- } */
-(simplify
- (plus:c
- (plus:c
- (convert
- (gt (lshift@10 @9 @3)
- (mult:c @0 @1)))
- (lshift
- (convert
- (gt @8 @9))
- @3))
- (plus:c@11
- (rshift
- (plus:c@9
- (mult:c (bit_and@4 SSA_NAME@0 @2) @7)
- (mult:c@8 @5 (bit_and@6 SSA_NAME@1 INTEGER_CST@2)))
- @3)
- (mult:c (rshift@5 SSA_NAME@0 @3)
- (rshift@7 SSA_NAME@1 INTEGER_CST@3))
- )
- )
- (if (flag_merge_mull && INTEGRAL_TYPE_P (type)
- && INTEGRAL_TYPE_P (TREE_TYPE (@0)) && types_match (@0, @1)
- && TYPE_PRECISION (type) == 64)
- (with {
- tree i128_type = build_nonstandard_integer_type (128, TYPE_UNSIGNED (type));
- tree shift = build_int_cst (integer_type_node, 64);
- }
- (convert:type (rshift
- (mult (convert:i128_type @0)
- (convert:i128_type @1))
- { shift; })))
- )
-)
-#endif
-
#if GIMPLE
/* These patterns are mostly used by FORWPROP1 to fold some operations into more
simple IR. The following scenario should be matched:
diff --git a/gcc/testsuite/g++.dg/tree-ssa/mull64.C b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
index f61cf5e6f..2a3b74604 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/mull64.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -Wno-psabi -fdump-tree-forwprop1-details -fdump-tree-forwprop4-details" } */
+/* { dg-options "-O2 -Wno-psabi -fmerge-mull -fdump-tree-forwprop1-details" } */
# define BN_BITS4 32
# define BN_MASK2 (0xffffffffffffffffL)
@@ -31,5 +31,4 @@ void mul64(unsigned long in0, unsigned long in1,
retHi = m11;
}
-/* { dg-final { scan-tree-dump "gimple_simplified to" "forwprop1" } } */
-/* { dg-final { scan-tree-dump-times "gimple_simplified to" 1 "forwprop4" } } */
+/* { dg-final { scan-tree-dump "gimple_simplified to low_18 = in0_4" "forwprop1" } } */
--
2.33.0
From 1fca02dd5ccfed3187a4a71bfbb49a3afeedc283 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:13:25 +0800
Subject: [PATCH 08/18] Revert "[FORWPROP] Fold series of instructions into
mul"
This reverts commit 2a2d0ba6a26d64f4c1f9352bb2c69dea8b67d6a6.
---
gcc/common.opt | 4 ---
gcc/match.pd | 27 --------------------
gcc/opts.c | 1 -
gcc/testsuite/g++.dg/tree-ssa/mull64.C | 34 --------------------------
4 files changed, 66 deletions(-)
delete mode 100644 gcc/testsuite/g++.dg/tree-ssa/mull64.C
diff --git a/gcc/common.opt b/gcc/common.opt
index 948806cd0..58f7be5d3 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2104,10 +2104,6 @@ fmerge-debug-strings
Common Report Var(flag_merge_debug_strings) Init(1)
Attempt to merge identical debug strings across compilation units.
-fmerge-mull
-Common Report Var(flag_merge_mull) Init(0) Optimization
-Attempt to merge series instructions into mul.
-
fmessage-length=
Common RejectNegative Joined UInteger
-fmessage-length=<number> Limit diagnostics to <number> characters per line. 0 suppresses line-wrapping.
diff --git a/gcc/match.pd b/gcc/match.pd
index 51bdc8ab8..886ea3e4d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3475,33 +3475,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
)
#endif
-#if GIMPLE
-/* These patterns are mostly used by FORWPROP1 to fold some operations into more
- simple IR. The following scenario should be matched:
- In0Lo = In0(D) & 4294967295;
- In0Hi = In0(D) >> 32;
- In1Lo = In1(D) & 4294967295;
- In1Hi = In1(D) >> 32;
- Addc = In0Lo * In1Hi + In0Hi * In1Lo;
- addc32 = Addc << 32;
- ResLo = In0Lo * In1Lo + addc32 */
-(simplify
- (plus:c (mult @4 @5)
- (lshift
- (plus:c
- (mult (bit_and@4 SSA_NAME@0 @2) (rshift SSA_NAME@1 @3))
- (mult (rshift SSA_NAME@0 @3) (bit_and@5 SSA_NAME@1 INTEGER_CST@2)))
- INTEGER_CST@3
- )
- )
- (if (flag_merge_mull && INTEGRAL_TYPE_P (type)
- && INTEGRAL_TYPE_P (TREE_TYPE (@0)) && types_match (@0, @1)
- && TYPE_PRECISION (type) == 64)
- (mult (convert:type @0) (convert:type @1))
- )
-)
-#endif
-
#if GIMPLE
/* Try to match
_4 = (int) _3; NOP_EXPR (SSA_NAME @2)
diff --git a/gcc/opts.c b/gcc/opts.c
index 751965e46..f12b13599 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -511,7 +511,6 @@ static const struct default_options default_options_table[] =
{ OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_CHEAP },
{ OPT_LEVELS_2_PLUS, OPT_finline_functions, NULL, 1 },
{ OPT_LEVELS_2_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
- { OPT_LEVELS_2_PLUS, OPT_fmerge_mull, NULL, 1 },
/* -O2 and above optimizations, but not -Os or -Og. */
{ OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_functions, NULL, 1 },
diff --git a/gcc/testsuite/g++.dg/tree-ssa/mull64.C b/gcc/testsuite/g++.dg/tree-ssa/mull64.C
deleted file mode 100644
index 2a3b74604..000000000
--- a/gcc/testsuite/g++.dg/tree-ssa/mull64.C
+++ /dev/null
@@ -1,34 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -Wno-psabi -fmerge-mull -fdump-tree-forwprop1-details" } */
-
-# define BN_BITS4 32
-# define BN_MASK2 (0xffffffffffffffffL)
-# define BN_MASK2l (0xffffffffL)
-# define BN_MASK2h (0xffffffff00000000L)
-# define BN_MASK2h1 (0xffffffff80000000L)
-# define LBITS(a) ((a)&BN_MASK2l)
-# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
-# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
-
-void mul64(unsigned long in0, unsigned long in1,
- unsigned long &retLo, unsigned long &retHi) {
- unsigned long m00, m01, m10, m11, al, ah, bl, bh;
- unsigned long Addc, addc32, low;
- al = LBITS(in0);
- ah = HBITS(in0);
- bl = LBITS(in1);
- bh = HBITS(in1);
- m10 = bh * al;
- m00 = bl * al;
- m01 = bl * ah;
- m11 = bh * ah;
- Addc = (m10 + m01) & BN_MASK2;
- if (Addc < m01) m11 += L2HBITS((unsigned long)1);
- m11 += HBITS(Addc);
- addc32 = L2HBITS(Addc);
- low = (m00 + addc32) & BN_MASK2; if (low < addc32) m11++;
- retLo = low;
- retHi = m11;
-}
-
-/* { dg-final { scan-tree-dump "gimple_simplified to low_18 = in0_4" "forwprop1" } } */
--
2.33.0
From 2dc164c3e4e70b090c0ad5946400536e32795e9f Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:16:38 +0800
Subject: [PATCH 09/18] Revert "[PHIOPT] Add A ? B op CST : B match and
simplify optimizations"
This reverts commit 9af03694082c462bee86c167c78717089a93a188.
---
gcc/match.pd | 21 ---------------------
gcc/testsuite/gcc.dg/pr107190.c | 27 ---------------------------
2 files changed, 48 deletions(-)
delete mode 100644 gcc/testsuite/gcc.dg/pr107190.c
diff --git a/gcc/match.pd b/gcc/match.pd
index 886ea3e4d..937a425f2 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3454,27 +3454,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
)
#endif
-#if GIMPLE
-(if (canonicalize_math_p ())
-/* These patterns are mostly used by PHIOPT to move some operations outside of
- the if statements. They should be done late because it gives jump threading
- and few other passes to reduce what is going on. */
-/* a ? x op C : x -> x op (a << log2(C)) when C is power of 2. */
- (for op (plus minus bit_ior bit_xor lshift rshift lrotate rrotate)
- (simplify
- (cond @0 (op:s @1 integer_pow2p@2) @1)
- /* powerof2cst */
- (if (INTEGRAL_TYPE_P (type))
- (with {
- tree shift = build_int_cst (integer_type_node, tree_log2 (@2));
- }
- (op @1 (lshift (convert (convert:boolean_type_node @0)) { shift; })))
- )
- )
- )
-)
-#endif
-
#if GIMPLE
/* Try to match
_4 = (int) _3; NOP_EXPR (SSA_NAME @2)
diff --git a/gcc/testsuite/gcc.dg/pr107190.c b/gcc/testsuite/gcc.dg/pr107190.c
deleted file mode 100644
index 235b2761a..000000000
--- a/gcc/testsuite/gcc.dg/pr107190.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -fexpensive-optimizations -fdump-tree-phiopt2-details" } */
-
-# define BN_BITS4 32
-# define BN_MASK2 (0xffffffffffffffffL)
-# define BN_MASK2l (0xffffffffL)
-# define BN_MASK2h (0xffffffff00000000L)
-# define BN_MASK2h1 (0xffffffff80000000L)
-# define LBITS(a) ((a)&BN_MASK2l)
-# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
-# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
-
-unsigned int test_m(unsigned long in0, unsigned long in1) {
- unsigned long m, m1, lt, ht, bl, bh;
- lt = LBITS(in0);
- ht = HBITS(in0);
- bl = LBITS(in1);
- bh = HBITS(in1);
- m = bh * lt;
- m1 = bl * ht;
- ht = bh * ht;
- m = (m + m1) & BN_MASK2;
- if (m < m1) ht += L2HBITS((unsigned long)1);
- return ht + m;
-}
-
-/* { dg-final { scan-tree-dump "COND_EXPR in block 2 and PHI in block 4 converted to straightline code" "phiopt2" } } */
--
2.33.0
From 49d054085f725b081b3b31615bc8aa6a677bd7c1 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:17:47 +0800
Subject: [PATCH 10/18] Revert "[PHIOPT] Disable the match A?CST1:0 when the
CST1 is negitive value"
This reverts commit b57c55b282e7a9a7b2cc0d3843e58fd7998685e6.
---
gcc/match.pd | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index 937a425f2..6c0dc8904 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3393,8 +3393,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(if (integer_onep (@1))
(convert (convert:boolean_type_node @0)))
/* a ? powerof2cst : 0 -> a << (log2(powerof2cst)) */
- (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (TREE_TYPE (@1))
- && integer_pow2p (@1))
+ (if (INTEGRAL_TYPE_P (type) && integer_pow2p (@1))
(with {
tree shift = build_int_cst (integer_type_node, tree_log2 (@1));
}
--
2.33.0
From b8024edd31345129695c3582816e377f53e5f60b Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:39:25 +0800
Subject: [PATCH 11/18] Revert "[Backport] Optimize x ? bswap(x) : 0 in
tree-ssa-phiopt"
This reverts commit 33dc778a34d7b93978efe922bb1b4583d8e6c4bb.
---
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c | 83 ----------------------
gcc/tree-ssa-phiopt.c | 37 +++-------
2 files changed, 11 insertions(+), 109 deletions(-)
delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c
deleted file mode 100644
index c52c92e1d..000000000
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-25.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
-
-unsigned short test_bswap16(unsigned short x)
-{
- return x ? __builtin_bswap16(x) : 0;
-}
-
-unsigned int test_bswap32(unsigned int x)
-{
- return x ? __builtin_bswap32(x) : 0;
-}
-
-unsigned long long test_bswap64(unsigned long long x)
-{
- return x ? __builtin_bswap64(x) : 0;
-}
-
-int test_clrsb(int x)
-{
- return x ? __builtin_clrsb(x) : (__SIZEOF_INT__*8-1);
-}
-
-int test_clrsbl(long x)
-{
- return x ? __builtin_clrsbl(x) : (__SIZEOF_LONG__*8-1);
-}
-
-int test_clrsbll(long long x)
-{
- return x ? __builtin_clrsbll(x) : (__SIZEOF_LONG_LONG__*8-1);
-}
-
-#if 0
-/* BUILT_IN_FFS is transformed by match.pd */
-int test_ffs(unsigned int x)
-{
- return x ? __builtin_ffs(x) : 0;
-}
-
-int test_ffsl(unsigned long x)
-{
- return x ? __builtin_ffsl(x) : 0;
-}
-
-int test_ffsll(unsigned long long x)
-{
- return x ? __builtin_ffsll(x) : 0;
-}
-#endif
-
-int test_parity(int x)
-{
- return x ? __builtin_parity(x) : 0;
-}
-
-int test_parityl(long x)
-{
- return x ? __builtin_parityl(x) : 0;
-}
-
-int test_parityll(long long x)
-{
- return x ? __builtin_parityll(x) : 0;
-}
-
-int test_popcount(int x)
-{
- return x ? __builtin_popcount(x) : 0;
-}
-
-int test_popcountl(long x)
-{
- return x ? __builtin_popcountl(x) : 0;
-}
-
-int test_popcountll(long long x)
-{
- return x ? __builtin_popcountll(x) : 0;
-}
-
-/* { dg-final { scan-tree-dump-not "goto" "optimized" } } */
-
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 21ac08145..045a7b1b8 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -66,9 +66,9 @@ static bool abs_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
static bool spaceship_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
-static bool cond_removal_in_builtin_zero_pattern (basic_block, basic_block,
- edge, edge, gphi *,
- tree, tree);
+static bool cond_removal_in_popcount_clz_ctz_pattern (basic_block, basic_block,
+ edge, edge, gphi *,
+ tree, tree);
static bool cond_store_replacement (basic_block, basic_block, edge, edge,
hash_set<tree> *);
static bool cond_if_else_store_replacement (basic_block, basic_block, basic_block);
@@ -355,8 +355,9 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
else if (abs_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
else if (!early_p
- && cond_removal_in_builtin_zero_pattern (bb, bb1, e1, e2,
- phi, arg0, arg1))
+ && cond_removal_in_popcount_clz_ctz_pattern (bb, bb1, e1,
+ e2, phi, arg0,
+ arg1))
cfgchanged = true;
else if (minmax_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
@@ -2203,8 +2204,7 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
return true;
}
-/* Optimize x ? __builtin_fun (x) : C, where C is __builtin_fun (0).
- Convert
+/* Convert
<bb 2>
if (b_4(D) != 0)
@@ -2236,10 +2236,10 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
instead of 0 above it uses the value from that macro. */
static bool
-cond_removal_in_builtin_zero_pattern (basic_block cond_bb,
- basic_block middle_bb,
- edge e1, edge e2, gphi *phi,
- tree arg0, tree arg1)
+cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
+ basic_block middle_bb,
+ edge e1, edge e2, gphi *phi,
+ tree arg0, tree arg1)
{
gimple *cond;
gimple_stmt_iterator gsi, gsi_from;
@@ -2287,12 +2287,6 @@ cond_removal_in_builtin_zero_pattern (basic_block cond_bb,
int val = 0;
switch (cfn)
{
- case CFN_BUILT_IN_BSWAP16:
- case CFN_BUILT_IN_BSWAP32:
- case CFN_BUILT_IN_BSWAP64:
- case CFN_BUILT_IN_BSWAP128:
- CASE_CFN_FFS:
- CASE_CFN_PARITY:
CASE_CFN_POPCOUNT:
break;
CASE_CFN_CLZ:
@@ -2321,15 +2315,6 @@ cond_removal_in_builtin_zero_pattern (basic_block cond_bb,
}
}
return false;
- case BUILT_IN_CLRSB:
- val = TYPE_PRECISION (integer_type_node) - 1;
- break;
- case BUILT_IN_CLRSBL:
- val = TYPE_PRECISION (long_integer_type_node) - 1;
- break;
- case BUILT_IN_CLRSBLL:
- val = TYPE_PRECISION (long_long_integer_type_node) - 1;
- break;
default:
return false;
}
--
2.33.0
From cbd2122a2c80f6fff309d0781a54dde365549aab Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:44:56 +0800
Subject: [PATCH 12/18] Revert "[Backport] Allow match-and-simplified phiopt to
run in early phiopt"
This reverts commit fabbe6ccc798d3cb097c6371b4d53cd6dfde6c7c.
---
gcc/tree-ssa-phiopt.c | 89 +++++++++----------------------------------
1 file changed, 19 insertions(+), 70 deletions(-)
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 045a7b1b8..9e72f2709 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -49,13 +49,12 @@ along with GCC; see the file COPYING3. If not see
#include "tree-eh.h"
#include "gimple-fold.h"
#include "internal-fn.h"
-#include "gimple-match.h"
static unsigned int tree_ssa_phiopt_worker (bool, bool, bool);
static bool two_value_replacement (basic_block, basic_block, edge, gphi *,
tree, tree);
static bool match_simplify_replacement (basic_block, basic_block,
- edge, edge, gphi *, tree, tree, bool);
+ edge, edge, gphi *, tree, tree);
static gphi *factor_out_conditional_conversion (edge, edge, gphi *, tree, tree,
gimple *);
static int value_replacement (basic_block, basic_block,
@@ -348,9 +347,9 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
/* Do the replacement of conditional if it can be done. */
if (!early_p && two_value_replacement (bb, bb1, e2, phi, arg0, arg1))
cfgchanged = true;
- else if (match_simplify_replacement (bb, bb1, e1, e2, phi,
- arg0, arg1,
- early_p))
+ else if (!early_p
+ && match_simplify_replacement (bb, bb1, e1, e2, phi,
+ arg0, arg1))
cfgchanged = true;
else if (abs_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
@@ -760,67 +759,6 @@ two_value_replacement (basic_block cond_bb, basic_block middle_bb,
return true;
}
-/* Return TRUE if CODE should be allowed during early phiopt.
- Currently this is to allow MIN/MAX and ABS/NEGATE. */
-static bool
-phiopt_early_allow (enum tree_code code)
-{
- switch (code)
- {
- case MIN_EXPR:
- case MAX_EXPR:
- case ABS_EXPR:
- case ABSU_EXPR:
- case NEGATE_EXPR:
- case SSA_NAME:
- return true;
- default:
- return false;
- }
-}
-
-/* gimple_simplify_phiopt is like gimple_simplify but designed for PHIOPT.
- Return NULL if nothing can be simplified or the resulting simplified value
- with parts pushed if EARLY_P was true. Also rejects non allowed tree code
- if EARLY_P is set.
- Takes the comparison from COMP_STMT and two args, ARG0 and ARG1 and tries
- to simplify CMP ? ARG0 : ARG1. */
-static tree
-gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt,
- tree arg0, tree arg1,
- gimple_seq *seq)
-{
- tree result;
- enum tree_code comp_code = gimple_cond_code (comp_stmt);
- location_t loc = gimple_location (comp_stmt);
- tree cmp0 = gimple_cond_lhs (comp_stmt);
- tree cmp1 = gimple_cond_rhs (comp_stmt);
- /* To handle special cases like floating point comparison, it is easier and
- less error-prone to build a tree and gimplify it on the fly though it is
- less efficient.
- Don't use fold_build2 here as that might create (bool)a instead of just
- "a != 0". */
- tree cond = build2_loc (loc, comp_code, boolean_type_node,
- cmp0, cmp1);
- gimple_match_op op (gimple_match_cond::UNCOND,
- COND_EXPR, type, cond, arg0, arg1);
-
- if (op.resimplify (early_p ? NULL : seq, follow_all_ssa_edges))
- {
- /* Early we want only to allow some generated tree codes. */
- if (!early_p
- || op.code.is_tree_code ()
- || phiopt_early_allow ((tree_code)op.code))
- {
- result = maybe_push_res_to_seq (&op, seq);
- if (result)
- return result;
- }
- }
-
- return NULL;
-}
-
/* The function match_simplify_replacement does the main work of doing the
replacement using match and simplify. Return true if the replacement is done.
Otherwise return false.
@@ -830,9 +768,10 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt,
static bool
match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
edge e0, edge e1, gphi *phi,
- tree arg0, tree arg1, bool early_p)
+ tree arg0, tree arg1)
{
gimple *stmt;
+ tree cond;
gimple_stmt_iterator gsi;
edge true_edge, false_edge;
gimple_seq seq = NULL;
@@ -893,6 +832,15 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
stmt = last_stmt (cond_bb);
+ /* To handle special cases like floating point comparison, it is easier and
+ less error-prone to build a tree and gimplify it on the fly though it is
+ less efficient.
+ Don't use fold_build2 here as that might create (bool)a instead of just
+ "a != 0". */
+ cond = build2_loc (gimple_location (stmt),
+ gimple_cond_code (stmt), boolean_type_node,
+ gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
+
/* We need to know which is the true edge and which is the false
edge so that we know when to invert the condition below. */
extract_true_false_edges_from_block (cond_bb, &true_edge, &false_edge);
@@ -900,9 +848,10 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
std::swap (arg0, arg1);
tree type = TREE_TYPE (gimple_phi_result (phi));
- result = gimple_simplify_phiopt (early_p, type, stmt,
- arg0, arg1,
- &seq);
+ result = gimple_simplify (COND_EXPR, type,
+ cond,
+ arg0, arg1,
+ &seq, NULL);
if (!result)
return false;
--
2.33.0
From 5a9f05273992522dad44e8a46fbabbee15fec3aa Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:47:49 +0800
Subject: [PATCH 13/18] Revert "[Backport] Add support for __builtin_bswap128"
This reverts commit 96afd5b761a74e9eef40a2e843810c503c669de8.
---
gcc/builtin-types.def | 4 ----
gcc/builtins.c | 2 --
gcc/builtins.def | 2 --
gcc/doc/extend.texi | 10 ++--------
gcc/fold-const-call.c | 1 -
gcc/fold-const.c | 2 --
gcc/optabs.c | 5 +----
gcc/tree-core.h | 1 -
gcc/tree-ssa-ccp.c | 1 -
gcc/tree-vect-stmts.c | 5 ++---
gcc/tree.c | 2 --
gcc/tree.h | 1 -
12 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
index c46b1bc5c..c7aa691b2 100644
--- a/gcc/builtin-types.def
+++ b/gcc/builtin-types.def
@@ -73,9 +73,6 @@ DEF_PRIMITIVE_TYPE (BT_UINT8, unsigned_char_type_node)
DEF_PRIMITIVE_TYPE (BT_UINT16, uint16_type_node)
DEF_PRIMITIVE_TYPE (BT_UINT32, uint32_type_node)
DEF_PRIMITIVE_TYPE (BT_UINT64, uint64_type_node)
-DEF_PRIMITIVE_TYPE (BT_UINT128, uint128_type_node
- ? uint128_type_node
- : error_mark_node)
DEF_PRIMITIVE_TYPE (BT_WORD, (*lang_hooks.types.type_for_mode) (word_mode, 1))
DEF_PRIMITIVE_TYPE (BT_UNWINDWORD, (*lang_hooks.types.type_for_mode)
(targetm.unwind_word_mode (), 1))
@@ -303,7 +300,6 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT8_FLOAT, BT_UINT8, BT_FLOAT)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT16, BT_UINT16, BT_UINT16)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT32, BT_UINT32, BT_UINT32)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_UINT64, BT_UINT64, BT_UINT64)
-DEF_FUNCTION_TYPE_1 (BT_FN_UINT128_UINT128, BT_UINT128, BT_UINT128)
DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_FLOAT, BT_UINT64, BT_FLOAT)
DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_INT, BT_BOOL, BT_INT)
DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_PTR, BT_BOOL, BT_PTR)
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 1b1c75cc1..10b6fd3bb 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8015,7 +8015,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
case BUILT_IN_BSWAP16:
case BUILT_IN_BSWAP32:
case BUILT_IN_BSWAP64:
- case BUILT_IN_BSWAP128:
target = expand_builtin_bswap (target_mode, exp, target, subtarget);
if (target)
return target;
@@ -11733,7 +11732,6 @@ is_inexpensive_builtin (tree decl)
case BUILT_IN_BSWAP16:
case BUILT_IN_BSWAP32:
case BUILT_IN_BSWAP64:
- case BUILT_IN_BSWAP128:
case BUILT_IN_CLZ:
case BUILT_IN_CLZIMAX:
case BUILT_IN_CLZL:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index ee67ac15d..fa8b0641a 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -834,8 +834,6 @@ DEF_GCC_BUILTIN (BUILT_IN_APPLY_ARGS, "apply_args", BT_FN_PTR_VAR, ATTR_L
DEF_GCC_BUILTIN (BUILT_IN_BSWAP16, "bswap16", BT_FN_UINT16_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GCC_BUILTIN (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GCC_BUILTIN (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, ATTR_CONST_NOTHROW_LEAF_LIST)
-DEF_GCC_BUILTIN (BUILT_IN_BSWAP128, "bswap128", BT_FN_UINT128_UINT128, ATTR_CONST_NOTHROW_LEAF_LIST)
-
DEF_EXT_LIB_BUILTIN (BUILT_IN_CLEAR_CACHE, "__clear_cache", BT_FN_VOID_PTR_PTR, ATTR_NOTHROW_LEAF_LIST)
/* [trans-mem]: Adjust BUILT_IN_TM_CALLOC if BUILT_IN_CALLOC is changed. */
DEF_LIB_BUILTIN (BUILT_IN_CALLOC, "calloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_WARN_UNUSED_RESULT_SIZE_1_2_NOTHROW_LEAF_LIST)
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index a7bd772de..9c7345959 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13727,20 +13727,14 @@ exactly 8 bits.
@deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
Similar to @code{__builtin_bswap16}, except the argument and return types
-are 32-bit.
+are 32 bit.
@end deftypefn
@deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
Similar to @code{__builtin_bswap32}, except the argument and return types
-are 64-bit.
+are 64 bit.
@end deftypefn
-@deftypefn {Built-in Function} uint128_t __builtin_bswap128 (uint128_t x)
-Similar to @code{__builtin_bswap64}, except the argument and return types
-are 128-bit. Only supported on targets when 128-bit types are supported.
-@end deftypefn
-
-
@deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
On targets where the user visible pointer size is smaller than the size
of an actual hardware address this function returns the extended user
diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c
index da01759d9..6150d7ada 100644
--- a/gcc/fold-const-call.c
+++ b/gcc/fold-const-call.c
@@ -1032,7 +1032,6 @@ fold_const_call_ss (wide_int *result, combined_fn fn, const wide_int_ref &arg,
case CFN_BUILT_IN_BSWAP16:
case CFN_BUILT_IN_BSWAP32:
case CFN_BUILT_IN_BSWAP64:
- case CFN_BUILT_IN_BSWAP128:
*result = wide_int::from (arg, precision, TYPE_SIGN (arg_type)).bswap ();
return true;
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 78227a83d..6e635382f 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -13889,10 +13889,8 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
CASE_CFN_POPCOUNT:
CASE_CFN_CLZ:
CASE_CFN_CLRSB:
- case CFN_BUILT_IN_BSWAP16:
case CFN_BUILT_IN_BSWAP32:
case CFN_BUILT_IN_BSWAP64:
- case CFN_BUILT_IN_BSWAP128:
/* Always true. */
return true;
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 64a1a1768..2b7c3e6fb 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -2896,11 +2896,8 @@ expand_unop (machine_mode mode, optab unoptab, rtx op0, rtx target,
if (temp)
return temp;
- /* We do not provide a 128-bit bswap in libgcc so force the use of
- a double bswap for 64-bit targets. */
if (GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD
- && (UNITS_PER_WORD == 64
- || optab_handler (unoptab, word_mode) != CODE_FOR_nothing))
+ && optab_handler (unoptab, word_mode) != CODE_FOR_nothing)
{
temp = expand_doubleword_bswap (mode, op0, target);
if (temp)
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 058e046aa..eb01c2434 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -600,7 +600,6 @@ enum tree_index {
TI_UINT16_TYPE,
TI_UINT32_TYPE,
TI_UINT64_TYPE,
- TI_UINT128_TYPE,
TI_VOID,
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index dcdf10369..952fd9cd4 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2005,7 +2005,6 @@ evaluate_stmt (gimple *stmt)
case BUILT_IN_BSWAP16:
case BUILT_IN_BSWAP32:
case BUILT_IN_BSWAP64:
- case BUILT_IN_BSWAP128:
val = get_value_for_expr (gimple_call_arg (stmt, 0), true);
if (val.lattice_val == UNDEFINED)
break;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 0e1c86af6..49bfac3c2 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3266,7 +3266,7 @@ vect_get_data_ptr_increment (dr_vec_info *dr_info, tree aggr_type,
return iv_step;
}
-/* Check and perform vectorization of BUILT_IN_BSWAP{16,32,64,128}. */
+/* Check and perform vectorization of BUILT_IN_BSWAP{16,32,64}. */
static bool
vectorizable_bswap (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
@@ -3635,8 +3635,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
else if (modifier == NONE
&& (gimple_call_builtin_p (stmt, BUILT_IN_BSWAP16)
|| gimple_call_builtin_p (stmt, BUILT_IN_BSWAP32)
- || gimple_call_builtin_p (stmt, BUILT_IN_BSWAP64)
- || gimple_call_builtin_p (stmt, BUILT_IN_BSWAP128)))
+ || gimple_call_builtin_p (stmt, BUILT_IN_BSWAP64)))
return vectorizable_bswap (stmt_info, gsi, vec_stmt, slp_node,
vectype_in, cost_vec);
else
diff --git a/gcc/tree.c b/gcc/tree.c
index a61788651..75a191f97 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10392,8 +10392,6 @@ build_common_tree_nodes (bool signed_char)
uint16_type_node = make_or_reuse_type (16, 1);
uint32_type_node = make_or_reuse_type (32, 1);
uint64_type_node = make_or_reuse_type (64, 1);
- if (targetm.scalar_mode_supported_p (TImode))
- uint128_type_node = make_or_reuse_type (128, 1);
/* Decimal float types. */
if (targetm.decimal_float_supported_p ())
diff --git a/gcc/tree.h b/gcc/tree.h
index c66207fa0..792d9c864 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4037,7 +4037,6 @@ tree_strip_any_location_wrapper (tree exp)
#define uint16_type_node global_trees[TI_UINT16_TYPE]
#define uint32_type_node global_trees[TI_UINT32_TYPE]
#define uint64_type_node global_trees[TI_UINT64_TYPE]
-#define uint128_type_node global_trees[TI_UINT128_TYPE]
#define void_node global_trees[TI_VOID]
--
2.33.0
From 2524e0be025dd5c4df4e0ce728a1eec35789de86 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Thu, 24 Oct 2024 21:48:01 +0800
Subject: [PATCH 14/18] Revert "[Backport] phiopt: Optimize (x <=> y) cmp z
[PR94589]"
This reverts commit 02313ab8cf7eb4defc1482ece48c07c2d8c77be9.
---
gcc/testsuite/g++.dg/opt/pr94589-1.C | 33 ---
gcc/testsuite/g++.dg/opt/pr94589-2.C | 33 ---
gcc/testsuite/g++.dg/opt/pr94589-3.C | 84 ------
gcc/testsuite/g++.dg/opt/pr94589-4.C | 84 ------
gcc/testsuite/gcc.dg/pr94589-1.c | 35 ---
gcc/testsuite/gcc.dg/pr94589-2.c | 35 ---
gcc/testsuite/gcc.dg/pr94589-3.c | 97 ------
gcc/testsuite/gcc.dg/pr94589-4.c | 97 ------
gcc/tree-ssa-phiopt.c | 424 ---------------------------
9 files changed, 922 deletions(-)
delete mode 100644 gcc/testsuite/g++.dg/opt/pr94589-1.C
delete mode 100644 gcc/testsuite/g++.dg/opt/pr94589-2.C
delete mode 100644 gcc/testsuite/g++.dg/opt/pr94589-3.C
delete mode 100644 gcc/testsuite/g++.dg/opt/pr94589-4.C
delete mode 100644 gcc/testsuite/gcc.dg/pr94589-1.c
delete mode 100644 gcc/testsuite/gcc.dg/pr94589-2.c
delete mode 100644 gcc/testsuite/gcc.dg/pr94589-3.c
delete mode 100644 gcc/testsuite/gcc.dg/pr94589-4.c
diff --git a/gcc/testsuite/g++.dg/opt/pr94589-1.C b/gcc/testsuite/g++.dg/opt/pr94589-1.C
deleted file mode 100644
index d1cc5050c..000000000
--- a/gcc/testsuite/g++.dg/opt/pr94589-1.C
+++ /dev/null
@@ -1,33 +0,0 @@
-// PR tree-optimization/94589
-// { dg-do compile { target c++20 } }
-// { dg-options "-O2 -g0 -fdump-tree-optimized" }
-// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 12 "optimized" } }
-// { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[45]" 12 "optimized" } }
-
-#include <compare>
-
-#define A __attribute__((noipa))
-A bool f1 (int i, int j) { auto c = i <=> j; return c == 0; }
-A bool f2 (int i, int j) { auto c = i <=> j; return c != 0; }
-A bool f3 (int i, int j) { auto c = i <=> j; return c > 0; }
-A bool f4 (int i, int j) { auto c = i <=> j; return c < 0; }
-A bool f5 (int i, int j) { auto c = i <=> j; return c >= 0; }
-A bool f6 (int i, int j) { auto c = i <=> j; return c <= 0; }
-A bool f7 (int i, int j) { auto c = i <=> j; return c == std::strong_ordering::less; }
-A bool f8 (int i, int j) { auto c = i <=> j; return c != std::strong_ordering::less; }
-A bool f9 (int i, int j) { auto c = i <=> j; return c == std::strong_ordering::equal; }
-A bool f10 (int i, int j) { auto c = i <=> j; return c != std::strong_ordering::equal; }
-A bool f11 (int i, int j) { auto c = i <=> j; return c == std::strong_ordering::greater; }
-A bool f12 (int i, int j) { auto c = i <=> j; return c != std::strong_ordering::greater; }
-A bool f13 (int i) { auto c = i <=> 5; return c == 0; }
-A bool f14 (int i) { auto c = i <=> 5; return c != 0; }
-A bool f15 (int i) { auto c = i <=> 5; return c > 0; }
-A bool f16 (int i) { auto c = i <=> 5; return c < 0; }
-A bool f17 (int i) { auto c = i <=> 5; return c >= 0; }
-A bool f18 (int i) { auto c = i <=> 5; return c <= 0; }
-A bool f19 (int i) { auto c = i <=> 5; return c == std::strong_ordering::less; }
-A bool f20 (int i) { auto c = i <=> 5; return c != std::strong_ordering::less; }
-A bool f21 (int i) { auto c = i <=> 5; return c == std::strong_ordering::equal; }
-A bool f22 (int i) { auto c = i <=> 5; return c != std::strong_ordering::equal; }
-A bool f23 (int i) { auto c = i <=> 5; return c == std::strong_ordering::greater; }
-A bool f24 (int i) { auto c = i <=> 5; return c != std::strong_ordering::greater; }
diff --git a/gcc/testsuite/g++.dg/opt/pr94589-2.C b/gcc/testsuite/g++.dg/opt/pr94589-2.C
deleted file mode 100644
index dda947e22..000000000
--- a/gcc/testsuite/g++.dg/opt/pr94589-2.C
+++ /dev/null
@@ -1,33 +0,0 @@
-// PR tree-optimization/94589
-// { dg-do compile { target c++20 } }
-// { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" }
-// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } }
-// { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 14 "optimized" } }
-
-#include <compare>
-
-#define A __attribute__((noipa))
-A bool f1 (double i, double j) { auto c = i <=> j; return c == 0; }
-A bool f2 (double i, double j) { auto c = i <=> j; return c != 0; }
-A bool f3 (double i, double j) { auto c = i <=> j; return c > 0; }
-A bool f4 (double i, double j) { auto c = i <=> j; return c < 0; }
-A bool f5 (double i, double j) { auto c = i <=> j; return c >= 0; }
-A bool f6 (double i, double j) { auto c = i <=> j; return c <= 0; }
-A bool f7 (double i, double j) { auto c = i <=> j; return c == std::partial_ordering::less; }
-A bool f8 (double i, double j) { auto c = i <=> j; return c != std::partial_ordering::less; }
-A bool f9 (double i, double j) { auto c = i <=> j; return c == std::partial_ordering::equivalent; }
-A bool f10 (double i, double j) { auto c = i <=> j; return c != std::partial_ordering::equivalent; }
-A bool f11 (double i, double j) { auto c = i <=> j; return c == std::partial_ordering::greater; }
-A bool f12 (double i, double j) { auto c = i <=> j; return c != std::partial_ordering::greater; }
-A bool f13 (double i) { auto c = i <=> 5.0; return c == 0; }
-A bool f14 (double i) { auto c = i <=> 5.0; return c != 0; }
-A bool f15 (double i) { auto c = i <=> 5.0; return c > 0; }
-A bool f16 (double i) { auto c = i <=> 5.0; return c < 0; }
-A bool f17 (double i) { auto c = i <=> 5.0; return c >= 0; }
-A bool f18 (double i) { auto c = i <=> 5.0; return c <= 0; }
-A bool f19 (double i) { auto c = i <=> 5.0; return c == std::partial_ordering::less; }
-A bool f20 (double i) { auto c = i <=> 5.0; return c != std::partial_ordering::less; }
-A bool f21 (double i) { auto c = i <=> 5.0; return c == std::partial_ordering::equivalent; }
-A bool f22 (double i) { auto c = i <=> 5.0; return c != std::partial_ordering::equivalent; }
-A bool f23 (double i) { auto c = i <=> 5.0; return c == std::partial_ordering::greater; }
-A bool f24 (double i) { auto c = i <=> 5.0; return c != std::partial_ordering::greater; }
diff --git a/gcc/testsuite/g++.dg/opt/pr94589-3.C b/gcc/testsuite/g++.dg/opt/pr94589-3.C
deleted file mode 100644
index 725b81f56..000000000
--- a/gcc/testsuite/g++.dg/opt/pr94589-3.C
+++ /dev/null
@@ -1,84 +0,0 @@
-// { dg-do run { target c++20 } }
-// { dg-options "-O2 -g" }
-
-#include "pr94589-1.C"
-
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
-
-int
-main ()
-{
- C (f1, 7, 8, false);
- C (f1, 8, 8, true);
- C (f1, 9, 8, false);
- C (f2, 7, 8, true);
- C (f2, 8, 8, false);
- C (f2, 9, 8, true);
- C (f3, 7, 8, false);
- C (f3, 8, 8, false);
- C (f3, 9, 8, true);
- C (f4, 7, 8, true);
- C (f4, 8, 8, false);
- C (f4, 9, 8, false);
- C (f5, 7, 8, false);
- C (f5, 8, 8, true);
- C (f5, 9, 8, true);
- C (f6, 7, 8, true);
- C (f6, 8, 8, true);
- C (f6, 9, 8, false);
- C (f7, 7, 8, true);
- C (f7, 8, 8, false);
- C (f7, 9, 8, false);
- C (f8, 7, 8, false);
- C (f8, 8, 8, true);
- C (f8, 9, 8, true);
- C (f9, 7, 8, false);
- C (f9, 8, 8, true);
- C (f9, 9, 8, false);
- C (f10, 7, 8, true);
- C (f10, 8, 8, false);
- C (f10, 9, 8, true);
- C (f11, 7, 8, false);
- C (f11, 8, 8, false);
- C (f11, 9, 8, true);
- C (f12, 7, 8, true);
- C (f12, 8, 8, true);
- C (f12, 9, 8, false);
- D (f13, 4, false);
- D (f13, 5, true);
- D (f13, 6, false);
- D (f14, 4, true);
- D (f14, 5, false);
- D (f14, 6, true);
- D (f15, 4, false);
- D (f15, 5, false);
- D (f15, 6, true);
- D (f16, 4, true);
- D (f16, 5, false);
- D (f16, 6, false);
- D (f17, 4, false);
- D (f17, 5, true);
- D (f17, 6, true);
- D (f18, 4, true);
- D (f18, 5, true);
- D (f18, 6, false);
- D (f19, 4, true);
- D (f19, 5, false);
- D (f19, 6, false);
- D (f20, 4, false);
- D (f20, 5, true);
- D (f20, 6, true);
- D (f21, 4, false);
- D (f21, 5, true);
- D (f21, 6, false);
- D (f22, 4, true);
- D (f22, 5, false);
- D (f22, 6, true);
- D (f23, 4, false);
- D (f23, 5, false);
- D (f23, 6, true);
- D (f24, 4, true);
- D (f24, 5, true);
- D (f24, 6, false);
-}
diff --git a/gcc/testsuite/g++.dg/opt/pr94589-4.C b/gcc/testsuite/g++.dg/opt/pr94589-4.C
deleted file mode 100644
index 256a45580..000000000
--- a/gcc/testsuite/g++.dg/opt/pr94589-4.C
+++ /dev/null
@@ -1,84 +0,0 @@
-// { dg-do run { target c++20 } }
-// { dg-options "-O2 -g -ffast-math" }
-
-#include "pr94589-2.C"
-
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
-
-int
-main ()
-{
- C (f1, 7.0, 8.0, false);
- C (f1, 8.0, 8.0, true);
- C (f1, 9.0, 8.0, false);
- C (f2, 7.0, 8.0, true);
- C (f2, 8.0, 8.0, false);
- C (f2, 9.0, 8.0, true);
- C (f3, 7.0, 8.0, false);
- C (f3, 8.0, 8.0, false);
- C (f3, 9.0, 8.0, true);
- C (f4, 7.0, 8.0, true);
- C (f4, 8.0, 8.0, false);
- C (f4, 9.0, 8.0, false);
- C (f5, 7.0, 8.0, false);
- C (f5, 8.0, 8.0, true);
- C (f5, 9.0, 8.0, true);
- C (f6, 7.0, 8.0, true);
- C (f6, 8.0, 8.0, true);
- C (f6, 9.0, 8.0, false);
- C (f7, 7.0, 8.0, true);
- C (f7, 8.0, 8.0, false);
- C (f7, 9.0, 8.0, false);
- C (f8, 7.0, 8.0, false);
- C (f8, 8.0, 8.0, true);
- C (f8, 9.0, 8.0, true);
- C (f9, 7.0, 8.0, false);
- C (f9, 8.0, 8.0, true);
- C (f9, 9.0, 8.0, false);
- C (f10, 7.0, 8.0, true);
- C (f10, 8.0, 8.0, false);
- C (f10, 9.0, 8.0, true);
- C (f11, 7.0, 8.0, false);
- C (f11, 8.0, 8.0, false);
- C (f11, 9.0, 8.0, true);
- C (f12, 7.0, 8.0, true);
- C (f12, 8.0, 8.0, true);
- C (f12, 9.0, 8.0, false);
- D (f13, 4.0, false);
- D (f13, 5.0, true);
- D (f13, 6.0, false);
- D (f14, 4.0, true);
- D (f14, 5.0, false);
- D (f14, 6.0, true);
- D (f15, 4.0, false);
- D (f15, 5.0, false);
- D (f15, 6.0, true);
- D (f16, 4.0, true);
- D (f16, 5.0, false);
- D (f16, 6.0, false);
- D (f17, 4.0, false);
- D (f17, 5.0, true);
- D (f17, 6.0, true);
- D (f18, 4.0, true);
- D (f18, 5.0, true);
- D (f18, 6.0, false);
- D (f19, 4.0, true);
- D (f19, 5.0, false);
- D (f19, 6.0, false);
- D (f20, 4.0, false);
- D (f20, 5.0, true);
- D (f20, 6.0, true);
- D (f21, 4.0, false);
- D (f21, 5.0, true);
- D (f21, 6.0, false);
- D (f22, 4.0, true);
- D (f22, 5.0, false);
- D (f22, 6.0, true);
- D (f23, 4.0, false);
- D (f23, 5.0, false);
- D (f23, 6.0, true);
- D (f24, 4.0, true);
- D (f24, 5.0, true);
- D (f24, 6.0, false);
-}
diff --git a/gcc/testsuite/gcc.dg/pr94589-1.c b/gcc/testsuite/gcc.dg/pr94589-1.c
deleted file mode 100644
index de404ea82..000000000
--- a/gcc/testsuite/gcc.dg/pr94589-1.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* PR tree-optimization/94589 */
-/* { dg-do compile } */
-/* { dg-options "-O2 -g0 -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[45]" 14 "optimized" } } */
-
-#define A __attribute__((noipa))
-A int f1 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 0; }
-A int f2 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 0; }
-A int f3 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > 0; }
-A int f4 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 0; }
-A int f5 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 0; }
-A int f6 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= 0; }
-A int f7 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == -1; }
-A int f8 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != -1; }
-A int f9 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c > -1; }
-A int f10 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c <= -1; }
-A int f11 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c == 1; }
-A int f12 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c != 1; }
-A int f13 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c < 1; }
-A int f14 (int i, int j) { int c = i == j ? 0 : i < j ? -1 : 1; return c >= 1; }
-A int f15 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 0; }
-A int f16 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 0; }
-A int f17 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > 0; }
-A int f18 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 0; }
-A int f19 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 0; }
-A int f20 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= 0; }
-A int f21 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == -1; }
-A int f22 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != -1; }
-A int f23 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c > -1; }
-A int f24 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c <= -1; }
-A int f25 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c == 1; }
-A int f26 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c != 1; }
-A int f27 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c < 1; }
-A int f28 (int i) { int c = i == 5 ? 0 : i < 5 ? -1 : 1; return c >= 1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-2.c b/gcc/testsuite/gcc.dg/pr94589-2.c
deleted file mode 100644
index 9481b764d..000000000
--- a/gcc/testsuite/gcc.dg/pr94589-2.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* PR tree-optimization/94589 */
-/* { dg-do compile } */
-/* { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 14 "optimized" } } */
-
-#define A __attribute__((noipa))
-A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; }
-A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; }
-A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; }
-A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; }
-A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; }
-A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; }
-A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; }
-A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; }
-A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; }
-A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; }
-A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; }
-A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; }
-A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; }
-A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; }
-A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; }
-A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; }
-A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; }
-A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; }
-A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; }
-A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; }
-A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; }
-A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; }
-A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; }
-A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; }
-A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; }
-A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; }
-A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; }
-A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-3.c b/gcc/testsuite/gcc.dg/pr94589-3.c
deleted file mode 100644
index df82fab73..000000000
--- a/gcc/testsuite/gcc.dg/pr94589-3.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* { dg-do run } */
-/* { dg-options "-O2 -g" } */
-
-#include "pr94589-1.c"
-
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
-
-int
-main ()
-{
- C (f1, 7, 8, 0);
- C (f1, 8, 8, 1);
- C (f1, 9, 8, 0);
- C (f2, 7, 8, 1);
- C (f2, 8, 8, 0);
- C (f2, 9, 8, 1);
- C (f3, 7, 8, 0);
- C (f3, 8, 8, 0);
- C (f3, 9, 8, 1);
- C (f4, 7, 8, 1);
- C (f4, 8, 8, 0);
- C (f4, 9, 8, 0);
- C (f5, 7, 8, 0);
- C (f5, 8, 8, 1);
- C (f5, 9, 8, 1);
- C (f6, 7, 8, 1);
- C (f6, 8, 8, 1);
- C (f6, 9, 8, 0);
- C (f7, 7, 8, 1);
- C (f7, 8, 8, 0);
- C (f7, 9, 8, 0);
- C (f8, 7, 8, 0);
- C (f8, 8, 8, 1);
- C (f8, 9, 8, 1);
- C (f9, 7, 8, 0);
- C (f9, 8, 8, 1);
- C (f9, 9, 8, 1);
- C (f10, 7, 8, 1);
- C (f10, 8, 8, 0);
- C (f10, 9, 8, 0);
- C (f11, 7, 8, 0);
- C (f11, 8, 8, 0);
- C (f11, 9, 8, 1);
- C (f12, 7, 8, 1);
- C (f12, 8, 8, 1);
- C (f12, 9, 8, 0);
- C (f13, 7, 8, 1);
- C (f13, 8, 8, 1);
- C (f13, 9, 8, 0);
- C (f14, 7, 8, 0);
- C (f14, 8, 8, 0);
- C (f14, 9, 8, 1);
- D (f15, 4, 0);
- D (f15, 5, 1);
- D (f15, 6, 0);
- D (f16, 4, 1);
- D (f16, 5, 0);
- D (f16, 6, 1);
- D (f17, 4, 0);
- D (f17, 5, 0);
- D (f17, 6, 1);
- D (f18, 4, 1);
- D (f18, 5, 0);
- D (f18, 6, 0);
- D (f19, 4, 0);
- D (f19, 5, 1);
- D (f19, 6, 1);
- D (f20, 4, 1);
- D (f20, 5, 1);
- D (f20, 6, 0);
- D (f21, 4, 1);
- D (f21, 5, 0);
- D (f21, 6, 0);
- D (f22, 4, 0);
- D (f22, 5, 1);
- D (f22, 6, 1);
- D (f23, 4, 0);
- D (f23, 5, 1);
- D (f23, 6, 1);
- D (f24, 4, 1);
- D (f24, 5, 0);
- D (f24, 6, 0);
- D (f25, 4, 0);
- D (f25, 5, 0);
- D (f25, 6, 1);
- D (f26, 4, 1);
- D (f26, 5, 1);
- D (f26, 6, 0);
- D (f27, 4, 1);
- D (f27, 5, 1);
- D (f27, 6, 0);
- D (f28, 4, 0);
- D (f28, 5, 0);
- D (f28, 6, 1);
- return 0;
-}
diff --git a/gcc/testsuite/gcc.dg/pr94589-4.c b/gcc/testsuite/gcc.dg/pr94589-4.c
deleted file mode 100644
index b2557fb07..000000000
--- a/gcc/testsuite/gcc.dg/pr94589-4.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* { dg-do run } */
-/* { dg-options "-O2 -g -ffast-math" } */
-
-#include "pr94589-2.c"
-
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
-
-int
-main ()
-{
- C (f1, 7.0, 8.0, 0);
- C (f1, 8.0, 8.0, 1);
- C (f1, 9.0, 8.0, 0);
- C (f2, 7.0, 8.0, 1);
- C (f2, 8.0, 8.0, 0);
- C (f2, 9.0, 8.0, 1);
- C (f3, 7.0, 8.0, 0);
- C (f3, 8.0, 8.0, 0);
- C (f3, 9.0, 8.0, 1);
- C (f4, 7.0, 8.0, 1);
- C (f4, 8.0, 8.0, 0);
- C (f4, 9.0, 8.0, 0);
- C (f5, 7.0, 8.0, 0);
- C (f5, 8.0, 8.0, 1);
- C (f5, 9.0, 8.0, 1);
- C (f6, 7.0, 8.0, 1);
- C (f6, 8.0, 8.0, 1);
- C (f6, 9.0, 8.0, 0);
- C (f7, 7.0, 8.0, 1);
- C (f7, 8.0, 8.0, 0);
- C (f7, 9.0, 8.0, 0);
- C (f8, 7.0, 8.0, 0);
- C (f8, 8.0, 8.0, 1);
- C (f8, 9.0, 8.0, 1);
- C (f9, 7.0, 8.0, 0);
- C (f9, 8.0, 8.0, 1);
- C (f9, 9.0, 8.0, 1);
- C (f10, 7.0, 8.0, 1);
- C (f10, 8.0, 8.0, 0);
- C (f10, 9.0, 8.0, 0);
- C (f11, 7.0, 8.0, 0);
- C (f11, 8.0, 8.0, 0);
- C (f11, 9.0, 8.0, 1);
- C (f12, 7.0, 8.0, 1);
- C (f12, 8.0, 8.0, 1);
- C (f12, 9.0, 8.0, 0);
- C (f13, 7.0, 8.0, 1);
- C (f13, 8.0, 8.0, 1);
- C (f13, 9.0, 8.0, 0);
- C (f14, 7.0, 8.0, 0);
- C (f14, 8.0, 8.0, 0);
- C (f14, 9.0, 8.0, 1);
- D (f15, 4.0, 0);
- D (f15, 5.0, 1);
- D (f15, 6.0, 0);
- D (f16, 4.0, 1);
- D (f16, 5.0, 0);
- D (f16, 6.0, 1);
- D (f17, 4.0, 0);
- D (f17, 5.0, 0);
- D (f17, 6.0, 1);
- D (f18, 4.0, 1);
- D (f18, 5.0, 0);
- D (f18, 6.0, 0);
- D (f19, 4.0, 0);
- D (f19, 5.0, 1);
- D (f19, 6.0, 1);
- D (f20, 4.0, 1);
- D (f20, 5.0, 1);
- D (f20, 6.0, 0);
- D (f21, 4.0, 1);
- D (f21, 5.0, 0);
- D (f21, 6.0, 0);
- D (f22, 4.0, 0);
- D (f22, 5.0, 1);
- D (f22, 6.0, 1);
- D (f23, 4.0, 0);
- D (f23, 5.0, 1);
- D (f23, 6.0, 1);
- D (f24, 4.0, 1);
- D (f24, 5.0, 0);
- D (f24, 6.0, 0);
- D (f25, 4.0, 0);
- D (f25, 5.0, 0);
- D (f25, 6.0, 1);
- D (f26, 4.0, 1);
- D (f26, 5.0, 1);
- D (f26, 6.0, 0);
- D (f27, 4.0, 1);
- D (f27, 5.0, 1);
- D (f27, 6.0, 0);
- D (f28, 4.0, 0);
- D (f28, 5.0, 0);
- D (f28, 6.0, 1);
- return 0;
-}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 9e72f2709..ca681db3e 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -63,8 +63,6 @@ static bool minmax_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
static bool abs_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
-static bool spaceship_replacement (basic_block, basic_block,
- edge, edge, gphi *, tree, tree);
static bool cond_removal_in_popcount_clz_ctz_pattern (basic_block, basic_block,
edge, edge, gphi *,
tree, tree);
@@ -360,8 +358,6 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
cfgchanged = true;
else if (minmax_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
- else if (spaceship_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
- cfgchanged = true;
}
}
@@ -1733,426 +1729,6 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
return true;
}
-/* Return true if the only executable statement in BB is a GIMPLE_COND. */
-
-static bool
-cond_only_block_p (basic_block bb)
-{
- /* BB must have no executable statements. */
- gimple_stmt_iterator gsi = gsi_after_labels (bb);
- if (phi_nodes (bb))
- return false;
- while (!gsi_end_p (gsi))
- {
- gimple *stmt = gsi_stmt (gsi);
- if (is_gimple_debug (stmt))
- ;
- else if (gimple_code (stmt) == GIMPLE_NOP
- || gimple_code (stmt) == GIMPLE_PREDICT
- || gimple_code (stmt) == GIMPLE_COND)
- ;
- else
- return false;
- gsi_next (&gsi);
- }
- return true;
-}
-
-/* Attempt to optimize (x <=> y) cmp 0 and similar comparisons.
- For strong ordering <=> try to match something like:
- <bb 2> : // cond3_bb (== cond2_bb)
- if (x_4(D) != y_5(D))
- goto <bb 3>; [INV]
- else
- goto <bb 6>; [INV]
-
- <bb 3> : // cond_bb
- if (x_4(D) < y_5(D))
- goto <bb 6>; [INV]
- else
- goto <bb 4>; [INV]
-
- <bb 4> : // middle_bb
-
- <bb 6> : // phi_bb
- # iftmp.0_2 = PHI <1(4), 0(2), -1(3)>
- _1 = iftmp.0_2 == 0;
-
- and for partial ordering <=> something like:
-
- <bb 2> : // cond3_bb
- if (a_3(D) == b_5(D))
- goto <bb 6>; [50.00%]
- else
- goto <bb 3>; [50.00%]
-
- <bb 3> [local count: 536870913]: // cond2_bb
- if (a_3(D) < b_5(D))
- goto <bb 6>; [50.00%]
- else
- goto <bb 4>; [50.00%]
-
- <bb 4> [local count: 268435456]: // cond_bb
- if (a_3(D) > b_5(D))
- goto <bb 6>; [50.00%]
- else
- goto <bb 5>; [50.00%]
-
- <bb 5> [local count: 134217728]: // middle_bb
-
- <bb 6> [local count: 1073741824]: // phi_bb
- # SR.27_4 = PHI <0(2), -1(3), 1(4), 2(5)>
- _2 = SR.27_4 > 0; */
-
-static bool
-spaceship_replacement (basic_block cond_bb, basic_block middle_bb,
- edge e0, edge e1, gphi *phi,
- tree arg0, tree arg1)
-{
- if (!INTEGRAL_TYPE_P (TREE_TYPE (PHI_RESULT (phi)))
- || TYPE_UNSIGNED (TREE_TYPE (PHI_RESULT (phi)))
- || !tree_fits_shwi_p (arg0)
- || !tree_fits_shwi_p (arg1)
- || !IN_RANGE (tree_to_shwi (arg0), -1, 2)
- || !IN_RANGE (tree_to_shwi (arg1), -1, 2))
- return false;
-
- basic_block phi_bb = gimple_bb (phi);
- gcc_assert (phi_bb == e0->dest && phi_bb == e1->dest);
- if (!IN_RANGE (EDGE_COUNT (phi_bb->preds), 3, 4))
- return false;
-
- use_operand_p use_p;
- gimple *use_stmt;
- if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (PHI_RESULT (phi)))
- return false;
- if (!single_imm_use (PHI_RESULT (phi), &use_p, &use_stmt))
- return false;
- enum tree_code cmp;
- tree lhs, rhs;
- if (gimple_code (use_stmt) == GIMPLE_COND)
- {
- cmp = gimple_cond_code (use_stmt);
- lhs = gimple_cond_lhs (use_stmt);
- rhs = gimple_cond_rhs (use_stmt);
- }
- else if (is_gimple_assign (use_stmt))
- {
- if (gimple_assign_rhs_class (use_stmt) == GIMPLE_BINARY_RHS)
- {
- cmp = gimple_assign_rhs_code (use_stmt);
- lhs = gimple_assign_rhs1 (use_stmt);
- rhs = gimple_assign_rhs2 (use_stmt);
- }
- else if (gimple_assign_rhs_code (use_stmt) == COND_EXPR)
- {
- tree cond = gimple_assign_rhs1 (use_stmt);
- if (!COMPARISON_CLASS_P (cond))
- return false;
- cmp = TREE_CODE (cond);
- lhs = TREE_OPERAND (cond, 0);
- rhs = TREE_OPERAND (cond, 1);
- }
- else
- return false;
- }
- else
- return false;
- switch (cmp)
- {
- case EQ_EXPR:
- case NE_EXPR:
- case LT_EXPR:
- case GT_EXPR:
- case LE_EXPR:
- case GE_EXPR:
- break;
- default:
- return false;
- }
- if (lhs != PHI_RESULT (phi)
- || !tree_fits_shwi_p (rhs)
- || !IN_RANGE (tree_to_shwi (rhs), -1, 1))
- return false;
-
- if (!empty_block_p (middle_bb))
- return false;
-
- gcond *cond1 = as_a <gcond *> (last_stmt (cond_bb));
- enum tree_code cmp1 = gimple_cond_code (cond1);
- if (cmp1 != LT_EXPR && cmp1 != GT_EXPR)
- return false;
- tree lhs1 = gimple_cond_lhs (cond1);
- tree rhs1 = gimple_cond_rhs (cond1);
- /* The optimization may be unsafe due to NaNs. */
- if (HONOR_NANS (TREE_TYPE (lhs1)))
- return false;
- if (TREE_CODE (lhs1) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs1))
- return false;
- if (TREE_CODE (rhs1) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1))
- return false;
-
- if (!single_pred_p (cond_bb) || !cond_only_block_p (cond_bb))
- return false;
-
- basic_block cond2_bb = single_pred (cond_bb);
- if (EDGE_COUNT (cond2_bb->succs) != 2)
- return false;
- edge cond2_phi_edge;
- if (EDGE_SUCC (cond2_bb, 0)->dest == cond_bb)
- {
- if (EDGE_SUCC (cond2_bb, 1)->dest != phi_bb)
- return false;
- cond2_phi_edge = EDGE_SUCC (cond2_bb, 1);
- }
- else if (EDGE_SUCC (cond2_bb, 0)->dest != phi_bb)
- return false;
- else
- cond2_phi_edge = EDGE_SUCC (cond2_bb, 0);
- tree arg2 = gimple_phi_arg_def (phi, cond2_phi_edge->dest_idx);
- if (!tree_fits_shwi_p (arg2))
- return false;
- gimple *cond2 = last_stmt (cond2_bb);
- if (cond2 == NULL || gimple_code (cond2) != GIMPLE_COND)
- return false;
- enum tree_code cmp2 = gimple_cond_code (cond2);
- tree lhs2 = gimple_cond_lhs (cond2);
- tree rhs2 = gimple_cond_rhs (cond2);
- if (lhs2 == lhs1)
- {
- if (!operand_equal_p (rhs2, rhs1, 0))
- return false;
- }
- else if (lhs2 == rhs1)
- {
- if (rhs2 != lhs1)
- return false;
- }
- else
- return false;
-
- tree arg3 = arg2;
- basic_block cond3_bb = cond2_bb;
- edge cond3_phi_edge = cond2_phi_edge;
- gimple *cond3 = cond2;
- enum tree_code cmp3 = cmp2;
- tree lhs3 = lhs2;
- tree rhs3 = rhs2;
- if (EDGE_COUNT (phi_bb->preds) == 4)
- {
- if (absu_hwi (tree_to_shwi (arg2)) != 1)
- return false;
- if (e1->flags & EDGE_TRUE_VALUE)
- {
- if (tree_to_shwi (arg0) != 2
- || absu_hwi (tree_to_shwi (arg1)) != 1
- || wi::to_widest (arg1) == wi::to_widest (arg2))
- return false;
- }
- else if (tree_to_shwi (arg1) != 2
- || absu_hwi (tree_to_shwi (arg0)) != 1
- || wi::to_widest (arg0) == wi::to_widest (arg1))
- return false;
- if (cmp2 != LT_EXPR && cmp2 != GT_EXPR)
- return false;
- /* if (x < y) goto phi_bb; else fallthru;
- if (x > y) goto phi_bb; else fallthru;
- bbx:;
- phi_bb:;
- is ok, but if x and y are swapped in one of the comparisons,
- or the comparisons are the same and operands not swapped,
- or second goto phi_bb is not the true edge, it is not. */
- if ((lhs2 == lhs1)
- ^ (cmp2 == cmp1)
- ^ ((e1->flags & EDGE_TRUE_VALUE) != 0))
- return false;
- if ((cond2_phi_edge->flags & EDGE_TRUE_VALUE) == 0)
- return false;
- if (!single_pred_p (cond2_bb) || !cond_only_block_p (cond2_bb))
- return false;
- cond3_bb = single_pred (cond2_bb);
- if (EDGE_COUNT (cond2_bb->succs) != 2)
- return false;
- if (EDGE_SUCC (cond3_bb, 0)->dest == cond2_bb)
- {
- if (EDGE_SUCC (cond3_bb, 1)->dest != phi_bb)
- return false;
- cond3_phi_edge = EDGE_SUCC (cond3_bb, 1);
- }
- else if (EDGE_SUCC (cond3_bb, 0)->dest != phi_bb)
- return false;
- else
- cond3_phi_edge = EDGE_SUCC (cond3_bb, 0);
- arg3 = gimple_phi_arg_def (phi, cond3_phi_edge->dest_idx);
- cond3 = last_stmt (cond3_bb);
- if (cond3 == NULL || gimple_code (cond3) != GIMPLE_COND)
- return false;
- cmp3 = gimple_cond_code (cond3);
- lhs3 = gimple_cond_lhs (cond3);
- rhs3 = gimple_cond_rhs (cond3);
- if (lhs3 == lhs1)
- {
- if (!operand_equal_p (rhs3, rhs1, 0))
- return false;
- }
- else if (lhs3 == rhs1)
- {
- if (rhs3 != lhs1)
- return false;
- }
- else
- return false;
- }
- else if (absu_hwi (tree_to_shwi (arg0)) != 1
- || absu_hwi (tree_to_shwi (arg1)) != 1
- || wi::to_widest (arg0) == wi::to_widest (arg1))
- return false;
-
- if (!integer_zerop (arg3) || (cmp3 != EQ_EXPR && cmp3 != NE_EXPR))
- return false;
- if ((cond3_phi_edge->flags & (cmp3 == EQ_EXPR
- ? EDGE_TRUE_VALUE : EDGE_FALSE_VALUE)) == 0)
- return false;
-
- /* lhs1 one_cmp rhs1 results in PHI_RESULT (phi) of 1. */
- enum tree_code one_cmp;
- if ((cmp1 == LT_EXPR)
- ^ (!integer_onep ((e1->flags & EDGE_TRUE_VALUE) ? arg1 : arg0)))
- one_cmp = LT_EXPR;
- else
- one_cmp = GT_EXPR;
-
- enum tree_code res_cmp;
- switch (cmp)
- {
- case EQ_EXPR:
- if (integer_zerop (rhs))
- res_cmp = EQ_EXPR;
- else if (integer_minus_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? GT_EXPR : LT_EXPR;
- else if (integer_onep (rhs))
- res_cmp = one_cmp;
- else
- return false;
- break;
- case NE_EXPR:
- if (integer_zerop (rhs))
- res_cmp = NE_EXPR;
- else if (integer_minus_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? LE_EXPR : GE_EXPR;
- else if (integer_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? GE_EXPR : LE_EXPR;
- else
- return false;
- break;
- case LT_EXPR:
- if (integer_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? GE_EXPR : LE_EXPR;
- else if (integer_zerop (rhs))
- res_cmp = one_cmp == LT_EXPR ? GT_EXPR : LT_EXPR;
- else
- return false;
- break;
- case LE_EXPR:
- if (integer_zerop (rhs))
- res_cmp = one_cmp == LT_EXPR ? GE_EXPR : LE_EXPR;
- else if (integer_minus_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? GT_EXPR : LT_EXPR;
- else
- return false;
- break;
- case GT_EXPR:
- if (integer_minus_onep (rhs))
- res_cmp = one_cmp == LT_EXPR ? LE_EXPR : GE_EXPR;
- else if (integer_zerop (rhs))
- res_cmp = one_cmp;
- else
- return false;
- break;
- case GE_EXPR:
- if (integer_zerop (rhs))
- res_cmp = one_cmp == LT_EXPR ? LE_EXPR : GE_EXPR;
- else if (integer_onep (rhs))
- res_cmp = one_cmp;
- else
- return false;
- break;
- default:
- gcc_unreachable ();
- }
-
- if (gimple_code (use_stmt) == GIMPLE_COND)
- {
- gcond *use_cond = as_a <gcond *> (use_stmt);
- gimple_cond_set_code (use_cond, res_cmp);
- gimple_cond_set_lhs (use_cond, lhs1);
- gimple_cond_set_rhs (use_cond, rhs1);
- }
- else if (gimple_assign_rhs_class (use_stmt) == GIMPLE_BINARY_RHS)
- {
- gimple_assign_set_rhs_code (use_stmt, res_cmp);
- gimple_assign_set_rhs1 (use_stmt, lhs1);
- gimple_assign_set_rhs2 (use_stmt, rhs1);
- }
- else
- {
- tree cond = build2 (res_cmp, TREE_TYPE (gimple_assign_rhs1 (use_stmt)),
- lhs1, rhs1);
- gimple_assign_set_rhs1 (use_stmt, cond);
- }
- update_stmt (use_stmt);
-
- if (MAY_HAVE_DEBUG_BIND_STMTS)
- {
- use_operand_p use_p;
- imm_use_iterator iter;
- bool has_debug_uses = false;
- FOR_EACH_IMM_USE_FAST (use_p, iter, PHI_RESULT (phi))
- {
- gimple *use_stmt = USE_STMT (use_p);
- gcc_assert (is_gimple_debug (use_stmt));
- has_debug_uses = true;
- break;
- }
-
- if (has_debug_uses)
- {
- /* If there are debug uses, emit something like:
- # DEBUG D#1 => i_2(D) > j_3(D) ? 1 : -1
- # DEBUG D#2 => i_2(D) == j_3(D) ? 0 : D#1
- where > stands for the comparison that yielded 1
- and replace debug uses of phi result with that D#2.
- Ignore the value of 2, because if NaNs aren't expected,
- all floating point numbers should be comparable. */
- gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (phi));
- tree type = TREE_TYPE (PHI_RESULT (phi));
- tree temp1 = make_node (DEBUG_EXPR_DECL);
- DECL_ARTIFICIAL (temp1) = 1;
- TREE_TYPE (temp1) = type;
- SET_DECL_MODE (temp1, TYPE_MODE (type));
- tree t = build2 (one_cmp, boolean_type_node, lhs1, rhs2);
- t = build3 (COND_EXPR, type, t, build_one_cst (type),
- build_int_cst (type, -1));
- gimple *g = gimple_build_debug_bind (temp1, t, phi);
- gsi_insert_before (&gsi, g, GSI_SAME_STMT);
- tree temp2 = make_node (DEBUG_EXPR_DECL);
- DECL_ARTIFICIAL (temp2) = 1;
- TREE_TYPE (temp2) = type;
- SET_DECL_MODE (temp2, TYPE_MODE (type));
- t = build2 (EQ_EXPR, boolean_type_node, lhs1, rhs2);
- t = build3 (COND_EXPR, type, t, build_zero_cst (type), temp1);
- g = gimple_build_debug_bind (temp2, t, phi);
- gsi_insert_before (&gsi, g, GSI_SAME_STMT);
- replace_uses_by (PHI_RESULT (phi), temp2);
- }
- }
-
- gimple_stmt_iterator psi = gsi_for_stmt (phi);
- remove_phi_node (&psi, true);
-
- return true;
-}
-
/* Convert
<bb 2>
--
2.33.0
From d10a1e5d77e50c900b07a5ff5a79863fac398194 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Fri, 25 Oct 2024 16:33:43 +0800
Subject: [PATCH 15/18] Revert "[Backport] phiopt: Optimize x ? __builtin_clz
(x) : 32 in GIMPLE fallout [PR97503]"
This reverts commit 7d5d2ab082ce9986db4f3313013b44faa46bc412.
---
gcc/tree-ssa-phiopt.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index ca681db3e..35c22fa29 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1817,10 +1817,10 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
CASE_CFN_CLZ:
if (INTEGRAL_TYPE_P (TREE_TYPE (arg)))
{
- tree type = TREE_TYPE (arg);
- if (direct_internal_fn_supported_p (IFN_CLZ, type, OPTIMIZE_FOR_BOTH)
- && CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (type),
- val) == 2)
+ scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
+ if (direct_internal_fn_supported_p (IFN_CLZ, TREE_TYPE (arg),
+ OPTIMIZE_FOR_BOTH)
+ && CLZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
{
ifn = IFN_CLZ;
break;
@@ -1830,10 +1830,10 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
CASE_CFN_CTZ:
if (INTEGRAL_TYPE_P (TREE_TYPE (arg)))
{
- tree type = TREE_TYPE (arg);
- if (direct_internal_fn_supported_p (IFN_CTZ, type, OPTIMIZE_FOR_BOTH)
- && CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (type),
- val) == 2)
+ scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
+ if (direct_internal_fn_supported_p (IFN_CTZ, TREE_TYPE (arg),
+ OPTIMIZE_FOR_BOTH)
+ && CTZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
{
ifn = IFN_CTZ;
break;
--
2.33.0
From eb5d68427d4cb54ea2ed6d9bfd820d23a4fce0f3 Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Fri, 25 Oct 2024 16:46:02 +0800
Subject: [PATCH 16/18] Revert "[Backport] phiopt: Optimize x ? __builtin_clz
(x) : 32 in GIMPLE [PR97503]"
This reverts commit a92cf465f10585350f7cd5739457c3f2852cfc86.
---
gcc/testsuite/gcc.dg/tree-ssa/pr97503.c | 19 -----
gcc/tree-ssa-phiopt.c | 100 ++++++------------------
2 files changed, 24 insertions(+), 95 deletions(-)
delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97503.c
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97503.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97503.c
deleted file mode 100644
index 3a3dae6c7..000000000
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr97503.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* PR tree-optimization/97503 */
-/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
-/* { dg-additional-options "-mbmi -mlzcnt" { target i?86-*-* x86_64-*-* } } */
-/* { dg-final { scan-tree-dump-times "\.CLZ" 2 "optimized" { target { { i?86-*-* x86_64-*-* aarch64-*-* powerpc*-*-* } && lp64 } } } } */
-/* { dg-final { scan-tree-dump-not "__builtin_clz" "optimized" { target { { i?86-*-* x86_64-*-* aarch64-*-* powerpc*-*-*} && lp64 } } } } */
-/* { dg-final { scan-tree-dump-not "PHI <" "optimized" { target { { i?86-*-* x86_64-*-* aarch64-*-* powerpc*-*-*} && lp64 } } } } */
-
-int
-foo (int x)
-{
- return x ? __builtin_clz (x) : 32;
-}
-
-int
-bar (unsigned long long x)
-{
- return x ? __builtin_clzll (x) : 64;
-}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index 35c22fa29..3cf9f77c4 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -48,7 +48,6 @@ along with GCC; see the file COPYING3. If not see
#include "case-cfn-macros.h"
#include "tree-eh.h"
#include "gimple-fold.h"
-#include "internal-fn.h"
static unsigned int tree_ssa_phiopt_worker (bool, bool, bool);
static bool two_value_replacement (basic_block, basic_block, edge, gphi *,
@@ -63,9 +62,8 @@ static bool minmax_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
static bool abs_replacement (basic_block, basic_block,
edge, edge, gphi *, tree, tree);
-static bool cond_removal_in_popcount_clz_ctz_pattern (basic_block, basic_block,
- edge, edge, gphi *,
- tree, tree);
+static bool cond_removal_in_popcount_pattern (basic_block, basic_block,
+ edge, edge, gphi *, tree, tree);
static bool cond_store_replacement (basic_block, basic_block, edge, edge,
hash_set<tree> *);
static bool cond_if_else_store_replacement (basic_block, basic_block, basic_block);
@@ -352,9 +350,8 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
else if (abs_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
else if (!early_p
- && cond_removal_in_popcount_clz_ctz_pattern (bb, bb1, e1,
- e2, phi, arg0,
- arg1))
+ && cond_removal_in_popcount_pattern (bb, bb1, e1, e2,
+ phi, arg0, arg1))
cfgchanged = true;
else if (minmax_replacement (bb, bb1, e1, e2, phi, arg0, arg1))
cfgchanged = true;
@@ -1755,20 +1752,16 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
<bb 4>
c_12 = PHI <_9(2)>
-
- Similarly for __builtin_clz or __builtin_ctz if
- C?Z_DEFINED_VALUE_AT_ZERO is 2, optab is present and
- instead of 0 above it uses the value from that macro. */
+*/
static bool
-cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
- basic_block middle_bb,
- edge e1, edge e2, gphi *phi,
- tree arg0, tree arg1)
+cond_removal_in_popcount_pattern (basic_block cond_bb, basic_block middle_bb,
+ edge e1, edge e2,
+ gphi *phi, tree arg0, tree arg1)
{
gimple *cond;
gimple_stmt_iterator gsi, gsi_from;
- gimple *call;
+ gimple *popcount;
gimple *cast = NULL;
tree lhs, arg;
@@ -1786,67 +1779,35 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
gsi_next_nondebug (&gsi);
if (!gsi_end_p (gsi))
{
- call = gsi_stmt (gsi);
+ popcount = gsi_stmt (gsi);
gsi_next_nondebug (&gsi);
if (!gsi_end_p (gsi))
return false;
}
else
{
- call = cast;
+ popcount = cast;
cast = NULL;
}
- /* Check that we have a popcount/clz/ctz builtin. */
- if (!is_gimple_call (call) || gimple_call_num_args (call) != 1)
- return false;
-
- arg = gimple_call_arg (call, 0);
- lhs = gimple_get_lhs (call);
-
- if (lhs == NULL_TREE)
+ /* Check that we have a popcount builtin. */
+ if (!is_gimple_call (popcount))
return false;
-
- combined_fn cfn = gimple_call_combined_fn (call);
- internal_fn ifn = IFN_LAST;
- int val = 0;
+ combined_fn cfn = gimple_call_combined_fn (popcount);
switch (cfn)
{
CASE_CFN_POPCOUNT:
break;
- CASE_CFN_CLZ:
- if (INTEGRAL_TYPE_P (TREE_TYPE (arg)))
- {
- scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
- if (direct_internal_fn_supported_p (IFN_CLZ, TREE_TYPE (arg),
- OPTIMIZE_FOR_BOTH)
- && CLZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
- {
- ifn = IFN_CLZ;
- break;
- }
- }
- return false;
- CASE_CFN_CTZ:
- if (INTEGRAL_TYPE_P (TREE_TYPE (arg)))
- {
- scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
- if (direct_internal_fn_supported_p (IFN_CTZ, TREE_TYPE (arg),
- OPTIMIZE_FOR_BOTH)
- && CTZ_DEFINED_VALUE_AT_ZERO (mode, val) == 2)
- {
- ifn = IFN_CTZ;
- break;
- }
- }
- return false;
default:
return false;
}
+ arg = gimple_call_arg (popcount, 0);
+ lhs = gimple_get_lhs (popcount);
+
if (cast)
{
- /* We have a cast stmt feeding popcount/clz/ctz builtin. */
+ /* We have a cast stmt feeding popcount builtin. */
/* Check that we have a cast prior to that. */
if (gimple_code (cast) != GIMPLE_ASSIGN
|| !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (cast)))
@@ -1859,7 +1820,7 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
cond = last_stmt (cond_bb);
- /* Cond_bb has a check for b_4 [!=|==] 0 before calling the popcount/clz/ctz
+ /* Cond_bb has a check for b_4 [!=|==] 0 before calling the popcount
builtin. */
if (gimple_code (cond) != GIMPLE_COND
|| (gimple_cond_code (cond) != NE_EXPR
@@ -1879,13 +1840,10 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
}
/* Check PHI arguments. */
- if (lhs != arg0
- || TREE_CODE (arg1) != INTEGER_CST
- || wi::to_wide (arg1) != val)
+ if (lhs != arg0 || !integer_zerop (arg1))
return false;
- /* And insert the popcount/clz/ctz builtin and cast stmt before the
- cond_bb. */
+ /* And insert the popcount builtin and cast stmt before the cond_bb. */
gsi = gsi_last_bb (cond_bb);
if (cast)
{
@@ -1893,19 +1851,9 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
gsi_move_before (&gsi_from, &gsi);
reset_flow_sensitive_info (gimple_get_lhs (cast));
}
- gsi_from = gsi_for_stmt (call);
- if (ifn == IFN_LAST || gimple_call_internal_p (call))
- gsi_move_before (&gsi_from, &gsi);
- else
- {
- /* For __builtin_c[lt]z* force .C[LT]Z ifn, because only
- the latter is well defined at zero. */
- call = gimple_build_call_internal (ifn, 1, gimple_call_arg (call, 0));
- gimple_call_set_lhs (call, lhs);
- gsi_insert_before (&gsi, call, GSI_SAME_STMT);
- gsi_remove (&gsi_from, true);
- }
- reset_flow_sensitive_info (lhs);
+ gsi_from = gsi_for_stmt (popcount);
+ gsi_move_before (&gsi_from, &gsi);
+ reset_flow_sensitive_info (gimple_get_lhs (popcount));
/* Now update the PHI and remove unneeded bbs. */
replace_phi_edge_with_variable (cond_bb, e2, phi, lhs);
--
2.33.0
From 8c4edc4220bd14262bafb37056dfec68079cf4d5 Mon Sep 17 00:00:00 2001
From: zhongyunde 00443407 <zhongyunde@huawei.com>
Date: Tue, 18 Jun 2024 19:37:46 +0800
Subject: [PATCH 17/18] Delete the unsupported option, NFC
---
gcc/testsuite/gcc.dg/double_sized_mul-1.c | 2 +-
gcc/testsuite/gcc.dg/double_sized_mul-2.c | 2 +-
gcc/testsuite/gcc.dg/ifcvt-gimple.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/double_sized_mul-1.c b/gcc/testsuite/gcc.dg/double_sized_mul-1.c
index bdb503bc4..4d475cc8a 100644
--- a/gcc/testsuite/gcc.dg/double_sized_mul-1.c
+++ b/gcc/testsuite/gcc.dg/double_sized_mul-1.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* fif-conversion-gimple and fuaddsub-overflow-match-all are required for
proper overflow detection in some cases. */
-/* { dg-options "-O2 -fif-conversion-gimple -fuaddsub-overflow-match-all -ftree-fold-phiopt -fdump-tree-widening_mul-stats" } */
+/* { dg-options "-O2 -fif-conversion-gimple -fuaddsub-overflow-match-all -fdump-tree-widening_mul-stats" } */
#include <stdint.h>
typedef unsigned __int128 uint128_t;
diff --git a/gcc/testsuite/gcc.dg/double_sized_mul-2.c b/gcc/testsuite/gcc.dg/double_sized_mul-2.c
index f9d58a2f6..cc6e5af25 100644
--- a/gcc/testsuite/gcc.dg/double_sized_mul-2.c
+++ b/gcc/testsuite/gcc.dg/double_sized_mul-2.c
@@ -1,7 +1,7 @@
/* { dg-do compile } */
/* fif-conversion-gimple is required for proper overflow detection
in some cases. */
-/* { dg-options "-O2 -fif-conversion-gimple -fuaddsub-overflow-match-all -ftree-fold-phiopt -fdump-tree-widening_mul-stats" } */
+/* { dg-options "-O2 -fif-conversion-gimple -fuaddsub-overflow-match-all -fdump-tree-widening_mul-stats" } */
#include <stdint.h>
typedef unsigned __int128 uint128_t;
diff --git a/gcc/testsuite/gcc.dg/ifcvt-gimple.c b/gcc/testsuite/gcc.dg/ifcvt-gimple.c
index 4dc0f9206..0f7c87e5c 100644
--- a/gcc/testsuite/gcc.dg/ifcvt-gimple.c
+++ b/gcc/testsuite/gcc.dg/ifcvt-gimple.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fif-conversion-gimple -fdump-tree-optimized -ftree-fold-phiopt" } */
+/* { dg-options "-O2 -fif-conversion-gimple -fdump-tree-optimized" } */
int test_int (int optimizable_int) {
if (optimizable_int > 5)
--
2.33.0
From d10e5329a61d654efb5f4f71553a1a9f330a7c5d Mon Sep 17 00:00:00 2001
From: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
Date: Tue, 29 Oct 2024 18:17:37 +0800
Subject: [PATCH 18/18] Fix lost changes prior to earlier backport.
The original commit for d212d216be0752370dbe7bc63bd75b3a9249e0b5
contained updates for the test. Without it, the test worked incorrectly
for some time.
---
gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
index a2770e5e8..2e86620da 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c
@@ -1,9 +1,9 @@
/* PR tree-optimization/96928 */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-phiopt2" } */
+/* { dg-options "-O2 -fdump-tree-phiopt2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times " = a_\[0-9]*\\\(D\\\) >> " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-times " = ~c_\[0-9]*\\\(D\\\);" 1 "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times " = ~" 1 "phiopt2" } } */
+/* { dg-final { scan-tree-dump-times " = ~" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times " = \[abc_0-9\\\(\\\)D]* \\\^ " 5 "phiopt2" } } */
/* { dg-final { scan-tree-dump-not "a < 0" "phiopt2" } } */
--
2.33.0