clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

[PPC] bad code generation for -O0 - arithmetic #47

Closed nenadv closed 10 years ago

nenadv commented 10 years ago

Test bug137c fails to produce the right result. Has nothing to do with UPC and I am able to reproduce the problem on the LLVM/CLANG trunk and this simple code:

#include <stdarg.h>
#include <stdio.h>
#include <string.h>

int x = 1;
int q = 1;
double y = 7.0;

double foo() {
  double d = x + y + q;
  printf("fooL %g\n", d);
  return d;
}

int main(void) {

  double b = foo();
  if (b != 9.0) {
    printf("FAILED (result = %g but expect 9.0)\n", b);
  } else {
    printf("SUCCESS\n");
  }
}

This test fails on -O0 only. IR looks fine, it must be LLVM code generation problem.

I'll see where to file LLVM bugs.

PHHargrove commented 10 years ago

Nenad,

I can reproduce on a Power7 at NCSA, where clang was built with gcc-4.6:

[hargrov1@bd-login ~]$ ./opt/llvm-intrepid/bin/clang -O bug.c
[hargrov1@bd-login ~]$ ./a.out 
fooL 9
SUCCESS
[hargrov1@bd-login ~]$ ./opt/llvm-intrepid/bin/clang -O0 bug.c
[hargrov1@bd-login ~]$ ./a.out 
fooL 8.58994e+09
FAILED (result = 8.58994e+09 but expect 9.0)
nenadv commented 10 years ago

I filed this: http://llvm.org/bugs/show_bug.cgi?id=19144

Paul, I was not able to add you to the cc list. You probably need to create an account at their bugzilla.

nenadv commented 10 years ago

I am seeing some other tests failing the same way when double and -O0 is involved (e.g. bug1557.upc). I'll try to run harness with optimizations and see what the difference is.

nenadv commented 10 years ago

Fixed by https://github.com/Intrepid/llvm-upc/commit/322d5a425a9ac6a24c69e23a5aa7c88213c1f790