Ubuntu

cselim tree optimizer generates incorrect code

Reported by Stéphane Glondu on 2012-07-26
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
High
Matthew Gretton-Dann
gcc-4.6 (Ubuntu)
High
Unassigned
Precise
High
Unassigned

Bug Description

I think gcc (4.6.3-1ubuntu5, amd64) generates incorrect code with the attached test case.

The expected output is "m = 8241071186". However, when compiled with "-O3", it outputs "m = 1". Looking further, it seems that the following lines:

       *m = 1UL;
      ularith_div_2ul_ul_ul_r (m, 0UL, 1UL, s);

are being swapped in the assembly output.

The output is correct when compiled with "-O2" or with "-O3 -fno-tree-cselim".

On Debian (version 4.6.3-1), the output is always correct. I have reports that the output is correct with upstream gcc compiled on Ubuntu, so this behaviour looks Ubuntu-specific.

Related branches

lp:~matthew-gretton-dann/gcc-linaro/4.6-cselim-fix
Merged into lp:gcc-linaro/4.6 at revision 106911
Christophe Lyon: Approve on 2012-10-03
Michael Hope: Pending requested 2012-09-20
Stéphane Glondu (glondu) wrote :
Stéphane Glondu (glondu) wrote :

The version in quantal (4.6.3-8ubuntu1) is not affected.

Stéphane Glondu (glondu) wrote :

Sorry, I meant the default gcc (which is gcc-4.7). With gcc-4.6, I observe the same behaviour.

Stéphane Glondu (glondu) wrote :

Same issue in oneiric (4.6.1-9ubuntu3).

Stéphane Glondu (glondu) wrote :

I've tried various historic versions of the gcc-4.6 package in a clean precise chroot.

The first faulty version appears to be 4.6.0-7ubuntu1. The previous version, 4.6.0-6ubuntu3, generates correct code.

Moreover, the last version (4.6.3-1ubuntu5) with all Linaro patches out generates correct code.

Michael Hope (michaelh1) wrote :

Thank you for the bug report. I've confirmed this with gcc-linaro-4.6+bzr106903 on x86_64:

michaelh@crucis:~/linaro/bugs$ ~/linaro/gcc/build/native-4.6/install/bin/gcc -O3 testcase3.c
michaelh@crucis:~/linaro/bugs$ ./a.out
m = 1

The fault is probably introduced by r106733 which added condtional store sinking support.

I've set it to high priority as bad code is generated. Likely trunk fixes include r113242, r111593, r110,443, and r114986 of lp:gcc-linaro/4.7.

Changed in gcc-linaro:
status: New → Triaged
importance: Undecided → High
Matthias Klose (doko) on 2012-09-06
Changed in gcc-4.6 (Ubuntu):
importance: Undecided → High
milestone: none → precise-updates
status: New → Triaged

Confirmed reverting lp:gcc-linaro/4.6 r106733 fixes the issue.

Michael Hope (michaelh1) on 2012-09-11
Changed in gcc-linaro:
assignee: nobody → Matthew Gretton-Dann (matthew-gretton-dann)
tags: added: precise quantal rls-q-incoming
Matthias Klose (doko) on 2012-09-13
Changed in gcc-4.6 (Ubuntu Precise):
importance: Undecided → High
milestone: none → precise-updates
status: New → Triaged
Changed in gcc-4.6 (Ubuntu):
milestone: precise-updates → none

The revisions Michael suggested do not fix the issue - either singly or when applied on top of each other.

Investigations lead me to believe this is upstream bug PR51987 (http://gcc.gnu.org/PR51987) made visible because of the conditional store sinking support being added.

I believe upstream fix svn r183524 fixes the issue. This is currently under test

Changed in gcc-linaro:
milestone: none → 4.6-2012.10
Matthias Klose (doko) wrote :

the backport fixes the issue, no regressions running the testsuite. however the testcase fails, because 4.6 doesn't know about ia32, so s/ia32/ilp32/

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gcc-4.6 - 4.6.3-10ubuntu1

---------------
gcc-4.6 (4.6.3-10ubuntu1) quantal; urgency=low

  * Merge with Debian.

gcc-4.6 (4.6.3-10) unstable; urgency=low

  * Update to SVN 20120918 (r191439) from the gcc-4_6-branch.
    - Fix PR c/54552 (ice on valid), PR c/54103 (ice on valid),
      PR target/54536 (AVR), PR middle-end/54515 (ice on valid),
      PR target/45070 (ARM, wrong code), PR target/54220 (AVR),
      PR driver/54335, PR rtl-optimization/54369 (mips, wrong code),
      PR c++/54511 (ice on valid), PR fortran/54225 (ice on invalid),
      PR fortran/53306 (ice on invalid), PR fortran/54556 (wrong code),
      PR fortran/54208 (rejects valid).

  [ Nobuhiro Iwamatsu ]
  * Remove sh4-enable-ieee.diff, -mieee enabled by default. Closes: #685974.

  [ Matthias Klose ]
  * Fix PR tree-optimization/51987, backport from the trunk, Linaro only
   (Matthew Gretton-Dann). LP: #1029454.
 -- Matthias Klose <email address hidden> Tue, 18 Sep 2012 22:44:00 +0200

Changed in gcc-4.6 (Ubuntu):
status: Triaged → Fix Released
Changed in gcc-linaro:
status: Triaged → In Progress
Changed in gcc-linaro:
status: In Progress → Fix Committed
Changed in gcc-linaro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments