public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/62262] New: aarch64 gcc generates invalid assembler
@ 2014-08-25 23:42 carrot at google dot com
  2014-08-26  1:03 ` [Bug target/62262] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: carrot at google dot com @ 2014-08-25 23:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 62262
           Summary: aarch64 gcc generates invalid assembler
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: carrot at google dot com
            Target: aarch64

Compile following source code with options -fprofile-use -O2


static inline int CLZ(int mask) {
   return mask ? __builtin_clz(mask) : 32;
}

int foo(int value)
{
    if (value == 0)
        return 0;

    int bias = CLZ(value);
    value >>= bias;
    int zeros = CLZ(value << 1);
    value <<= zeros;

    int packed = (unsigned)(value << 9) >> 9;
    return packed;
}

Without any actual profiling data, trunk gcc generates

/tmp/cctLq1F0.s: Assembler messages:
/tmp/cctLq1F0.s:20: Error: immediate value out of range 0 to 31 at operand 3 --
`ubfiz w0,w2,32,23'

The generated assembler code is:

foo:
    cbz    w0, .L4
    clz    w1, w0
    asr    w2, w0, w1
    adds    w0, w2, w2
    beq    .L3
    clz    w3, w0
    lsl    w4, w2, w3
    and    w0, w4, 8388607
    ret
.L3:
    ubfiz    w0, w2, 32, 23       // Wrong code
    ret
.L4:
    mov    w0, 0
    ret

4.9 gcc generates the same error.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-09-05 15:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-25 23:42 [Bug target/62262] New: aarch64 gcc generates invalid assembler carrot at google dot com
2014-08-26  1:03 ` [Bug target/62262] " pinskia at gcc dot gnu.org
2014-08-26  2:45 ` amker at gcc dot gnu.org
2014-08-26  3:15 ` pinskia at gcc dot gnu.org
2014-08-26  3:24 ` amker at gcc dot gnu.org
2014-08-26 23:10 ` pinskia at gcc dot gnu.org
2014-08-27  1:42 ` amker at gcc dot gnu.org
2014-08-27 16:48 ` carrot at gcc dot gnu.org
2014-08-27 23:01 ` carrot at gcc dot gnu.org
2014-09-05 15:39 ` mshawcroft at gcc dot gnu.org

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).