This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: simplify_and_const_int - disable call to force_to_mode


> On Mon, 26 Feb 2001, Toshi Morita wrote:
> 
> > Mon Feb 26 10:37:43 PST 2001  Toshiyasu Morita  (tm2@best.com)
> > 
> >         * combine.c (simplify_and_const_int): Disable call to
> > force_to_mode.
> 
> Which testcase does this fix, on what target?
> 
> -- 
> Joseph S. Myers
> jsm28@cam.ac.uk
> 
> 

Okay, I managed to create a testcase which elicits the bug.

Build an sh-elf target compiler, and compile this sample:

int b = 5;

void main(void)

{
        int a = 0;

        if (b) {
                func();
        }

        printf("%d\n", (a + 23) & 0xfffffffc);
}

using the options:

-O1 -S test.c

and you'll get:

_main:
        mov.l   r14,@-r15
        sts.l   pr,@-r15
        mov.l   .L4,r1
        jsr     @r1
        mov     r15,r14
        mov.l   .L5,r1
        mov.l   @r1,r1
        tst     r1,r1
        bt      .L3
        mov.l   .L6,r1
        jsr     @r1
        nop
.L3:
        mov.l   .L7,r1
        mov.l   .L8,r4
        jsr     @r1
        mov     #23,r5		<- doh! is never ANDed against 0xfffffffc
...

With the previous patch, I get:

_main:
        mov.l   r14,@-r15
        sts.l   pr,@-r15
        mov.l   .L4,r1
        jsr     @r1
        mov     r15,r14
        mov.l   .L5,r1
        mov.l   @r1,r1
        tst     r1,r1
        bt      .L3
        mov.l   .L6,r1
        jsr     @r1
        nop
.L3:
        mov     #23,r0
        and     #60,r0		<- correctly ANDed before passing to printf
        mov.l   .L7,r1
        mov.l   .L8,r4
        jsr     @r1
        mov     r0,r5

Toshi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]