public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Maciej W. Rozycki <macro@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-5766] VAX: Correct fatal issues with the `ffs' builtin
Date: Sat,  5 Dec 2020 18:27:47 +0000 (GMT)	[thread overview]
Message-ID: <20201205182747.9E7E0383303C@sourceware.org> (raw)

https://gcc.gnu.org/g:8c18e22afb061329766be3532a06a85ccc492d9c

commit r11-5766-g8c18e22afb061329766be3532a06a85ccc492d9c
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Sat Dec 5 18:26:24 2020 +0000

    VAX: Correct fatal issues with the `ffs' builtin
    
    The `builtins.md' machine description fragment is not included anywhere
    and is therefore dead code, which has become bitrotten due to non-use.
    
    If actually enabled, it does not build due to the use of an unknown `t'
    constraint:
    
    .../gcc/config/vax/builtins.md:42:1: error: undefined machine-specific constraint at this point: "t"
    .../gcc/config/vax/builtins.md:42:1: note:  in operand 1
    
    which came from commit becb93d02cc1 ("builtins.md (ffssi2_internal):
    Correct constraint."), which was not applied as posted and reviewed; `T'
    was meant to be used instead.
    
    Once this has been fixed this code still fails building:
    
    .../gcc/config/vax/builtins.md: In function 'rtx_def* gen_ffssi2(rtx, rtx)':
    .../gcc/config/vax/builtins.md:35:19: error: 'gen_bne' was not declared in this
    scope; did you mean 'gen_use'?
       35 |   emit_jump_insn (gen_bne (label));
          |                   ^~~~~~~
          |                   gen_use
    make[2]: *** [Makefile:1122: insn-emit.o] Error 1
    
    Finally the FFS machine instruction sets the Z condition code according
    to the comparison of the value held in the source operand against zero
    rather than the value held in the target operand.  If the source operand
    is found hold zero, then the target operand is set to the width of the
    source operand, 32 for SImode (FFS supports arbitrary widths).
    
    Correct the build issues then and update RTL to match the operation of
    the machine instruction.  A test case will be added separately.
    
            gcc/
            * config/vax/builtins.md (ffssi2): Make preparation statements
            actually buildable.
            (ffssi2_internal): Fix input constraints; make the RTL pattern
            match reality for `cc0'.

Diff:
---
 gcc/config/vax/builtins.md | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/config/vax/builtins.md b/gcc/config/vax/builtins.md
index ac0e0271ddd..6bce7a85add 100644
--- a/gcc/config/vax/builtins.md
+++ b/gcc/config/vax/builtins.md
@@ -31,8 +31,12 @@
   "
 {
   rtx label = gen_label_rtx ();
+  rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, label);
+  rtx cond = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
+  rtx target = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, label_ref, pc_rtx);
+
   emit_insn (gen_ffssi2_internal (operands[0], operands[1]));
-  emit_jump_insn (gen_bne (label));
+  emit_jump_insn (gen_rtx_SET (pc_rtx, target));
   emit_insn (gen_negsi2 (operands[0], const1_rtx));
   emit_label (label);
   emit_insn (gen_addsi3 (operands[0], operands[0], const1_rtx));
@@ -41,8 +45,10 @@
 
 (define_insn "ffssi2_internal"
   [(set (match_operand:SI 0 "nonimmediate_operand" "=rQ")
-	(ffs:SI (match_operand:SI 1 "general_operand" "nrQt")))
-   (set (cc0) (match_dup 0))]
+	(ffs:SI (match_operand:SI 1 "general_operand" "nrQT")))
+   (set (cc0)
+	(compare (match_dup 1)
+		 (const_int 0)))]
   ""
   "ffs $0,$32,%1,%0")


                 reply	other threads:[~2020-12-05 18:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201205182747.9E7E0383303C@sourceware.org \
    --to=macro@gcc.gnu.org \
    --cc=gcc-cvs@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).