Hi Michael,
The patch looks good in general. But I'm a bit concerned about the textural representation about these flags. 'N', 'I', 'S', 'R', 'A' seem cryptic to me. Does it make sense to expand them a bit 'nnan', 'inf', etc.? They definitely need to be documented.
Evan
Hi Michael,
The patch looks good in general. But I'm a bit concerned about the textural representation about these flags. 'N', 'I', 'S', 'R', 'A' seem cryptic to me. Does it make sense to expand them a bit 'nnan', 'inf', etc.? They definitely need to be documented.
I think it does make sense to expand them to be more readable. Also, the textual representation doesn't have to precisely follow the internal names. What about:
nnan : no nans
ninf : no infs
nsz : no signed zeros
ar: allow reciprocal
fast : unsafe algebra (and implicitly all the others)
I'll get started on documentation.
Hi Michael,
The patch looks good in general. But I'm a bit concerned about the textural representation about these flags. 'N', 'I', 'S', 'R', 'A' seem cryptic to me. Does it make sense to expand them a bit 'nnan', 'inf', etc.? They definitely need to be documented.
I think it does make sense to expand them to be more readable. Also, the textual representation doesn't have to precisely follow the internal names. What about:
nnan : no nans
ninf : no infs
nsz : no signed zeros
ar: allow reciprocal
fast : unsafe algebra (and implicitly all the others)
These seem reasonable to me. Thanks!
Evan
Trying to apply patches..
What's your base revision?
Joe
Though semantically equivalent in this case, however I think you should use logical ors here not bitwise.
- bool any() {
- return UnsafeAlgebra | NoNaNs | NoInfs | NoSignedZeros |
- AllowReciprocal;
- }
Gripe: This pattern is probably super fast and has precedence… but the code is non-obvious:
SubclassOptionalData =
(SubclassOptionalData & ~BitToSet) | (B * BitToSet);
This is likely one iota slower… but it sure is easier to get the intent.
B ? SubclassOptionalData |= BitToSet :
SubclassOptionalData &= ~BitToSet;
Otherwise looks good to me.
Joe
Though semantically equivalent in this case, however I think you should use logical ors here not bitwise.
- bool any() {
- return UnsafeAlgebra | NoNaNs | NoInfs | NoSignedZeros |
- AllowReciprocal;
- }
Will do.
Gripe: This pattern is probably super fast and has precedence… but the code is non-obvious:
SubclassOptionalData =
(SubclassOptionalData & ~BitToSet) | (B * BitToSet);
This is an existing pattern that’s used elsewhere in the file, so I had assumed it was well understood and preferred.
Michael,
Overall the code looks good.
80-cols:
2046 FMF.UnsafeAlgebra = 0 != (Record[OpNum] & (1 << bitc::FMF_UNSAFE_ALGEBRA));
2047 FMF.NoNaNs = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_NANS));
2048 FMF.NoInfs = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_INFS));
2049 FMF.NoSignedZeros = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_SIGNED_ZEROS));
2050 FMF.AllowReciprocal = 0 != (Record[OpNum] & (1 << bitc::FMF_ALLOW_RECIPROCAL));
I found some more in BitcodeReader::ParseConstants(), which I’ll scrub after this commits.
Will there be a // fmul N 1, x ==> x? perhaps a // fadd N S 0, x ==> x? as well as other arithmetic identities?
Cheers,
Joe
Michael,
Overall the code looks good.
80-cols:
2046 FMF.UnsafeAlgebra = 0 != (Record[OpNum] & (1 << bitc::FMF_UNSAFE_ALGEBRA));
2047 FMF.NoNaNs = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_NANS));
2048 FMF.NoInfs = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_INFS));
2049 FMF.NoSignedZeros = 0 != (Record[OpNum] & (1 << bitc::FMF_NO_SIGNED_ZEROS));
2050 FMF.AllowReciprocal = 0 != (Record[OpNum] & (1 << bitc::FMF_ALLOW_RECIPROCAL));
I found some more in BitcodeReader::ParseConstants(), which I’ll scrub after this commits.
Will there be a // fmul N 1, x ==> x? perhaps a // fadd N S 0, x ==> x? as well as other arithmetic identities?
Yes, that is the intent. You can see more examples in the original RFC. For you specific examples:
fmul N 1, x ==> x
I think that the ‘N’ (now spelled ‘nnan’) flag isn’t relevant to the optimization, as NaN * 1 ==> NaN.
fadd N S 0, x ==> x
Again, ‘N’ shouldn’t apply. I don’t think ‘S’ (‘nsz’) is needed here either, but it would be if it was x - 0 ==> x.