Skip to content

Missing constant folding for atan with -ffast-math on llvm 20.1.0 #143360

Closed
@amitch1999

Description

@amitch1999

Hi,
Compiling this simple test, which is taken from gcc's regression, works on llvm 18.1.7, but gets a link error on llvm 20.1.0 (undefined reference to 'link_error')

Compiled using clang test.c -O2 -ffast-math -lm
On llvm 20 & 18, without the -ffast-math flag, compilation passes.
(my default march is rv32imc, but I tried if with a couple different march's(32/64, with/out f, with/out d) with the same result)

extern void link_error(void);

extern double atan(double);

int main()
{
  if (atan(1.0) < 0.78 || atan(1.0) > 0.79)
    link_error(); /* expected to be optimized out */

  return 0;
}

Is this expected?

EDIT: upon more tries, it seems not to be RISCV specific issue, as I also tried it with -target x86_64-linux-gnu and got the same result. Leaving the [RISCV] for now, because I'm not sure what label I should use (maybe clang:codegen?)

Metadata

Metadata

Assignees

Labels

constant-foldingProblems related to constant folding in the optimizerfloating-pointFloating-point math

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions