Transferring programs from one architecture to another

Warn immediately that this is a difficult task.

There is a test. The test was the result of parsing a big problem for the error that we encountered at work. The design __ attribute__((noinline))forbids the compiler to perform the replacement function (for optimization, something did not explode there). This is the easiest way to optimize guaranteed so as not to kill an interesting situation.

#include <stdio.h>

double d = 5436277361664796672.000000;
long long ll = 5436277361664796253LL;

int __attribute__((noinline))
func1 (void)
{
  double d1 = (double)ll;

  if (d > d1)
    return 1;
  else
    return 0;
}

int __attribute__((noinline))
func2 (void)
{
  if (d > (double)ll)
    return 1;
  else
    return 0;
}

int
main (void)
{
  printf ("%d %d\n", func1(), func2());
  return 0;
}

I conducted this test on inteland sparc. GccIt is used in the mode with optimization and without optimization. Got the following results:

sparc: "gcc" printed "0 0"
sparc: "gcc -O2" printed "0 0"
intel: "gcc" printed "0 1"
intel: "gcc -O2" printed "1 1"

? , , , sparc. sparc Windows microsoft or borland C compiler. , , - ( )

1 _attribute_ ((noinline)) - gcc ( ). VisualStudio .

+3
2

, . , . sparc . int64-> float64 . , ( intel) int64-> float80, . .. Intel , .

, Intel, . , , ( )

0

, 19 , , ​​ IEEE ( 15 17 ). d 5436277361664796672.000000 .

16- , , , . , .

, ++ , , double, , undefined, .

+1

All Articles