public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: im Kiva <libkernelpanic@gmail.com>
To: binutils@sourceware.org
Subject: [RISCV] [GNU AS] Possible `vmsge{u}.vx` instruction lowering bug?
Date: Tue, 29 Aug 2023 14:52:36 +0800	[thread overview]
Message-ID: <CA+fTAJqPu6Aszt9FtqGXw8JOC6UY56k+BwOZw_VjZ7RpA2Wmyw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]

Hi maintainers,

I discovered that GNU Assembler (as) lowers `vmsge.vx` and `vmsgeu.vx` (pseudo
instructions from RISC-V Vector Extension [1]) when the destination
register is v0 as follows:

vmsge{u}.vx v0, v4, a0, v0.t, v2

will be expanded to:

vmslt{u}.vx v2, v4, a0, v0.t
vmandn.mm v0, v0, v2

You can inspect the lowering result with Godbolt [2].
However, according to the Vector specification [1] page 52. The "desugared"
`vmslt{u}.vx` is not masked:

> masked va >= x, vd == v0
>   pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t, vt
>   expansion: vmslt{u}.vx vt, va, x; vmandn.mm vd, vd, vt

So the spec-expected result of the example above should be:
vmslt{u}.vx v2, v4, a0 <-- no v0.t here
vmandn.mm v0, v0, v2

I thus submitted a patch to the LLVM [3], and it was accepted recently.

I am wondering if binutils considers it a bug, or if it is just intentional
because of some historical and compatibility reasons.
Thanks.

Best regards
Kiva Oyama

[1]: https://github.com/riscv/riscv-v-spec/releases/tag/v1.0
[2]: https://godbolt.org/z/aszc5d8sh
[3]: https://reviews.llvm.org/D158392

             reply	other threads:[~2023-08-29  6:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  6:52 im Kiva [this message]
2023-08-29  7:43 ` Jan Beulich
2023-08-29  7:59   ` Nelson Chu
2023-08-29  8:52     ` Jan Beulich
2023-08-30  2:51       ` Nelson Chu
2023-08-30  5:50         ` Jan Beulich
2023-09-01  6:37           ` Kiva Oyama
2023-09-01  8:03             ` Nelson Chu

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=CA+fTAJqPu6Aszt9FtqGXw8JOC6UY56k+BwOZw_VjZ7RpA2Wmyw@mail.gmail.com \
    --to=libkernelpanic@gmail.com \
    --cc=binutils@sourceware.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).