https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96195
Bug ID: 96195
Summary: aarch64: ICE during GIMPLE pass:vect
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: yangyang305 at huawei dot com
Target Milestone: ---
Hi, gcc-trunk ICEs when compiling the following testcase with -ftree-vectorize
-march=armv8.2-a+sve -O1 -msve-vector-bits=128 -fopenmp-simd
testcase
---
int by;
#pragma omp declare simd
int
zp (int);
void
qh (int oh)
{
#pragma omp simd
for (by = 0; by < oh; ++by)
by = zp (by);
}
---
GCC version: 11.0.0 20200714 (experimental)
Result:
pr92347.c: In function ‘qh’:
pr92347.c:13:1: error: invalid conversion in gimple call
13 | qh (int oh)
| ^~
vector(4) int
vector(4) int
# .MEM_59 = VDEF <.MEM_13>
vect__21.16_58 = zp.simdclone.2 (vect_vec_iv_.15_56);
during GIMPLE pass: vect
pr92347.c:13:1: internal compiler error: verify_gimple failed
0xd1dcd7 verify_gimple_in_cfg(function*, bool)
../.././gcc/tree-cfg.c:5491
0xbe415b execute_function_todo
../.././gcc/passes.c:1992
0xbe505b do_per_function
../.././gcc/passes.c:1640
0xbe505b execute_todo
../.././gcc/passes.c:2046
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
In the testcase, the following gimple call is generated:
vect__21.16_58 = zp.simdclone.2 (vect_vec_iv_.15_56);
The TREE_TYPE of vect__21.16_58 has a different mode with the TREE_TYPE of
zp.simdclone.2 (vect_vec_iv_.15_56), leading to the crash.
It seems that a type conversion is needed when the return type of the simd
clone of the function has the same ABI identity but different TYPE_MODEs with
the vectype analyzed.
I have prepared the following patch to fix this problem, the type conversions
of
the arguments are added as well.
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -4108,7 +4108,20 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
vec_oprnd0);
}
if (k == 1)
- vargs.safe_push (vec_oprnd0);
+ if (!useless_type_conversion_p (TREE_TYPE (vec_oprnd0),
+ atype))
+ {
+ vec_oprnd0
+ = build1 (VIEW_CONVERT_EXPR, atype, vec_oprnd0);
+ gassign *new_stmt
+ = gimple_build_assign (make_ssa_name (atype),
+ vec_oprnd0);
+ vect_finish_stmt_generation (vinfo, stmt_info,
+ new_stmt, gsi);
+ vargs.safe_push (gimple_assign_lhs (new_stmt));
+ }
+ else
+ vargs.safe_push (vec_oprnd0);
else
{
vec_oprnd0 = build_constructor (atype, ctor_elts);
@@ -4204,8 +4217,7 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
gcc_assert (ratype || simd_clone_subparts (rtype) == nunits);
if (ratype)
new_temp = create_tmp_var (ratype);
- else if (simd_clone_subparts (vectype)
- == simd_clone_subparts (rtype))
+ else if (useless_type_conversion_p (vectype, rtype))
new_temp = make_ssa_name (vec_dest, new_call);
else
new_temp = make_ssa_name (rtype, new_call);
@@ -4293,6 +4305,12 @@ vectorizable_simd_clone_call (vec_info *vinfo,
stmt_vec_info stmt_info,
vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
vect_clobber_variable (vinfo, stmt_info, gsi, new_temp);
}
+ else if (!useless_type_conversion_p (vectype, rtype))
+ {
+ vec_oprnd0 = build1 (VIEW_CONVERT_EXPR, vectype, new_temp);
+ new_stmt = gimple_build_assign (make_ssa_name (vec_dest),
vec_oprnd0);
+ vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
+ }
}
if (j == 0)
With this patch, gcc generates:
_58 = VIEW_CONVERT_EXPR<vector(4) int>(vect_vec_iv_.15_56);
_59 = zp.simdclone.2 (_58);
vect__21.16_61 = VIEW_CONVERT_EXPR<vector(4) int>(_59);