public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "alpsayin at alpsayin dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgcc/107459] New: microblaze moddi3 implementation is buggy
Date: Sun, 30 Oct 2022 00:49:02 +0000	[thread overview]
Message-ID: <bug-107459-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107459
           Summary: microblaze moddi3 implementation is buggy
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alpsayin at alpsayin dot com
  Target Milestone: ---

Created attachment 53791
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53791&action=edit
Disassembly of the submitted code sample

The issue has been mentioned and tried to be amended here:
https://lists.yoctoproject.org/g/meta-xilinx/message/3409

gcc version: 12.1.0 (from zephyrproject-rtos/gcc fork)
system: rhel8.5
compile flags:
 -isystem
/home/asayin/zephyr_sdks/microblaze_devel/zephyr/lib/libc/minimal/include
 -isystem
/home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/bin/../lib/gcc/microblazeel-zephyr-elf/12.1.0/include
 -isystem
/home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/bin/../lib/gcc/microblazeel-zephyr-elf/12.1.0/include-fixed 
 -fno-strict-aliasing 
 -Og 
 -imacros
/home/asayin/workspace/zephyr/build/zephyr/include/generated/autoconf.h 
 -ffreestanding 
 -fno-common
 -g
 -gdwarf-4
 -fdiagnostics-color=always
 -mcpu=v9.00.a
 -mxl-barrel-shift
 -mno-xl-soft-mul
 -mxl-multiply-high
 -mno-xl-soft-div
 -msoft-float
 -fdollars-in-identifiers

--sysroot=/home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/microblazeel-zephyr-elf
 -imacros
/home/asayin/zephyr_sdks/microblaze_devel/zephyr/include/zephyr/toolchain/zephyr_stdint.h
 -Wall
 -Wformat
 -Wformat-security
 -Wno-format-zero-length
 -Wno-main
 -Wno-pointer-sign
 -Wpointer-arith
 -Wexpansion-to-defined
 -Wno-unused-but-set-variable
 -Werror=implicit-int
 -fno-pic
 -fno-pie
 -fno-asynchronous-unwind-tables
 -fno-reorder-functions
 --param=min-pagesize=0
 -fno-defer-pop

-fmacro-prefix-map=/home/asayin/workspace/zephyr/samples/hello_world=CMAKE_SOURCE_DIR

-fmacro-prefix-map=/home/asayin/zephyr_sdks/microblaze_devel/zephyr=ZEPHYR_BASE
 -fmacro-prefix-map=/home/asayin/zephyr_sdks/microblaze_devel=WEST_TOPDIR
 -ffunction-sections
 -fdata-sections
 -std=c99 
 -nostdinc
 -MD 
 -MT CMakeFiles/app.dir/src/main.c.obj
 -MF CMakeFiles/app.dir/src/main.c.obj.d
 -o CMakeFiles/app.dir/src/main.c.obj
 -c /home/asayin/workspace/zephyr/samples/hello_world/src/main.c
output: none
preprocessed file: deemed unnecessary due to nature of the bug
attachments: relevant sections of the disassembly

Reproduction should be possible via the below code sample:

void main(void)
{
        volatile int64_t delta = 1514821494020000000;
        printf("delta = %016lld\n", delta);
        printf("NSEC_PER_SEC = %08d\n", NSEC_PER_SEC);
        uint32_t res1 = delta % NSEC_PER_SEC;
        printf("delta %% (moddi3) NSEC_PER_SEC = %"PRId32" (0x%"PRIx32")\n",
res1, res1);
        uint64_t new_tv_sec = delta / NSEC_PER_SEC;
        uint32_t res2 = delta - (new_tv_sec * NSEC_PER_SEC);
        printf("delta - delta*(delta/NSEC_PER_SEC) = %"PRId32"
(0x%"PRIx32")\n", res2, res2);
}

             reply	other threads:[~2022-10-30  0:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30  0:49 alpsayin at alpsayin dot com [this message]
2022-10-30  0:56 ` [Bug target/107459] " alpsayin at alpsayin dot com
2022-11-05 10:23 ` rguenth at gcc dot gnu.org

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=bug-107459-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).