From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2032 invoked by alias); 4 Oct 2015 13:04:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 2011 invoked by uid 48); 4 Oct 2015 13:04:07 -0000 From: "senthil_kumar.selvaraj at atmel dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67839] New: Bit addressable instructions generated for invalid memory address Date: Sun, 04 Oct 2015 13:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: senthil_kumar.selvaraj at atmel dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg00267.txt.bz2 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