GCC Middle and Back End API Reference
vec_perm_indices Class Reference

#include <vec-perm-indices.h>

Collaboration diagram for vec_perm_indices:

Public Member Functions

 vec_perm_indices ()
 
 vec_perm_indices (const vec_perm_builder &, unsigned int, poly_uint64)
 
void new_vector (const vec_perm_builder &, unsigned int, poly_uint64)
 
void new_expanded_vector (const vec_perm_indices &, unsigned int)
 
bool new_shrunk_vector (const vec_perm_indices &, unsigned int)
 
void rotate_inputs (int delta)
 
const vec_perm_builderencoding () const
 
poly_uint64 length () const
 
unsigned int ninputs () const
 
poly_uint64 nelts_per_input () const
 
poly_uint64 input_nelts () const
 
element_type clamp (element_type) const
 
element_type operator[] (unsigned int i) const
 
bool series_p (unsigned int, unsigned int, element_type, element_type) const
 
bool all_in_range_p (element_type, element_type) const
 
bool all_from_input_p (unsigned int) const
 

Private Types

typedef poly_int64 element_type
 

Private Member Functions

 vec_perm_indices (const vec_perm_indices &)
 

Private Attributes

vec_perm_builder m_encoding
 
unsigned int m_ninputs
 
poly_uint64 m_nelts_per_input
 

Detailed Description

This class represents a constant permutation vector, such as that used
as the final operand to a VEC_PERM_EXPR.

Permutation vectors select indices modulo the number of input elements,
and the class canonicalizes each permutation vector for a particular
number of input vectors and for a particular number of elements per
input.  For example, the gimple statements:

 _1 = VEC_PERM_EXPR <a, a, { 0, 2, 4, 6, 0, 2, 4, 6 }>;
 _2 = VEC_PERM_EXPR <a, a, { 0, 2, 4, 6, 8, 10, 12, 14 }>;
 _3 = VEC_PERM_EXPR <a, a, { 0, 2, 20, 22, 24, 2, 4, 14 }>;

effectively have only a single vector input "a".  If "a" has 8
elements, the indices select elements modulo 8, which makes all three
VEC_PERM_EXPRs equivalent.  The canonical form is for the indices to be
in the range [0, number of input elements - 1], so the class treats the
second and third permutation vectors as though they had been the first.

The class copes with cases in which the input and output vectors have
different numbers of elements.   

Member Typedef Documentation

◆ element_type

Constructor & Destructor Documentation

◆ vec_perm_indices() [1/3]

vec_perm_indices::vec_perm_indices ( )
inline

◆ vec_perm_indices() [2/3]

vec_perm_indices::vec_perm_indices ( const vec_perm_builder & elements,
unsigned int ninputs,
poly_uint64 nelts_per_input )
inline
Construct a permutation vector that selects between NINPUTS vector
inputs that have NELTS_PER_INPUT elements each.  Take the elements of
the new vector from ELEMENTS, clamping each one to be in range.   

References nelts_per_input(), new_vector(), and ninputs().

◆ vec_perm_indices() [3/3]

vec_perm_indices::vec_perm_indices ( const vec_perm_indices & )
private

Member Function Documentation

◆ all_from_input_p()

bool vec_perm_indices::all_from_input_p ( unsigned int i) const
inline
Return true if the permutation vector only selects elements from
input I.   

References all_in_range_p(), i, and m_nelts_per_input.

◆ all_in_range_p()

bool vec_perm_indices::all_in_range_p ( element_type start,
element_type size ) const

◆ clamp()

vec_perm_indices::element_type vec_perm_indices::clamp ( element_type elt) const
inline
Return the canonical value for permutation vector element ELT,
taking into account the current number of input elements.   

References input_nelts(), and known_lt.

Referenced by all_in_range_p(), new_vector(), operator[](), rotate_inputs(), and series_p().

◆ encoding()

const vec_perm_builder & vec_perm_indices::encoding ( ) const
inline

◆ input_nelts()

poly_uint64 vec_perm_indices::input_nelts ( ) const
inline

References m_nelts_per_input, and m_ninputs.

Referenced by all_in_range_p(), and clamp().

◆ length()

◆ nelts_per_input()

poly_uint64 vec_perm_indices::nelts_per_input ( ) const
inline

References m_nelts_per_input.

Referenced by new_vector(), and vec_perm_indices().

◆ new_expanded_vector()

void vec_perm_indices::new_expanded_vector ( const vec_perm_indices & orig,
unsigned int factor )
Switch to a new permutation vector that selects the same input elements
as ORIG, but with each element split into FACTOR pieces.  For example,
if ORIG is { 1, 2, 0, 3 } and FACTOR is 2, the new permutation is
{ 2, 3, 4, 5, 0, 1, 6, 7 }.   

