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

            Bug ID: 102584
           Summary: [OpenRISC] backend generates wrong halfword constant
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thrustl at hotmail dot com
  Target Milestone: ---

The following simple program:

void f1(unsigned short);
void f2(short);

int main()
{
    f1(0xf123);
    f2(0xf123);
}

When compiled with 

$ openrisc-linux-gnu-gcc -S 35.c

generates the following assembly:

    .section    .text
    .align 4
    .global main
    .type   main, @function
main:
    l.addi  r1, r1, -8
    l.sw    0(r1), r2
    l.addi  r2, r1, 8
    l.sw    4(r1), r9
    l.xori  r3, r0, -3805
    l.jal   f1
     l.nop

    l.xori  r3, r0, -3805
    l.jal   f2
     l.nop

    l.movhi r17, hi(0)
    l.or    r11, r17, r17
    l.lwz   r2, 0(r1)
    l.lwz   r9, 4(r1)
    l.addi  r1, r1, 8
    l.jr    r9
     l.nop

    .size   main, .-main

Both f1() and f2() are called with signed constant -3805. I believe f1() should
be called with unsigned constant 0xf123, generated by l.ori instruction.

GCC version (comes with Fedora 34):

$ openrisc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=openrisc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/or1k-linux/11/lto-wrapper
Target: or1k-linux
Configured with: ../gcc-11.2.1-20210728/configure --bindir=/usr/bin
--build=x86_64-redhat-linux-gnu --datadir=/usr/share --disable-decimal-float
--disable-dependency-tracking --disable-gold --disable-libgcj --disable-libgomp
--disable-libmpx --disable-libquadmath --disable-libssp
--disable-libunwind-exceptions --disable-shared --disable-silent-rules
--disable-sjlj-exceptions --disable-threads
--with-ld=/usr/bin/openrisc-linux-gnu-ld --enable-__cxa_atexit
--enable-checking=release --enable-gnu-unique-object --enable-initfini-array
--enable-languages=c,c++ --enable-linker-build-id --enable-lto --enable-nls
--enable-obsolete --enable-plugin --enable-targets=all --exec-prefix=/usr
--host=x86_64-redhat-linux-gnu --includedir=/usr/include
--infodir=/usr/share/info --libexecdir=/usr/libexec --localstatedir=/var
--mandir=/usr/share/man --prefix=/usr --program-prefix=openrisc-linux-gnu-
--sbindir=/usr/sbin --sharedstatedir=/var/lib --sysconfdir=/etc
--target=or1k-linux --with-bugurl=http://bugzilla.redhat.com/bugzilla/
--with-gcc-major-version-only --with-isl --with-newlib
--with-plugin-ld=/usr/bin/openrisc-linux-gnu-ld
--with-sysroot=/usr/openrisc-linux-gnu/sys-root --with-system-libunwind
--with-system-zlib --without-headers --with-linker-hash-style=gnu
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20210728 (Red Hat Cross 11.2.1-1) (GCC) 

I also tried to recompile and got the same result.

Reply via email to