diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index d04cf4bccf8..6019d9b03ff 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -2661,18 +2661,21 @@ simplify_permutation (gimple_stmt_iterator *gsi) /* Shuffle of a constructor. */ bool ret = false; - tree res_type = TREE_TYPE (gimple_assign_lhs (stmt)); + tree res_type = TREE_TYPE (arg0); tree opt = fold_ternary (VEC_PERM_EXPR, res_type, arg0, arg1, op2); if (!opt || (TREE_CODE (opt) != CONSTRUCTOR && TREE_CODE (opt) != VECTOR_CST)) return 0; /* Found VIEW_CONVERT_EXPR before, need one explicit conversion. */ - if (res_type != TREE_TYPE (op0)) + tree lhs_type = TREE_TYPE (gimple_assign_lhs (stmt)); + if (res_type != lhs_type) { + if (!operand_equal_p (TYPE_SIZE (lhs_type), TYPE_SIZE (res_type))) + return 0; tree name = make_ssa_name (TREE_TYPE (opt)); gimple *ass_stmt = gimple_build_assign (name, opt); gsi_insert_before (gsi, ass_stmt, GSI_SAME_STMT); - opt = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (op0), name); + opt = build1 (VIEW_CONVERT_EXPR, lhs_type, name); } gimple_assign_set_rhs_from_tree (gsi, opt); update_stmt (gsi_stmt (*gsi));