Instruction Combine Cast (fptrunc (floor x)) -> (floor (fptrunc x))

Hi,

I have a test case would fail due to instruction combine cast
from floor to floorf.

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;
}

My question is: Is the transformation legal for this case?

Thanks,
Shiva

Hi Shiva,

Thanks for reporting this. It looks like a bug to me (from r292855). Can you file a bug report? Matt, can you fix this?

  -Hal

https://reviews.llvm.org/D31107

Hi Hal,

I don't have llvm bugzilla account yet and I send the email to
llvm-admin@lists.llvm.org last friday.
I'll file the bug as soon as I get the account.

Thanks for verify the issue.
Shiva

Should be fixed by r298312