From: Richard Biener Date: Mon, 30 Nov 2020 09:41:36 +0000 (+0100) Subject: tree-optimization/98048 - fix vector lowering of ABSU_EXPR X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bcded23eb87c55a1a3fcd23d5629a0c35aee4ba;p=gcc.git tree-optimization/98048 - fix vector lowering of ABSU_EXPR This makes sure to use the correct type for the LHS of the scalar replacement statement. 20220-11-30 Richard Biener PR tree-optimization/98048 * tree-vect-generic.c (expand_vector_operations_1): Use the correct type for the scalar LHS replacement. * gcc.dg/vect/pr98048.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/vect/pr98048.c b/gcc/testsuite/gcc.dg/vect/pr98048.c new file mode 100644 index 00000000000..e61a376cb04 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr98048.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +extern short var_0; +extern int var_3; +extern int arr_277[]; +int a(int b, int c) { return b < c ? b : c; } +int e; +void test() +{ + e = var_0; + for (int d = 0; d < 9; d++) + if (var_3) + arr_277[d] = a(var_0, -var_0); +} diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index 23bc1cb04b7..55cf0d9bab5 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -2089,7 +2089,7 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi, if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing) { - tree slhs = make_ssa_name (TREE_TYPE (srhs1)); + tree slhs = make_ssa_name (TREE_TYPE (TREE_TYPE (lhs))); gimple *repl = gimple_build_assign (slhs, code, srhs1, srhs2); gsi_insert_before (gsi, repl, GSI_SAME_STMT); gimple_assign_set_rhs_from_tree (gsi,