Skip to content

Code generation issue for loongarch64 compiler when using -O2 or higher optimization

Summary

Loongarch64 compiler generates faulty code when -O2 optimization option or higher is used.

System Information

  • Operating system: Linux
  • Processor architecture: Loongarch64
  • Compiler version: 3.3.1

See failures for tcalpext.pp:

https://www.freepascal.org/testsuite/cgi-bin/new-testsuite2.cgi?action=4&testfilename=test%2Fcg%2Ftcalpext.pp&os=15&cpu=8&version=58&date=&submitter=&machine=&comment=&limit=50&cond=&Category=3&failedonly=1&noskipped=1&listall=1

Steps to reproduce

Just compile required files for tests/test/cg/tcalpext.pp and compile using ppcloongarch64 -O2

Example Project

What is the current bug behavior?

The code fails on function test_function_tiny_struct. which returns a 8-bit value. It seems that, with -O2, the upper part of register $a0 is not zeroed out. I do not know if this is an error in the function or in the code after which seems to assume that upper bytes of the register are zero.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information