Bug 52831 - extract_bit_field_1: issue when str_rtx unsafe from target
Summary: extract_bit_field_1: issue when str_rtx unsafe from target
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-02 09:39 UTC by Aurelien Buhrig
Modified: 2012-04-19 09:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Fix (780 bytes, patch)
2012-04-02 09:42 UTC, Aurelien Buhrig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Buhrig 2012-04-02 09:39:35 UTC
This bug makes gcc.c-torture/execute/20040625-1.c fail on my private target port with gcc 4.6.3. Note that it also occurs on trunk during expand, but it seems to be masked by next passes.

The issue occurs when:
- str_rtx (op0) is not safe from target
- when bitsize > BITS_PER_WORD

Example:

WORD_MODE = HImode
Pmode == ptr_mode == PSImode

extract_bit_field_1 (str_rtx=0x2aaaac15be28, bitsize=32, bitnum=0, unsignedp=1, packedp=1 '\001', target=0x2aaaac16c880, mode=PSImode, tmode=PSImode, 
    fallback_p=1 '\001')
(gdb) call debug_rtx (str_rtx)
(mem:BLK (reg/v/f:PSI 22 [ s ]) [2 *s_3(D)+0 S4 A8])
(gdb) call debug_rtx (target)
(reg/v/f:PSI 22 [ s ])

Here is the expand log from trunk (see insns 19 and 20):

; s_4 = s_3(D)->next;

(insn 10 9 11 (clobber (reg/v/f:PSI 22 [ s ])) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 11 10 12 (set (reg:QI 25)
        (mem:QI (plus:PSI (reg/v/f:PSI 22 [ s ])
                (const_int 2 [0x2])) [0+2 S1 A8])) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 12 11 13 (set (reg:HI 24)
        (zero_extend:HI (reg:QI 25))) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 13 12 14 (set (reg:HI 26)
        (reg:HI 24)) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 14 13 15 (set (reg:HI 26)
        (unspec:HI [
                (reg:HI 26)
            ] 11)) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 15 14 16 (set (strict_low_part (subreg:QI (reg:HI 26) 1))
        (const_int 0 [0])) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 16 15 17 (set (reg:QI 28)
        (mem:QI (plus:PSI (reg/v/f:PSI 22 [ s ])
                (const_int 3 [0x3])) [0+3 S1 A8])) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 17 16 18 (set (reg:HI 27)
        (zero_extend:HI (reg:QI 28))) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 18 17 19 (set (reg:HI 29)
        (ior:HI (reg:HI 27)
            (reg:HI 26))) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 19 18 20 (set (subreg:HI (reg/v/f:PSI 22 [ s ]) 2)
        (reg:HI 29)) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 20 19 21 (set (reg:QI 31)
        (mem:QI (reg/v/f:PSI 22 [ s ]) [0+0 S1 A8])) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 21 20 22 (set (reg:HI 30)
        (zero_extend:HI (reg:QI 31))) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))

(insn 22 21 23 (set (reg:HI 32)
        (reg:HI 30)) /home/buhrig/work/sdk/gcc/trunk/src/gcc/testsuite/gcc.c-torture/execute/20040625-1.c:8 -1
     (nil))


The provided patch solves the issue by using an intermediate reg, when needed, before extracting in word mode.
Comment 1 Aurelien Buhrig 2012-04-02 09:42:28 UTC
Created attachment 27062 [details]
Fix
Comment 2 Aurelien Buhrig 2012-04-19 09:18:24 UTC
Need more information about the bug?
Any comment about the provided patch?