diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-06-27 18:16:40 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-06-27 18:16:40 +0000 |
| commit | d052de856d83095bf687755fb0c7c47e916956c8 (patch) | |
| tree | f386aa2189c05ee1d68b025e95dea63eb6e82f7e /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | 7e7b13d016f6f216c83dde5b925a937ef4cf3072 (diff) | |
| download | llvm-d052de856d83095bf687755fb0c7c47e916956c8.zip llvm-d052de856d83095bf687755fb0c7c47e916956c8.tar.gz llvm-d052de856d83095bf687755fb0c7c47e916956c8.tar.bz2 | |
[DAGCombiner] restrict (float)((int) f) --> ftrunc with no-signed-zeros
As noted in the D44909 review, the transform from (fptosi+sitofp) to ftrunc
can produce -0.0 where the original code does not:
#include <stdio.h>
int main(int argc) {
float x;
x = -0.8 * argc;
printf("%f\n", (float)((int)x));
return 0;
}
$ clang -O0 -mavx fp.c ; ./a.out
0.000000
$ clang -O1 -mavx fp.c ; ./a.out
-0.000000
Ideally, we'd use IR/node flags to predicate the transform, but the IR parser
doesn't currently allow fast-math-flags on the cast instructions. So for now,
just use the function attribute that corresponds to clang's "-fno-signed-zeros"
option.
Differential Revision: https://reviews.llvm.org/D48085
llvm-svn: 335761
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions
