public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Klaus.k.pedersen@nokia.com
To: gcc-gnats@gcc.gnu.org
Subject: target/5170: Supicious code in arm.md
Date: Fri, 21 Dec 2001 06:56:00 -0000	[thread overview]
Message-ID: <20011221145008.23546.qmail@sources.redhat.com> (raw)


>Number:         5170
>Category:       target
>Synopsis:       Supicious code in arm.md
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 21 06:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Klaus Pedersen
>Release:        gcc version 3.1 20011203 (experimental)
>Organization:
>Environment:
nice
>Description:
See also target/5107, investigated by Richard Earnshaw <rearnsha@arm.com>

The arm.md file defines the split pattern
 
 (define_split 
   [(set (match_operand:SI 0 "register_operand" "")
         (match_operand:SI 1 "const_int_operand" ""))]
   "TARGET_THUMB && CONST_OK_FOR_THUMB_LETTER (INTVAL (operands[1]), 'K')"
   [(set (match_dup 0) (match_dup 1))
    (set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))]
   "
   {
     unsigned HOST_WIDE_INT val = INTVAL (operands[1]);
     unsigned HOST_WIDE_INT mask = 0xff;
     int i;
     
     for (i = 0; i < 25; i++)
       if ((val & (mask << i)) == val)
         break;
 
     if (i == 0)
       FAIL;
 
     operands[1] = GEN_INT (val >> i);
     operands[2] = GEN_INT (i);
   }"


I think that there is a bug here:
 
>     for (i = 0; i < 25; i++)
>       if ((val & (mask << i)) == val)
>         break;
> 
>     if (i == 0)
>       FAIL;
 
Consider "val = 0x55", which can be represented as 0x55 << 0, but
calling the function with this value causes the function FAIL to
be called.
 
On the other hand, FAIL isn't called when passing the constant 0x101, 
which can't be represented, therefor I think that:
 
>     if (i == 0)
>       FAIL;
 
should read:
 
>     if (i == 25)
>       FAIL;
 
 
BR, Klaus Pedersen
 
>How-To-Repeat:
Well I have to admit it - I haven't been able to find
code affected by this typo. So if it is redundant - it
probably should be removed.
>Fix:
change 
   if (i == 0)
to 
   if (i == 25)
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-12-21 14:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-21  6:56 Klaus.k.pedersen [this message]
2002-01-04  9:46 Richard Earnshaw
2002-01-04  9:46 Richard Earnshaw
2002-01-22  3:04 pb
2002-01-23 11:16 Klaus Pedersen
2002-01-24  2:30 rearnsha
2002-03-15  9:18 rearnsha

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=20011221145008.23546.qmail@sources.redhat.com \
    --to=klaus.k.pedersen@nokia.com \
    --cc=gcc-gnats@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).