public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi
@ 2011-12-04 13:15 kazu at gcc dot gnu.org
  2011-12-05 16:12 ` [Bug target/51408] " kazu at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-04 13:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

             Bug #: 51408
           Summary: Miscompilation in arm.md:*minmax_arithsi
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kazu@gcc.gnu.org


The following testcase, reduced from efgcvt_r.c:fcvt_r in glibc, gets
miscompiled:

extern void abort (void);

int __attribute__((noinline))
foo (int a, int b)
{
  int max = (b > 0) ? b : 0;
  return max - a;
}

int
main (void)
{
  if (foo (3, -1) != -3)
    abort ();
  return 0;
}

arm-none-eabi-gcc -O1 generates:

foo:
    @ Function supports interworking.
    @ args = 0, pretend = 0, frame = 0
    @ frame_needed = 0, uses_anonymous_args = 0
    @ link register save eliminated.
    cmp    r1, #0
    rsbge    r0, r0, r1
    bx    lr

This would be equivalent to:

  return b >= 0 ? b - a : a;

which is different from:

  return b >= 0 ? b - a : -a;

That is, in assembly code, we should have an "else" clause like so:

    cmp    r1, #0
    rsbge    r0, r0, r1  <- then clause
    rsblt    r0, r0, #0  <- else clause
    bx    lr

This bug comes from gcc/config/arm/arm.md:*minmax_arithsi, not
outputting an else clause on the MINUS case.

I've tested a patch and will post it shortly.


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
@ 2011-12-05 16:12 ` kazu at gcc dot gnu.org
  2011-12-05 16:15 ` kazu at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-05 16:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

--- Comment #1 from Kazu Hirata <kazu at gcc dot gnu.org> 2011-12-05 16:11:43 UTC ---
Author: kazu
Date: Mon Dec  5 16:11:35 2011
New Revision: 182014

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182014
Log:
gcc/
    PR target/51408
    * config/arm/arm.md (*minmax_arithsi): Always require the else
    clause in the MINUS case.

gcc/testsuite/
    PR target/51408
    * gcc.dg/pr51408.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/pr51408.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.md
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
  2011-12-05 16:12 ` [Bug target/51408] " kazu at gcc dot gnu.org
@ 2011-12-05 16:15 ` kazu at gcc dot gnu.org
  2011-12-09  1:46 ` kazu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-05 16:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

Kazu Hirata <kazu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Kazu Hirata <kazu at gcc dot gnu.org> 2011-12-05 16:15:18 UTC ---
Fixed on trunk.


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
  2011-12-05 16:12 ` [Bug target/51408] " kazu at gcc dot gnu.org
  2011-12-05 16:15 ` kazu at gcc dot gnu.org
@ 2011-12-09  1:46 ` kazu at gcc dot gnu.org
  2011-12-09  2:22 ` kazu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-09  1:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

--- Comment #3 from Kazu Hirata <kazu at gcc dot gnu.org> 2011-12-09 01:27:05 UTC ---
Author: kazu
Date: Fri Dec  9 01:27:01 2011
New Revision: 182149

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182149
Log:
gcc/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * config/arm/arm.md (*minmax_arithsi): Always require the else
    clause in the MINUS case.

testsuite/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * gcc.dg/pr51408.c: New.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr51408.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/arm/arm.md
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-12-09  1:46 ` kazu at gcc dot gnu.org
@ 2011-12-09  2:22 ` kazu at gcc dot gnu.org
  2011-12-09  5:20 ` kazu at gcc dot gnu.org
  2012-06-08  6:58 ` jye2 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-09  2:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

--- Comment #4 from Kazu Hirata <kazu at gcc dot gnu.org> 2011-12-09 01:45:57 UTC ---
Author: kazu
Date: Fri Dec  9 01:45:54 2011
New Revision: 182150

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182150
Log:
gcc/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * config/arm/arm.md (*minmax_arithsi): Always require the else
    clause in the MINUS case.

