LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27681 - wrong code at -O3 in 32-bit mode on x86_64-linux-gnu
Summary: wrong code at -O3 in 32-bit mode on x86_64-linux-gnu
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 27580 27804 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-05-09 05:27 PDT by Chengnian Sun
Modified: 2016-09-08 10:54 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chengnian Sun 2016-05-09 05:27:58 PDT
The following code is miscompiled by clang-trunk at -O3 in 32-bit mode on x86_64-linux-gnu. 


$: clang-trunk -v
clang version 3.9.0 (trunk 268870)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.4
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$: 
$: clang-trunk -O3 -m32 small.c 
$: ./a.out 
Floating point exception (core dumped)
$: clang-trunk -O2 -m32 small.c 
$: ./a.out 
$: cat small.c
int a, i;
unsigned short b, c = 4, d = 5, e, f, g;
long long h;
void fn1() {
  int j = 0;
  for (; a;)
  L1:;
  unsigned char k = e;
  if (f) {
  L2:
    h = b % h & k;
    goto L1;
  }
  int l = j;
  int m = ~i * d;
  j = ~(g || d) ^ d >> (h && c) * m;
  e = (d || m) + d;
  d = ~ - (d && m >> i) & ~(j && (l || h));
  if (!(d < c))
    goto L2;
}

int main() { fn1(); return 0;}
$:
Comment 1 David Majnemer 2016-05-09 11:24:35 PDT
Bisect points to r267809:
Author: Mitch Bodart <mitch.l.bodart@intel.com>
Date:   Wed Apr 27 22:52:35 2016 +0000

    [X86] Enable the post-RA-scheduler for clang's default 32-bit cpu.
    
    For compilations with no explicit cpu specified, this exhibits
    nice gains on Silvermont, with neutral performance on big cores.
    
    Differential Revision: http://reviews.llvm.org/D19138

Mitch, can you please take a look?
Comment 2 David Majnemer 2016-05-18 10:47:05 PDT
*** Bug 27804 has been marked as a duplicate of this bug. ***
Comment 3 Hans Wennborg 2016-08-03 17:45:10 PDT
I can't reproduce this on 3.9 or trunk. Was it fixed?
Comment 4 Sanjay Patel 2016-08-03 17:50:33 PDT
Yep - this was fixed with:
https://reviews.llvm.org/rL270935
Comment 5 Sanjay Patel 2016-08-04 09:23:07 PDT
*** Bug 27580 has been marked as a duplicate of this bug. ***