target/5170: Supicious code in arm.md
Klaus.k.pedersen@nokia.com
Klaus.k.pedersen@nokia.com
Fri Dec 21 06:56:00 GMT 2001
>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:
More information about the Gcc-prs
mailing list