public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/112801] [14] RISC-V vector: failure to mask top bits during type conversion
Date: Sat, 02 Dec 2023 03:38:10 +0000	[thread overview]
Message-ID: <bug-112801-4-1N2VAyETnk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112801-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112801

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <panli@gcc.gnu.org>:

https://gcc.gnu.org/g:1461b431da51f80c90c3bea03d587d76e3e50843

commit r14-6069-g1461b431da51f80c90c3bea03d587d76e3e50843
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Fri Dec 1 20:31:50 2023 +0800

    RISC-V: Fix incorrect combine of extended scalar pattern

    Background:
    RVV ISA vx instructions for example vadd.vx,
    When EEW = 64 and RV32. We can't directly use vadd.vx.
    Instead, we need to use:

    sw
    sw
    vlse
    vadd.vv

    However, we have some special situation that we still can directly use
    vadd.vx directly for EEW=64 && RV32.

    that is, when scalar is a known CONST_INT value that doesn't overflow
32-bit value.
    So, we have a dedicated pattern for such situation:

    ...
    (sign_extend:<VEL> (match_operand:<VSUBEL> 3 "register_operand"          "
r,  r,  r,  r")).
    ...

    We first force_reg such CONST_INT (within 32bit value) into a SImode reg.
    Then use such special patterns.
    Those pattern with this operand match should only value on! TARGET_64BIT.

    The PR112801 combine into such patterns on RV64 incorrectly (Those patterns
should be only value on RV32).

    This is the bug:

            andi    a2,a2,2
            vsetivli        zero,2,e64,m1,ta,ma
            sext.w  a3,a4
            vmv.v.x v1,a2
            vslide1down.vx  v1,v1,a4    -> it should be a3 instead of a4.

    Such incorrect codegen is caused by
    ...
                    (sign_extend:DI (subreg:SI (reg:DI 135 [ f.0_3 ]) 0))
                ] UNSPEC_VSLIDE1DOWN)) 16935 {*pred_slide1downv2di_extended}
    ...

    Incorretly combine into the patterns should not be valid on RV64 system.

    So add !TARGET_64BIT to all same type patterns which can fix such issue as
well as robostify the vector.md.

            PR target/112801

    gcc/ChangeLog:

            * config/riscv/vector.md: Add !TARGET_64BIT.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/autovec/pr112801.c: New test.

  parent reply	other threads:[~2023-12-02  3:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01  2:41 [Bug target/112801] New: " patrick at rivosinc dot com
2023-12-01  2:49 ` [Bug target/112801] " juzhe.zhong at rivai dot ai
2023-12-01  7:57 ` rguenth at gcc dot gnu.org
2023-12-01  8:26 ` juzhe.zhong at rivai dot ai
2023-12-02  3:38 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-02  3:38 ` juzhe.zhong at rivai dot ai
2023-12-04 17:25 ` patrick at rivosinc dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112801-4-1N2VAyETnk@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).