public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/64217] New: LRA: generate wrong liveness info after r217947 for clobber in jump_insn
@ 2014-12-08  7:29 npickito at gmail dot com
  2014-12-09 20:35 ` [Bug rtl-optimization/64217] " vmakarov at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: npickito at gmail dot com @ 2014-12-08  7:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64217
           Summary: LRA: generate wrong liveness info after r217947 for
                    clobber in jump_insn
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: npickito at gmail dot com

Created attachment 34214
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34214&action=edit
rtl dumps for r217946 and  r217947

Configure:

--target=nds32le-elf --enable-checking=yes

Testcase:
testsuite/gcc.c-torture/compile/20020116-1.c

How to reproduce:
nds32le-elf-gcc testsuite/gcc.c-torture/compile/20020116-1.c -O0

What's happen:

...
(jump_insn 17 56 18 4 (parallel [
            (set (pc)
                (mem:SI (plus:SI (mult:SI (reg:SI 45) 
                            (const_int 4 [0x4]))
                        (label_ref 18)) [0  S4 A32]))
            (use (label_ref 18))
            (clobber (reg:SI 47))
            (clobber (reg:SI 15 $ta))
        ]) testsuite/gcc.c-torture/compile/20020116-1.c:13 87 {casesi_internal}
     (expr_list:REG_DEAD (reg:SI 45) 
        (expr_list:REG_UNUSED (reg:SI 47) 
            (expr_list:REG_UNUSED (reg:SI 15 $ta)
                (nil))))
 -> 18) 
...

LRA dump in r217946:
...
 r47: [15..16]
...
Compressing live ranges: from 21 to 15 - 71% 
Ranges after the compression:
...
 r47: [11..12]
...

LRA dump in r217947:
...
 r47: [0..26]
...
Compressing live ranges: from 27 to 15 - 55% 
Ranges after the compression:
...
 r47: [0..14]
...

Full dump in attachment.



Back trace:
~/gcc-trunk/gcc/testsuite/gcc.c-torture/compile/20020116-1.c: In function
'main':
~/gcc-trunk/gcc/testsuite/gcc.c-torture/compile/20020116-1.c:28:1: internal
compiler error: in lra_assign, at lra-assigns.c:1536
 }
 ^
0xb6015d lra_assign()
    ../../src/gcc/lra-assigns.c:1536
0xb5a022 lra(_IO_FILE*)
    ../../src/gcc/lra.c:2322
0xb0ce20 do_reload
    ../../src/gcc/ira.c:5391
0xb0d1b2 execute
    ../../src/gcc/ira.c:5561
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug rtl-optimization/64217] LRA: generate wrong liveness info after r217947 for clobber in jump_insn
  2014-12-08  7:29 [Bug rtl-optimization/64217] New: LRA: generate wrong liveness info after r217947 for clobber in jump_insn npickito at gmail dot com
@ 2014-12-09 20:35 ` vmakarov at gcc dot gnu.org
  2014-12-12  4:08 ` [Bug target/64217] " jasonwucj at gcc dot gnu.org
  2014-12-16  6:51 ` jasonwucj at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2014-12-09 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

Vladimir Makarov <vmakarov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vmakarov at gcc dot gnu.org

--- Comment #1 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
Thanks for reporting this.  I've reproduced the bug.  LRA treats p47 as an
input therefore after adding live info update to LRA, p47 live range becomes
such long.

The insn in question has the following definition

(define_insn "casesi_internal"
  [(parallel [(set (pc)
                   (mem:SI (plus:SI (mult:SI (match_operand:SI 0
"register_operand" "r")
                                             (const_int 4))
                                    (label_ref (match_operand 1 "" "")))))
              (use (label_ref (match_dup 1)))
              (clobber (match_operand:SI 2 "register_operand" ""))
              (clobber (reg:SI TA_REGNUM))])]

I think it is wrong.  GCC documentation says

@cindex @samp{=} In constraint
@item =
Means that this operand is written to by this instruction:
the previous value is discarded and replaced by new data.

As clobber always discards the previous value, it should have '=' which is
absent for this insn definition.  The constraints for LRA is usually more
important than other info.  After saying that, you can understand that the of
absence of other constraints is confusing to me. For example, clobber could get
memory in LRA and that will conflict finally with register_operand predicate
(but the conflict will probably recognized in assembler only as operand
predicates are used mostly in combiner and rtl generation).  But may be I am
wrong and the intention was that memory also works for the insn.

So I'd add at least '=' but it is better to add '=r' or '=<some other register
constraint>' to solve the problem.

If such fix is not acceptable for you for some reasons, let me know.  I'll
think how this undefined behaviour (it is really a grey area) can be fixed in
LRA.


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

* [Bug target/64217] LRA: generate wrong liveness info after r217947 for clobber in jump_insn
  2014-12-08  7:29 [Bug rtl-optimization/64217] New: LRA: generate wrong liveness info after r217947 for clobber in jump_insn npickito at gmail dot com
  2014-12-09 20:35 ` [Bug rtl-optimization/64217] " vmakarov at gcc dot gnu.org
@ 2014-12-12  4:08 ` jasonwucj at gcc dot gnu.org
  2014-12-16  6:51 ` jasonwucj at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jasonwucj at gcc dot gnu.org @ 2014-12-12  4:08 UTC (permalink / raw)
  To: gcc-bugs

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

Chung-Ju Wu <jasonwucj at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-12-12
                 CC|                            |jasonwucj at gcc dot gnu.org
          Component|rtl-optimization            |target
           Assignee|unassigned at gcc dot gnu.org      |jasonwucj at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Chung-Ju Wu <jasonwucj at gcc dot gnu.org> ---
(In reply to Vladimir Makarov from comment #1)
> 
> So I'd add at least '=' but it is better to add '=r' or '=<some other
> register constraint>' to solve the problem.
> 

Thanks Kito for reporting this issue.

Also thanks Vladimir to help identify the root cause.
Sorry for that our wrong pattern makes LRA live range analysis confused.

I will have a patch to fix it soon.  Thanks both of you. :)


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

* [Bug target/64217] LRA: generate wrong liveness info after r217947 for clobber in jump_insn
  2014-12-08  7:29 [Bug rtl-optimization/64217] New: LRA: generate wrong liveness info after r217947 for clobber in jump_insn npickito at gmail dot com
  2014-12-09 20:35 ` [Bug rtl-optimization/64217] " vmakarov at gcc dot gnu.org
  2014-12-12  4:08 ` [Bug target/64217] " jasonwucj at gcc dot gnu.org
@ 2014-12-16  6:51 ` jasonwucj at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jasonwucj at gcc dot gnu.org @ 2014-12-16  6:51 UTC (permalink / raw)
  To: gcc-bugs

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

Chung-Ju Wu <jasonwucj at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Chung-Ju Wu <jasonwucj at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-12-16  6:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08  7:29 [Bug rtl-optimization/64217] New: LRA: generate wrong liveness info after r217947 for clobber in jump_insn npickito at gmail dot com
2014-12-09 20:35 ` [Bug rtl-optimization/64217] " vmakarov at gcc dot gnu.org
2014-12-12  4:08 ` [Bug target/64217] " jasonwucj at gcc dot gnu.org
2014-12-16  6:51 ` jasonwucj 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).