[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csmith-dev] Testing floating point optimizations with CSmith


My name is Jacek Burys and I'm a Computing student at Imperial College London.

My research project for the summer is to use CSmith to test floating point optimizations in C compilers. The general idea is to use interval arithmetics to obtain ranges of where each float variable should fall into. Running the program in float_test mode would give us the interval, while running it in the normal mode would give us the actual value. Then we just need to see if the value lies inside the interval.

Here is a link to my github branch

At this point you can generate programs that can be run in normal and float_test mode (there is FLOAT_TEST_INSTRUCTIONS.txt file that could help). I had some problems with linking and did not know how to modify the Makefile, so runtime/FloatTest.c has to be compiled along with the generated program (example in instructions; if anybody could give me a hint how to fix that I would be grateful).

I don't do anything with the intervals yet, just return [0,0].

I followed Alastairs advise to add

>           if (t->is_float() && !(var->type->is_float())) {
>               valid = false;
>           }

There was another problem with comparison operators.
BinaryOpWorksForFloat(eBinaryOps op) would return true for comparison operators, leading to CSmith telling me that, for example, type of (x < y) is eFloat, while it actually is int. It was only after I changed it to return false for comparison operators, that I could compile the generated programs. Would there be a way to make CSmith keep eInt for results of comparison operations?

I think these changes had an impact on how interesting the generated programs are. They are also longer, and take more time to generate.

Jacek Burys