References vector_builder< T, Shape, Derived >::encoded_nelts(), vector_builder< T, Shape, Derived >::finalize(), vector_builder< T, Shape, Derived >::full_nelts(), i, m_encoding, m_nelts_per_input, m_ninputs, vector_builder< T, Shape, Derived >::nelts_per_pattern(), int_vector_builder< T >::new_vector(), and vector_builder< T, Shape, Derived >::npatterns().

Referenced by can_vec_perm_const_p(), and expand_vec_perm_const().

◆ new_shrunk_vector()

bool vec_perm_indices::new_shrunk_vector ( const vec_perm_indices & orig,
unsigned int factor )
Check whether we can switch to a new permutation vector that
selects the same input elements as ORIG, but with each element
built up from FACTOR pieces.  Return true if yes, otherwise
return false.  Every FACTOR permutation indexes should be
continuous separately and the first one of each batch should
be able to exactly modulo FACTOR.  For example, if ORIG is
{ 2, 3, 4, 5, 0, 1, 6, 7 } and FACTOR is 2, the new permutation
is { 1, 2, 0, 3 }.   

References vector_builder< T, Shape, Derived >::encoded_nelts(), encoding(), vector_builder< T, Shape, Derived >::finalize(), vector_builder< T, Shape, Derived >::full_nelts(), gcc_assert, i, m_encoding, m_nelts_per_input, m_ninputs, vector_builder< T, Shape, Derived >::nelts_per_pattern(), int_vector_builder< T >::new_vector(), and vector_builder< T, Shape, Derived >::npatterns().

Referenced by simplify_permutation().

◆ new_vector()

void vec_perm_indices::new_vector ( const vec_perm_builder & elements,
unsigned int ninputs,
poly_uint64 nelts_per_input )
A representation of vector permutation indices.
   Copyright (C) 2017-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Switch to a new permutation vector that selects between NINPUTS vector
inputs that have NELTS_PER_INPUT elements each.  Take the elements of the
new permutation vector from ELEMENTS, clamping each one to be in range.   

References clamp(), vector_builder< T, Shape, Derived >::elt(), vector_builder< T, Shape, Derived >::encoded_nelts(), vector_builder< T, Shape, Derived >::finalize(), vector_builder< T, Shape, Derived >::full_nelts(), i, poly_int< N, C >::is_constant(), m_encoding, m_nelts_per_input, m_ninputs, nelts_per_input(), vector_builder< T, Shape, Derived >::nelts_per_pattern(), int_vector_builder< T >::new_vector(), ninputs(), and vector_builder< T, Shape, Derived >::npatterns().

Referenced by calc_perm_vec_perm_simplify_seqs(), and vec_perm_indices().

◆ ninputs()

unsigned int vec_perm_indices::ninputs ( ) const
inline

References m_ninputs.

Referenced by new_vector(), and vec_perm_indices().

◆ operator[]()

vec_perm_indices::element_type vec_perm_indices::operator[] ( unsigned int i) const
inline
Return the value of vector element I, which might or might not be
explicitly encoded.   

References clamp(), vector_builder< T, Shape, Derived >::elt(), i, and m_encoding.

◆ rotate_inputs()

void vec_perm_indices::rotate_inputs ( int delta)
Rotate the inputs of the permutation right by DELTA inputs.  This changes
the values of the permutation vector but it doesn't change the way that
the elements are encoded.   

References clamp(), i, m_encoding, and m_nelts_per_input.

◆ series_p()

bool vec_perm_indices::series_p ( unsigned int out_base,
unsigned int out_step,
element_type in_base,
element_type in_step ) const
Return true if index OUT_BASE + I * OUT_STEP selects input
element IN_BASE + I * IN_STEP.  For example, the call to test
whether a permute reverses a vector of N elements would be:

  series_p (0, 1, N - 1, -1)

which would return true for { N - 1, N - 2, N - 3, ... }.
The calls to test for an interleaving of elements starting
at N1 and N2 would be:

  series_p (0, 2, N1, 1) && series_p (1, 2, N2, 1).

which would return true for { N1, N2, N1 + 1, N2 + 1, ... }.   

References clamp(), vector_builder< T, Shape, Derived >::elt(), vector_builder< T, Shape, Derived >::full_nelts(), known_ge, least_common_multiple(), m_encoding, and vector_builder< T, Shape, Derived >::npatterns().

Referenced by is_combined_permutation_identity(), and shift_amt_for_vec_perm_mask().

Field Documentation

◆ m_encoding

◆ m_nelts_per_input

◆ m_ninputs

unsigned int vec_perm_indices::m_ninputs
private

The documentation for this class was generated from the following files: