[PATCH] D46135: [Driver, CodeGen] add options to enable/disable an FP cast optimization

Sanjay Patel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 13:43:24 PDT 2018


spatel added inline comments.


================
Comment at: docs/UsersManual.rst:1260-1265
+   Enable or disable a code generation optimization that may convert a
+   cast of a floating-point value to integer and back to floating-point
+   into the equivalent of the math libary's 'trunc()' function. This
+   optimization is disabled by default to avoid problems associated
+   with relying on the undefined behavior of an overflowing cast, but 
+   that limitation should be considered temporary. 
----------------
chandlerc wrote:
> I would phrase this the other way around (and I think the flag name is already phrased the other way around?):
> 
> """
> Enable a workaround for incorrect code that casts floating point values to integers where the floating point value is not representable in the integer type. This code is incorrect according to the language standard, but this flag will attempt to generate code to cause <insert expected behavior with the flag enabled>.
> """
> 
> Essentially, this should be more like '-fwrapv'. Also, I think the default should be what the specification says. People can explicitly pass this flag if their code is broken in this way.
Ah - did I misinterpret the earlier comments? 

I thought we need to have the work-around 'on' by default as the immediate fix for broken programs?


https://reviews.llvm.org/D46135





More information about the cfe-commits mailing list