Two example patches: enable powerpc64 builds of devel/powerpc64-gcc and lang/gcc8 via system-clang ( avoiding clang's reserving vec_step )
Mark Millard
marklmi at yahoo.com
Fri Oct 12 14:45:00 UTC 2018
[I experiment with using modern compilers on
powerpc64, here buildworld buildkernel was
via devel/powerpc64-xtoolchain-gcc but included
building clang and having clang as cc. clang's
problems are tied to aspects of buildworld
buildkernel but is otherwise usable.]
When clang is built with support for altivec
for powerpc* (powerpc64 here) and such it
reserves a name not from the C/C++ language
standards: vec_step .
system-clang has enough enabled for powerpc64
to have reserved vec_step.
If devel/llvm* ever enable enough powerpc64
support they would reserve vec_step too. (I've
not checked if this is already happening.)
Unfortunately, various devel/*gcc and lang/gcc*
use that name in gcc/tree-vect-loop.c and so on
powerpc64 those various *gcc* fail to build.
The below just avoids the extra reserved word
by renaming each non-comment vec_step in
gcc/tree-vect-loop.c to vec_step_renamed . This
has allowed me to build the example *gcc* 's in
poudriere-devel on powerpc64 (head -r339076
based).
One could imagine sed'ing or otherwise processing
gcc/tree-vect-loop.c instead of having patch files.
In the examples the original gcc/tree-vect-loop.c
files are not the same: one patch for all *gcc*
would not work.
# svnlite status /usr/ports/devel/powerpc64-gcc/files/ | more
? /usr/ports/devel/powerpc64-gcc/files/patch-gcc_tree-vect-loop.c
# svnlite status /usr/ports/lang/gcc8/files/ | more
? /usr/ports/lang/gcc8/files/patch-gcc_tree-vect-loop.c
# more /usr/ports/devel/powerpc64-gcc/files/patch-gcc_tree-vect-loop.c
--- gcc/tree-vect-loop.c.orig 2017-03-28 15:35:56 UTC
+++ gcc/tree-vect-loop.c
@@ -3832,7 +3832,7 @@ get_initial_def_for_induction (gimple *iv_phi)
edge pe = loop_preheader_edge (loop);
struct loop *iv_loop;
basic_block new_bb;
- tree new_vec, vec_init, vec_step, t;
+ tree new_vec, vec_init, vec_step_renamed, t;
tree new_name;
gimple *new_stmt;
gphi *induction_phi;
@@ -3986,7 +3986,7 @@ get_initial_def_for_induction (gimple *iv_phi)
stepvectype = get_vectype_for_scalar_type (TREE_TYPE (new_name));
gcc_assert (stepvectype);
new_vec = build_vector_from_val (stepvectype, t);
- vec_step = vect_init_vector (iv_phi, new_vec, stepvectype, NULL);
+ vec_step_renamed = vect_init_vector (iv_phi, new_vec, stepvectype, NULL);
/* Create the following def-use cycle:
@@ -4008,7 +4008,7 @@ get_initial_def_for_induction (gimple *iv_phi)
induc_def = PHI_RESULT (induction_phi);
/* Create the iv update inside the loop */
- new_stmt = gimple_build_assign (vec_dest, PLUS_EXPR, induc_def, vec_step);
+ new_stmt = gimple_build_assign (vec_dest, PLUS_EXPR, induc_def, vec_step_renamed);
vec_def = make_ssa_name (vec_dest, new_stmt);
gimple_assign_set_lhs (new_stmt, vec_def);
gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
@@ -4049,7 +4049,7 @@ get_initial_def_for_induction (gimple *iv_phi)
gcc_assert (CONSTANT_CLASS_P (new_name)
|| TREE_CODE (new_name) == SSA_NAME);
new_vec = build_vector_from_val (stepvectype, t);
- vec_step = vect_init_vector (iv_phi, new_vec, stepvectype, NULL);
+ vec_step_renamed = vect_init_vector (iv_phi, new_vec, stepvectype, NULL);
vec_def = induc_def;
prev_stmt_vinfo = vinfo_for_stmt (induction_phi);
@@ -4057,7 +4057,7 @@ get_initial_def_for_induction (gimple *iv_phi)
{
/* vec_i = vec_prev + vec_step */
new_stmt = gimple_build_assign (vec_dest, PLUS_EXPR,
- vec_def, vec_step);
+ vec_def, vec_step_renamed);
vec_def = make_ssa_name (vec_dest, new_stmt);
gimple_assign_set_lhs (new_stmt, vec_def);
@@ -6324,13 +6324,13 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iter
/* Create a vector of the step value. */
tree step = build_int_cst (cr_index_scalar_type, nunits_out);
- tree vec_step = build_vector_from_val (cr_index_vector_type, step);
+ tree vec_step_renamed = build_vector_from_val (cr_index_vector_type, step);
/* Create an induction variable. */
gimple_stmt_iterator incr_gsi;
bool insert_after;
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
- create_iv (series_vect, vec_step, NULL_TREE, loop, &incr_gsi,
+ create_iv (series_vect, vec_step_renamed, NULL_TREE, loop, &incr_gsi,
insert_after, &indx_before_incr, &indx_after_incr);
/* Next create a new phi node vector (NEW_PHI_TREE) which starts
# more /usr/ports/lang/gcc8/files/patch-gcc_tree-vect-loop.c
--- gcc/tree-vect-loop.c.orig 2018-10-10 22:41:40.295753000 -0700
+++ gcc/tree-vect-loop.c 2018-10-10 22:57:44.698855000 -0700
@@ -4970,13 +4970,13 @@
/* Create a vector of the step value. */
tree step = build_int_cst (cr_index_scalar_type, nunits_out);
- tree vec_step = build_vector_from_val (cr_index_vector_type, step);
+ tree vec_step_renamed = build_vector_from_val (cr_index_vector_type, step);
/* Create an induction variable. */
gimple_stmt_iterator incr_gsi;
bool insert_after;
standard_iv_increment_position (loop, &incr_gsi, &insert_after);
- create_iv (series_vect, vec_step, NULL_TREE, loop, &incr_gsi,
+ create_iv (series_vect, vec_step_renamed, NULL_TREE, loop, &incr_gsi,
insert_after, &indx_before_incr, &indx_after_incr);
/* Next create a new phi node vector (NEW_PHI_TREE) which starts
@@ -7641,7 +7641,7 @@
tree vec_def;
edge pe = loop_preheader_edge (loop);
basic_block new_bb;
- tree new_vec, vec_init, vec_step, t;
+ tree new_vec, vec_init, vec_step_renamed, t;
tree new_name;
gimple *new_stmt;
gphi *induction_phi;
@@ -7834,7 +7834,7 @@
new_name = vect_init_vector (phi, new_name,
TREE_TYPE (step_expr), NULL);
new_vec = build_vector_from_val (vectype, new_name);
- vec_step = vect_init_vector (phi, new_vec, vectype, NULL);
+ vec_step_renamed = vect_init_vector (phi, new_vec, vectype, NULL);
/* Now generate the IVs. */
unsigned group_size = SLP_TREE_SCALAR_STMTS (slp_node).length ();
@@ -7873,7 +7873,7 @@
/* Create the iv update inside the loop */
vec_def = make_ssa_name (vec_dest);
- new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);
+ new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step_renamed);
gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));
@@ -7904,7 +7904,7 @@
new_name = vect_init_vector (phi, new_name,
TREE_TYPE (step_expr), NULL);
new_vec = build_vector_from_val (vectype, new_name);
- vec_step = vect_init_vector (phi, new_vec, vectype, NULL);
+ vec_step_renamed = vect_init_vector (phi, new_vec, vectype, NULL);
for (; ivn < nvects; ++ivn)
{
gimple *iv = SLP_TREE_VEC_STMTS (slp_node)[ivn - nivs];
@@ -7915,7 +7915,7 @@
def = gimple_assign_lhs (iv);
new_stmt = gimple_build_assign (make_ssa_name (vectype),
PLUS_EXPR,
- def, vec_step);
+ def, vec_step_renamed);
if (gimple_code (iv) == GIMPLE_PHI)
gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
else
@@ -8041,7 +8041,7 @@
gcc_assert (CONSTANT_CLASS_P (new_name)
|| TREE_CODE (new_name) == SSA_NAME);
new_vec = build_vector_from_val (vectype, t);
- vec_step = vect_init_vector (phi, new_vec, vectype, NULL);
+ vec_step_renamed = vect_init_vector (phi, new_vec, vectype, NULL);
/* Create the following def-use cycle:
@@ -8064,7 +8064,7 @@
/* Create the iv update inside the loop */
vec_def = make_ssa_name (vec_dest);
- new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step);
+ new_stmt = gimple_build_assign (vec_def, PLUS_EXPR, induc_def, vec_step_renamed);
gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
set_vinfo_for_stmt (new_stmt, new_stmt_vec_info (new_stmt, loop_vinfo));
@@ -8108,7 +8108,7 @@
gcc_assert (CONSTANT_CLASS_P (new_name)
|| TREE_CODE (new_name) == SSA_NAME);
new_vec = build_vector_from_val (vectype, t);
- vec_step = vect_init_vector (phi, new_vec, vectype, NULL);
+ vec_step_renamed = vect_init_vector (phi, new_vec, vectype, NULL);
vec_def = induc_def;
prev_stmt_vinfo = vinfo_for_stmt (induction_phi);
@@ -8116,7 +8116,7 @@
{
/* vec_i = vec_prev + vec_step */
new_stmt = gimple_build_assign (vec_dest, PLUS_EXPR,
- vec_def, vec_step);
+ vec_def, vec_step_renamed);
vec_def = make_ssa_name (vec_dest, new_stmt);
gimple_assign_set_lhs (new_stmt, vec_def);
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-ppc
mailing list