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

Chandler Carruth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 26 13:47:59 PDT 2018


chandlerc 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. 
----------------
spatel wrote:
> 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?
Maybe others feel strongly about the default. I'm happy to explicitly pass a flag for our code until we get it fixed here.

I would suggest starting by adding the flag to toggle the behavior but not changing the default (which as of now is 'optimize, no workaround') and then we can invert the default if we get enough feedback that this is causing users problems.

Either way, I'd word this as suggested above.


https://reviews.llvm.org/D46135





More information about the cfe-commits mailing list