aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-03-26 09:50:03 +0100
committerRichard Biener <rguenther@suse.de>2021-04-27 08:23:08 +0200
commit7d6bb80931b429631f63e0fd27bee95f32eb57a9 (patch)
treec93617ede29c78771bae7244355fc9d446100438 /gcc/match.pd
parent2cde2d620fc5ff60264ee825fd6eea457d7c51d9 (diff)
downloadgcc-7d6bb80931b429631f63e0fd27bee95f32eb57a9.zip
gcc-7d6bb80931b429631f63e0fd27bee95f32eb57a9.tar.gz
gcc-7d6bb80931b429631f63e0fd27bee95f32eb57a9.tar.bz2
tree-optimization/99776 - relax condition on vector ctor element extract
This relaxes the condition for the match.pd pattern doing vector ctor element extracts to not require type identity but only size equality. Since we vectorize pointer data as unsigned integer data such mismatches have to be tolerated to optimize scalar code uses of vector results. 2021-03-26 Richard Biener <rguenther@suse.de> PR tree-optimization/99776 * match.pd (bit_field_ref (ctor)): Relax element extract type compatibility checks. * gcc.dg/tree-ssa/ssa-fre-91.c: New testcase.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd18
1 files changed, 13 insertions, 5 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 66788ba..bb1d623 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6168,9 +6168,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(BIT_FIELD_REF CONSTRUCTOR@0 @1 @2)
(if (VECTOR_TYPE_P (TREE_TYPE (@0))
- && (types_match (type, TREE_TYPE (TREE_TYPE (@0)))
+ && tree_fits_uhwi_p (TYPE_SIZE (type))
+ && ((tree_to_uhwi (TYPE_SIZE (type))
+ == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0)))))
|| (VECTOR_TYPE_P (type)
- && types_match (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@0))))))
+ && (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (type)))
+ == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0))))))))
(with
{
tree ctor = (TREE_CODE (@0) == SSA_NAME
@@ -6226,10 +6229,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
if (!CONSTANT_CLASS_P (e))
constant_p = false;
}
- res = (constant_p ? build_vector_from_ctor (type, vals)
- : build_constructor (type, vals));
+ tree evtype = (types_match (TREE_TYPE (type),
+ TREE_TYPE (TREE_TYPE (ctor)))
+ ? type
+ : build_vector_type (TREE_TYPE (TREE_TYPE (ctor)),
+ count));
+ res = (constant_p ? build_vector_from_ctor (evtype, vals)
+ : build_constructor (evtype, vals));
}
- { res; })))))
+ (view_convert { res; }))))))
/* The bitfield references a single constructor element. */
(if (k.is_constant (&const_k)
&& idx + n <= (idx / const_k + 1) * const_k)