70 lines
2.8 KiB
Diff
70 lines
2.8 KiB
Diff
|
|
From 7d5d2ab082ce9986db4f3313013b44faa46bc412 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jakub Jelinek <jakub@redhat.com>
|
||
|
|
Date: Thu, 22 Oct 2020 09:34:28 +0200
|
||
|
|
Subject: [PATCH 06/35] [Backport] phiopt: Optimize x ? __builtin_clz (x) : 32
|
||
|
|
in GIMPLE fallout [PR97503]
|
||
|
|
|
||
|
|
Reference: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=ef2d3ec325b1b720df5da20784eba46249af2294
|
||
|
|
|
||
|
|
> this broke sparc-sun-solaris2.11 bootstrap
|
||
|
|
>
|
||
|
|
> /vol/gcc/src/hg/master/local/gcc/tree-ssa-phiopt.c: In function 'bool cond_removal_in_popcount_clz_ctz_pattern(basic_block, basic_block, edge, edge, gimple*, tree, tree)':
|
||
|
|
> /vol/gcc/src/hg/master/local/gcc/tree-ssa-phiopt.c:1858:27: error: variable 'mode' set but not used [-Werror=unused-but-set-variable]
|
||
|
|
> 1858 | scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
|
||
|
|
> | ^~~~
|
||
|
|
>
|
||
|
|
>
|
||
|
|
> and doubtlessly several other targets that use the defaults.h definition of
|
||
|
|
>
|
||
|
|
> #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) 0
|
||
|
|
|
||
|
|
Ugh, seems many of those macros do not evaluate the first argument.
|
||
|
|
This got broken by the change to direct_internal_fn_supported_p, previously
|
||
|
|
it used mode also in the optab test.
|
||
|
|
|
||
|
|
2020-10-22 Jakub Jelinek <jakub@redhat.com>
|
||
|
|
|
||
|
|
* tree-ssa-phiopt.c (cond_removal_in_popcount_clz_ctz_pattern):
|
||
|
|
For CLZ and CTZ tests, use type temporary instead of mode.
|
||
|
|
---
|
||
|
|
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 c1e11916e..707a5882e 100644
|
||
|
|
--- a/gcc/tree-ssa-phiopt.c
|
||
|
|
+++ b/gcc/tree-ssa-phiopt.c
|
||
|
|
@@ -1836,10 +1836,10 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
|
||
|
|
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)
|
||
|
|
+ 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)
|
||
|
|
{
|
||
|
|
ifn = IFN_CLZ;
|
||
|
|
break;
|
||
|
|
@@ -1849,10 +1849,10 @@ cond_removal_in_popcount_clz_ctz_pattern (basic_block cond_bb,
|
||
|
|
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)
|
||
|
|
+ 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)
|
||
|
|
{
|
||
|
|
ifn = IFN_CTZ;
|
||
|
|
break;
|
||
|
|
--
|
||
|
|
2.27.0.windows.1
|
||
|
|
|