public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/67839] New: Bit addressable instructions generated for invalid memory address
@ 2015-10-04 13:04 senthil_kumar.selvaraj at atmel dot com
  2015-10-05  9:04 ` [Bug target/67839] " senthil_kumar.selvaraj at atmel dot com
  2015-10-28 17:36 ` denisc at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2015-10-04 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67839
           Summary: Bit addressable instructions generated for invalid
                    memory address
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: senthil_kumar.selvaraj at atmel dot com
  Target Milestone: ---

Bit addressable instructions (sbi, cbi, sbis, sbic) only work on IO addresses
0x0-0x1f (inclusive). The compiler generates these instructions for IO address
0x20 as well.

The problem is in the specification of low_io_address_operand predicate, which
has

(define_special_predicate "low_io_address_operand"                              
  (ior (and (match_code "const_int")
      (match_test "IN_RANGE (INTVAL (op) - avr_arch->sfr_offset,
           0, 0x20 - GET_MODE_SIZE (mode))"))
       (and (match_code "symbol_ref")
      (match_test "SYMBOL_REF_FLAGS (op) & SYMBOL_FLAG_IO_LOW"))))

While this looks ok, gcc invokes low_io_address_operand with mode set to VOID,
and GET_MODE_SIZE for VOID returns 0, so the effective range becomes 0x0-0x20.

gcc does pass the correct mode if the operand mode is set in the define_insn
that uses this predicate. Don't know why it isn't set, and why
define_special_predicate is used instead of define_predicate.

Note that io_address_operand predicate has a GET_MODE_SIZE call as well, so the
range check is off by one in it too


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

* [Bug target/67839] Bit addressable instructions generated for invalid memory address
  2015-10-04 13:04 [Bug target/67839] New: Bit addressable instructions generated for invalid memory address senthil_kumar.selvaraj at atmel dot com
@ 2015-10-05  9:04 ` senthil_kumar.selvaraj at atmel dot com
  2015-10-28 17:36 ` denisc at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2015-10-05  9:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Senthil Kumar Selvaraj <senthil_kumar.selvaraj at atmel dot com> ---
Created attachment 36444
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36444&action=edit
Test case

Compile with avr-gcc test.c -Os


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

* [Bug target/67839] Bit addressable instructions generated for invalid memory address
  2015-10-04 13:04 [Bug target/67839] New: Bit addressable instructions generated for invalid memory address senthil_kumar.selvaraj at atmel dot com
  2015-10-05  9:04 ` [Bug target/67839] " senthil_kumar.selvaraj at atmel dot com
@ 2015-10-28 17:36 ` denisc at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: denisc at gcc dot gnu.org @ 2015-10-28 17:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from denisc at gcc dot gnu.org ---
Author: denisc
Date: Wed Oct 28 17:35:27 2015
New Revision: 229495

URL: https://gcc.gnu.org/viewcvs?rev=229495&root=gcc&view=rev
Log:
gcc/ChangeLog

        PR target/67839
        * config/avr/predicates.md (low_io_address_operand): Don't
        consider MODE when computing upper bound.
        (io_address_operand): Likewise.

gcc/testsuite/ChangeLog

        PR target/67839
        * gcc.target/avr/pr67839.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/avr/pr67839.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/predicates.md
    trunk/gcc/testsuite/ChangeLog


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

end of thread, other threads:[~2015-10-28 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-04 13:04 [Bug target/67839] New: Bit addressable instructions generated for invalid memory address senthil_kumar.selvaraj at atmel dot com
2015-10-05  9:04 ` [Bug target/67839] " senthil_kumar.selvaraj at atmel dot com
2015-10-28 17:36 ` denisc 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).