Bug 39716 - suboptimal MAX_EXPR expansion for Thumb
Summary: suboptimal MAX_EXPR expansion for Thumb
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2009-04-10 12:44 UTC by Paolo Bonzini
Modified: 2010-02-08 11:54 UTC (History)
1 user (show)

See Also:
Host:
Target: arm
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-09-09 15:11:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Bonzini 2009-04-10 12:44:33 UTC
/* -O1 -mthumb -march=armv6t2 -ffinite-math-only */

float repl1 (float varx)
{
  if (varx < 0.0)
    return 0.0;
    return varx;
}
Comment 1 Paolo Bonzini 2009-07-14 20:35:11 UTC
This fails for me with r149508 with a reload failure.
Comment 2 Ramana Radhakrishnan 2009-08-19 08:59:49 UTC
(In reply to comment #1)
> This fails for me with r149508 with a reload failure.
> 

I don't seem to have a reload failure for this with 150624.

Comment 3 Ramana Radhakrishnan 2009-09-09 11:08:09 UTC
There isn't a reload failure  with trunk as of yesterday. 

Paolo can you explain this further ?

Comment 4 Paolo Bonzini 2009-09-09 15:11:09 UTC
I don't see the reload failure anymore.

The code is:

	push	{r4, lr}
	mov	r4, r0
	mov	r1, #0
	bl	__gesf2
	cmp	r0, #0
	it	lt
	movlt	r4, #0
	mov	r0, r4
	pop	{r4, pc}

Pre-cond-optab, we generated

	push	{r4, lr}
	mov	r4, r0
	mov	r1, #0
	bl	__gesf2
	cmp	r0, #0
	mov	r0, #0      <<<<
	it	ge
	movge	r0, r4
	pop	{r4, pc}

So this is fixed.  I'm leaving this bug open as an enhancement though because the highlighted mov is redundant.
Comment 5 Steven Bosscher 2010-02-08 11:29:22 UTC
Trunk today (r156595) produces this:

repl1:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        push    {r4, lr}
        mov     r4, r0
        mov     r1, #0
        bl      __gesf2
        cmp     r0, #0
        it      lt
        movlt   r4, #0
        mov     r0, r4
        pop     {r4, pc}

Regarding the redundant mov of comment #4: There is another PR about missed implicit sets after reload, see bug 14770. I'm sure this is the same issue.

Thus, fixed.