public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pan2.li at intel dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/116278] [15] RISC-V: Miscompile at -O2 -fwrapv -fno-strict-aliasing
Date: Thu, 08 Aug 2024 02:13:57 +0000	[thread overview]
Message-ID: <bug-116278-4-T9JWuhj77i@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-116278-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Li Pan <pan2.li at intel dot com> ---
(In reply to Andrew Pinski from comment #4)
>         lb      a1,0(a5) // load -40
>         lui     a0,%hi(.LC0)
>         lui     a4,%hi(c)
>         addi    a5,a1,9 //a5 = -31
>         slli    a5,a5,48 
>         srli    a5,a5,48 // a5 = -31
>         sltu    a1,a5,a1 // -31 <u -40 ? false
>         neg     a1,a1 // 0
>         or      a1,a1,a5 // -31
>         slli    a1,a1,48
>         srli    a1,a1,48
> 
> I don't see anything wrong here ... Unless I missed something (is lb a
> signed load byte?)

I think the problem comes from the lb side

     0x1014c <main+16>               lb      a1,0(a5)  // a1 is -40, aka
0xffffffffffffffd8                                                             
                                                                               
         ││   0x10150 <main+20>               lui     a0,0x1a                  
                                                                               
                                                          ││   0x10152
<main+22>               addi    a5,a1,9                                        
                                                                               
                                    ││   0x10156 <main+26>               slli  
 a5,a5,0x30                                                                    
                                                                               
     ││   0x10158 <main+28>               srli    a5,a5,0x30 // a5 is 65505    
                                                                               
                                                                     ││ 
>0x1015a <main+30>               sltu    a1,a5,a1   // compare 65505 and
0xffffffffffffffd8 => TRUE, and then get max 65535.

It should be one backend code-gen issue, will take care of this.

  parent reply	other threads:[~2024-08-08  2:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08  0:46 [Bug target/116278] New: " patrick at rivosinc dot com
2024-08-08  1:01 ` [Bug target/116278] " pinskia at gcc dot gnu.org
2024-08-08  1:17 ` kito at gcc dot gnu.org
2024-08-08  1:21 ` pan2.li at intel dot com
2024-08-08  1:21 ` pinskia at gcc dot gnu.org
2024-08-08  1:42 ` pan2.li at intel dot com
2024-08-08  2:13 ` pan2.li at intel dot com [this message]
2024-08-08  2:30 ` pan2.li at intel dot com
2024-08-08  3:19 ` pan2.li at intel dot com
2024-08-18  1:28 ` cvs-commit at gcc dot gnu.org
2024-08-18  3:49 ` sjames at gcc dot gnu.org
2024-08-18  4:12 ` pan2.li at intel dot com
2024-08-18  5:32 ` sjames at gcc dot gnu.org
2024-08-28  8:09 ` cvs-commit at gcc dot gnu.org
2024-09-02  4:43 ` law 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-116278-4-T9JWuhj77i@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).