testsuite/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * gcc.dg/pr51408.c: New.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr51408.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/arm/arm.md
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-12-09  2:22 ` kazu at gcc dot gnu.org
@ 2011-12-09  5:20 ` kazu at gcc dot gnu.org
  2012-06-08  6:58 ` jye2 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kazu at gcc dot gnu.org @ 2011-12-09  5:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

--- Comment #5 from Kazu Hirata <kazu at gcc dot gnu.org> 2011-12-09 05:03:08 UTC ---
Author: kazu
Date: Fri Dec  9 05:02:59 2011
New Revision: 182153

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182153
Log:
gcc/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * config/arm/arm.md (*minmax_arithsi): Always require the else
    clause in the MINUS case.

testsuite/
    Backport from mainline:

    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * gcc.dg/pr51408.c: New.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr51408.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/arm/arm.md
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


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

* [Bug target/51408] Miscompilation in arm.md:*minmax_arithsi
  2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-12-09  5:20 ` kazu at gcc dot gnu.org
@ 2012-06-08  6:58 ` jye2 at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jye2 at gcc dot gnu.org @ 2012-06-08  6:58 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51408

--- Comment #6 from jye2 at gcc dot gnu.org 2012-06-08 06:58:32 UTC ---
Author: jye2
Date: Fri Jun  8 06:58:25 2012
New Revision: 188327

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188327
Log:
Backport mainline r179607, r179979, r179980, r181416, r182014
2012-06-08  Joey Ye  <joey.ye@arm.com>

    Backport r182014 from mainline.
    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * config/arm/arm.md (*minmax_arithsi): Always require the else
    clause in the MINUS case.

    Backport r181416 from mainline.
    2011-11-16  Richard Earnshaw  <rearnsha@arm.com>
        Bernd Schmidt <bernds@coudesourcery.com>
        Sebastian Huber <sebastian.huber@embedded-brains.de>

    PR target/49641
    * config/arm/arm.c (store_multiple_sequence): Avoid cases where
    the base reg is stored iff compiling for Thumb1.

    Backport r179980 from mainline.
    2011-10-14  David Alan Gilbert  <david.gilbert@linaro.org>

    PR target/48126
    * config/arm/arm.c (arm_output_sync_loop): Move label before barrier.

    Backport r179979 from mainline.
    2011-10-14  David Alan Gilbert  <david.gilbert@linaro.org>

    * config/arm/arm.h (TARGET_HAVE_DMB_MCR): MCR Not available in Thumb1.

    Backport r179607 from mainline.
    2011-10-06  Bernd Schmidt  <bernds@codesourcery.com>

    PR target/49049
    * config/arm/arm.md (arm_subsi3_insn): Lose the last alternative.

Testsuites:
    Backport r182014 from mainline
    2011-12-05  Kazu Hirata  <kazu@codesourcery.com>

    PR target/51408
    * gcc.dg/pr51408.c: New.

    Backport r181416 from mainline
    2011-11-16  Richard Earnshaw  <rearnsha@arm.com>
        Bernd Schmidt <bernds@coudesourcery.com>
        Sebastian Huber <sebastian.huber@embedded-brains.de>

    PR target/49641
    * gcc.target/arm/pr49641.c: New test.

    Backport r179607 from mainline
    2011-10-06  Bernd Schmidt  <bernds@codesourcery.com>

    PR target/49049
    * gcc.c-torture/compile/pr49049.c: New test.


Added:
   
branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.c-torture/compile/pr49049.c
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/pr51408.c
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.target/arm/pr49641.c
Modified:
    branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm
    branches/ARM/embedded-4_6-branch/gcc/config/arm/arm.c
    branches/ARM/embedded-4_6-branch/gcc/config/arm/arm.h
    branches/ARM/embedded-4_6-branch/gcc/config/arm/arm.md
    branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm


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

end of thread, other threads:[~2012-06-08  6:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-04 13:15 [Bug target/51408] New: Miscompilation in arm.md:*minmax_arithsi kazu at gcc dot gnu.org
2011-12-05 16:12 ` [Bug target/51408] " kazu at gcc dot gnu.org
2011-12-05 16:15 ` kazu at gcc dot gnu.org
2011-12-09  1:46 ` kazu at gcc dot gnu.org
2011-12-09  2:22 ` kazu at gcc dot gnu.org
2011-12-09  5:20 ` kazu at gcc dot gnu.org
2012-06-08  6:58 ` jye2 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).