llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[InsnCombine] (fptrunc (floor x)) -> (floor (fptrunc x))

Open ShivaChen opened this issue 9 years ago • 1 comments

Bugzilla Link 32386
Resolution FIXED
Resolved on Mar 23, 2017 00:47
Version trunk
OS Linux
CC @hfinkel

Extended Description

The test case fail due to instruction combine cast from floor to floorf which make precision lost and get wrong floor value.

double d = 1024.0 - 1.0 / 32768.0; extern double floor(double); extern float floorf(float); extern void abort();

int main() {

float f1 = (float)floor(d);

if ((int)f1 != 1023)
  abort ();

return 0;

}

ShivaChen avatar Mar 23 '17 07:03 ShivaChen

The bug verify by Hal and Fix by Matt with r298312.

ShivaChen avatar Mar 23 '17 07:03 ShivaChen