From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id 4CB183851C3E; Thu, 20 Oct 2022 09:08:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CB183851C3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666256884; bh=hsl3v8DkFDjji5I4OdJeBRnFGKlJDkAZ9hSQGjqnDBg=; h=From:To:Subject:Date:From; b=Aa00OWvea3usHusj3Eb6PEzEp58bKJHVGSRtQG8oUtL4n5aWQ9hBDzYQGXRZZcfo9 Qt4QtYn0SPVra1tmtp9eUhPRHi1hu/QjPnskvI0HFUR4oUsso62LNcNRMOPuHRn6Pf RKZzks+wCvPiC06un08RCRvod64vMoK1WG1ZE/6E= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3396] vect: Simplify first for shifted value generation [PR107240] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: a2e28389354495a532eb4b7124106b21236f4f72 X-Git-Newrev: 5d6e834ecf212e7fc6f585b154af224d2e38c749 Message-Id: <20221020090804.4CB183851C3E@sourceware.org> Date: Thu, 20 Oct 2022 09:08:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5d6e834ecf212e7fc6f585b154af224d2e38c749 commit r13-3396-g5d6e834ecf212e7fc6f585b154af224d2e38c749 Author: Kewen Lin Date: Thu Oct 20 04:07:05 2022 -0500 vect: Simplify first for shifted value generation [PR107240] As PR107240 shows, when both the value to be shifted and the count used for shifting are constants, it can be simplified to one constant value, and doesn't actually require to check if the current target supports vector shift operations or not. This patch uses a canonical way proposed by Richi to generate the shifted value, if it can be simplified, the shift operation would be gone, otherwise it's the same as before. It can help to fix the failures of vect-bitfield-write-{2,3}.c on Power. PR tree-optimization/107240 2022-10-20 Richard Biener gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_bit_insert_pattern): Attempt to simplify shifted value first. Diff: --- gcc/tree-vect-patterns.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 6afd57a50c4..d18e1e60996 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -2098,11 +2098,12 @@ vect_recog_bit_insert_pattern (vec_info *vinfo, stmt_vec_info stmt_info, tree shifted = value; if (shift_n) { - pattern_stmt - = gimple_build_assign (vect_recog_temp_ssa_var (container_type), - LSHIFT_EXPR, value, shift); - append_pattern_def_seq (vinfo, stmt_info, pattern_stmt); - shifted = gimple_get_lhs (pattern_stmt); + gimple_seq stmts = NULL; + shifted + = gimple_build (&stmts, LSHIFT_EXPR, container_type, value, shift); + if (!gimple_seq_empty_p (stmts)) + append_pattern_def_seq (vinfo, stmt_info, + gimple_seq_first_stmt (stmts)); } tree mask_t