[llvm-commits] [llvm-gcc-4.2] r55796 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dale Johannesen
dalej at apple.com
Fri Sep 5 11:01:45 PDT 2008
On Sep 5, 2008, at 1:11 AMPDT, Duncan Sands wrote:
> Hi Dale,
>
>> Use new math intrinsics only when errno is not in use.
>> They are marked as not touching memory.
>
> this is not enough. Some gcc math builtins may be marked
> readonly, not readnone (= does not touch memory). It is
> then wrong to promote them to the readnone llvm intrinsics.
> Please replace the errno test with a check something like
> this:
>
> if (flags_from_decl_or_type(exp) & ECF_CONST)
>
> This will automatically handle the errno case.
>
> Thanks,
>
> Duncan.
>
> PS: gcc marks some math functions readonly ("pure") if
> their result depends on the floating point rounding mode.
> This is correct, and it would be wrong to promote to
> readnone in this case.
This doesn't do the right thing for Darwin, and is inconsistent with
the existing handling of sqrt, which is explicitly tested in the
testsuite.
The difficulty does seem to be the rounding mode. I don't agree that
reading the rounding mode should prevent marking things "readnone";
the description can be read that way, but it's pretty clear whoever
wrote it wasn't thinking of rounding mode. Rounding mode is not
memory. There is no reason a libcall that reads rounding mode, but
doesn't touch memory, can't be moved across loads and stores. (It
can't be moved across instructions that change the rounding mode, but
we don't currently model that, and this consideration is orthogonal to
touching memory.)
More information about the llvm-commits
mailing list