diff mbox series

tree-optimization/98048 - fix vector lowering of ABSU_EXPR

Message ID nycvar.YFH.7.76.2011301044390.17979@zhemvz.fhfr.qr
State New
Headers show
Series tree-optimization/98048 - fix vector lowering of ABSU_EXPR | expand

Commit Message

Richard Biener Nov. 30, 2020, 9:44 a.m. UTC
This makes sure to use the correct type for the LHS of the scalar
replacement statement.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

20220-11-30  Richard Biener  <rguenther@suse.de>

	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.
---
 gcc/testsuite/gcc.dg/vect/pr98048.c | 14 ++++++++++++++
 gcc/tree-vect-generic.c             |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/pr98048.c
diff mbox series

Patch

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,