Page MenuHomePhabricator
Feed Advanced Search

Thu, Aug 8

scanon added inline comments to D65303: [BPI] Adjust the probability for floating point unordered comparison.
Thu, Aug 8, 9:04 AM · Restricted Project
scanon added a comment to D65303: [BPI] Adjust the probability for floating point unordered comparison.

It's not that NaN is rare in normal programs, or that it indicates a bug in the code. It's that testing for NaN is usually an indication that you're testing for an exceptional case, and it makes sense to move those off the hot path (i.e. NaN is actually pretty common, but the likelihood of handling it on the normal-value path through code is small).

Thu, Aug 8, 9:04 AM · Restricted Project

Tue, Aug 6

scanon added a comment to D65753: Builtins: Add some v2f16 variants.

(Ideally we would just call them e.g. builtin_floor, but that would be source-breaking. builtin_tgmath_floor seems like a good compromise.)

Tue, Aug 6, 1:03 PM
scanon added a comment to D65753: Builtins: Add some v2f16 variants.

Strongly agree with what @rjmccall said. If we can make these generic builtins instead of ending up with O(100) variants of each math operation, that would make life immensely nicer.

Tue, Aug 6, 1:03 PM

Fri, Jul 26

scanon requested changes to D65303: [BPI] Adjust the probability for floating point unordered comparison.
Fri, Jul 26, 6:33 AM · Restricted Project

Wed, Jul 24

scanon accepted D65235: CrashHandler: be careful about crashing while handling.

LGTM

Wed, Jul 24, 12:03 PM · Restricted Project

Mon, Jul 22

scanon requested changes to D54749: Saturating float to int casts: Basics [1/n].

Reviewers: what do we need to get this across the finish line?

Mon, Jul 22, 1:28 PM · Restricted Project

Jul 16 2019

scanon accepted D64666: [Sema] Enable -Wimplicit-int-float-conversion for integral to floating point precision loss.

LGTM. Please get at least one additional reviewer's approval before merging, as this is a corner of clang that I don't work on often.

Jul 16 2019, 10:53 AM · Restricted Project, Restricted Project

Jul 15 2019

scanon requested changes to D64666: [Sema] Enable -Wimplicit-int-float-conversion for integral to floating point precision loss.
Jul 15 2019, 10:50 AM · Restricted Project, Restricted Project

May 30 2019

scanon accepted D62708: Fix the predefined exponent limit macros for the 16-bit IEEE format..
May 30 2019, 5:43 PM · Restricted Project

Mar 11 2019

scanon accepted D59070: [builtins] Divide shouldn't underflow if rounded result would be normal..

Ah, now I see what you're talking about. And in fact, because of the way divide works out, there's a little gap of results that are even possible to achieve just below each binade boundary, so the code you have here will work out fine. We *should* add a comment to clarify this somewhat, but I'm happy to do that in a separate commit. LGTM.

Mar 11 2019, 5:21 PM · Restricted Project, Restricted Project
scanon added a comment to D59070: [builtins] Divide shouldn't underflow if rounded result would be normal..

These results *are* tiny in the before rounding sense.

Mar 11 2019, 4:53 PM · Restricted Project, Restricted Project
scanon requested changes to D59070: [builtins] Divide shouldn't underflow if rounded result would be normal..

In the parlance of IEEE 754, there are two ways to "detect tininess": "before rounding" and "after rounding". The standard doesn't define how to flush subnormal results, but in practice most HW flushes results that are "tiny". The existing code flushes as though tininess is detected before rounding. This proposed update flushes as though tininess were detected after rounding.

Mar 11 2019, 4:37 PM · Restricted Project, Restricted Project

Jan 25 2019

scanon updated subscribers of D57188: Disable _Float16 for non ARM/SPIR Targets.

do we want to support _Float16 anywhere else?

ARM is the only in-tree target with a defined ABI that I'm aware of.

Jan 25 2019, 9:30 AM

Jan 11 2019

scanon added a reviewer for D56596: Enable fma formation for fp16 on x86 and aarch64: ahatanak.
Jan 11 2019, 5:50 AM
scanon created D56596: Enable fma formation for fp16 on x86 and aarch64.
Jan 11 2019, 5:48 AM

Dec 17 2018

scanon added a comment to D55531: AsmParser: test .double NaN.

Can you also add a check for .double infinity? It looks like that's likely missing too.

Dec 17 2018, 10:44 AM
scanon accepted D55531: AsmParser: test .double NaN.

Shrug. OK.

Dec 17 2018, 10:40 AM

Dec 7 2018

scanon requested changes to D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch..
Dec 7 2018, 12:05 PM
scanon added inline comments to D48342: [libcxx] Optimize vectors construction of trivial types from an iterator range with const-ness mismatch..
Dec 7 2018, 12:04 PM

Oct 9 2018

scanon added a comment to D53004: [WebAssembly] Saturating float to int intrinsics.

Are these documented anywhere? I haven't seen it in any of the patches so far. What do they return for NaN inputs?

Oct 9 2018, 9:53 AM

Oct 3 2018

scanon added inline comments to D52835: [Diagnostics] Check integer to floating point number implicit conversions.
Oct 3 2018, 12:40 PM

Sep 24 2018

scanon added a comment to D49514: [compiler-rt] [builtins] Add logb/logbf/logbl methods to compiler-rt to avoid libm dependencies when possible..

I suspect that we'd rather use ilogb in the long term, but as a like-for-like replacement this looks OK.

Sep 24 2018, 10:12 AM

Jul 19 2018

scanon committed rL337523: Add x86_64-unkown triple to llc for x86 test..
Add x86_64-unkown triple to llc for x86 test.
Jul 19 2018, 8:56 PM
scanon committed rL337506: Skip out of SimplifyDemandedBits for BITCAST of f16 to i16.
Skip out of SimplifyDemandedBits for BITCAST of f16 to i16
Jul 19 2018, 3:51 PM
scanon closed D49524: Avoid generating FGETSIGN for f16.
Jul 19 2018, 3:51 PM
scanon added inline comments to D49561: AMDGPU: Try to make isKnownNeverSNan more accurate.
Jul 19 2018, 2:42 PM
scanon added inline comments to D49561: AMDGPU: Try to make isKnownNeverSNan more accurate.
Jul 19 2018, 2:41 PM
scanon added a comment to D49524: Avoid generating FGETSIGN for f16.
In D49524#1168723, @ab wrote:

I wouldn't be surprised if it failed on some target that can't even handle half parameters

Jul 19 2018, 1:47 PM

Jul 18 2018

scanon updated the diff for D49524: Avoid generating FGETSIGN for f16.
Jul 18 2018, 5:22 PM
scanon created D49524: Avoid generating FGETSIGN for f16.
Jul 18 2018, 4:59 PM

May 22 2018

scanon requested changes to D46926: [Fixed Point Arithmetic] Conversion between Fixed Point and Floating Point Numbers.

IIRC the optimization of divide-by-power-of-two --> multiply-by-inverse does not occur at -O0, so it would be better to multiply by 2^(-fbits) instead.

May 22 2018, 7:06 AM · Restricted Project

May 10 2018

scanon accepted D46499: [Support] Add docs for 'openFileFor{Write,Read}'.

LGTM, thanks!

May 10 2018, 2:19 PM

May 9 2018

scanon added a comment to D46499: [Support] Add docs for 'openFileFor{Write,Read}'.

One more question: the caller is responsible for closing the file when they're done, right?

May 9 2018, 8:57 AM
scanon added a comment to D46499: [Support] Add docs for 'openFileFor{Write,Read}'.

Two quick notes as someone who has never used these functions:

  • Name is really the *path* of the file to open, right?
  • What happens to ResultFD if the function fails?
May 9 2018, 8:52 AM

May 8 2018

scanon accepted D41868: APFloat/x87: Fix string conversion for "unnormal" values (pr35860).

LGTM

May 8 2018, 8:34 AM

May 4 2018

scanon added a comment to D46042: Cap vector alignment at 16 for all Darwin platforms.
In D46042#1088044, @ab wrote:

So, this makes sense to me, but on x86, should we also be worried about the fact that the calling convention is based on which features are available? (>128bit ext_vector_types are passed in AVX/AVX-512 registers, if available). Presumably swift is also affected, no?

May 4 2018, 10:50 AM

Apr 26 2018

scanon added a comment to D46135: [Driver, CodeGen] add options to enable/disable an FP cast optimization.

I like Chandler's wording. Something like:

Apr 26 2018, 1:51 PM

Apr 25 2018

scanon updated subscribers of D30527: Replacing float with new class Fraction for LSR alternative way of resolving complex solution.

@gottesmm can you take a look at this? You're more familiar with the APFloat API than I am.

Apr 25 2018, 7:28 AM

Apr 20 2018

scanon added a comment to rL330437: [DAGCombine] (float)((int) f) --> ftrunc (PR36617).

Tangential question: Do we have an intrinsic floating -> integer conversion with defined semantics for out-of-range values?

Apr 20 2018, 8:43 AM

Apr 6 2018

scanon added a comment to D45336: Apply accumulator to fadd/fmul experimental vector reductions (PR36734).

it should really be the default in both LLVM and source languages except where there's an explicit constraint that forces linear reduction.

Tree reductions is what Rust portable packed SIMD RFC [0] currently specifies.

Apr 6 2018, 10:06 AM
scanon added a comment to D45336: Apply accumulator to fadd/fmul experimental vector reductions (PR36734).

I also wonder whether requiring fast-math to allow tree reductions is overkill. Tree reductions can be implemented reasonably efficiently in many architectures, while linearly ordered reduction appear to me to be more of a niche.

Apr 6 2018, 8:19 AM

Mar 26 2018

scanon added a comment to D44909: [DAGCombine] (float)((int) f) --> ftrunc (PR36617).

Two questions, to which I do not know the answer:

(a) Are the semantics of ISD::FP_TO_[US]INT for out-of-range values specified anywhere? The do not seem to be, but maybe I'm just missing it.

No, I don't see anything either. We just have:

/// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
/// integer.

I was assuming these nodes follow the same rules as the IR instructions since they are mapped 1-to-1 in SelectionDAGBuilder::visitFPToSI() etc.

Mar 26 2018, 5:36 PM
scanon added a comment to D44909: [DAGCombine] (float)((int) f) --> ftrunc (PR36617).

Two questions, to which I do not know the answer:

Mar 26 2018, 5:08 PM
scanon added a comment to D44909: [DAGCombine] (float)((int) f) --> ftrunc (PR36617).

This is the class of optimizations that I would call "formally allowed by the standard, but extremely likely to break things and surprise people." Which isn't to say that we shouldn't do it, just ... be prepared.

Mar 26 2018, 2:57 PM

Mar 20 2018

scanon accepted D44318: [LangRef] describe the default FP environment.

I'm OK with this.

Mar 20 2018, 8:08 AM

Mar 16 2018

scanon added inline comments to D44521: [InstSimplify] fp_binop X, NaN --> NaN.
Mar 16 2018, 9:37 AM

Mar 5 2018

scanon added a comment to D43765: [InstSimplify] loosen FMF for sqrt(X) * sqrt(X) --> X.

IIRC Intrinsic::sqrt is undef for negative inputs (unlike the sqrt libcall), so we don't need FMF.noNaNs to license this transformation.

Mar 5 2018, 8:56 AM

Mar 2 2018

scanon accepted D44038: [InstCombine] Rewrite the binary op shrinking in visitFPTrunc to avoid creating overly small ConstantFPs that we'll just need to extend again..

Works for me.

Mar 2 2018, 12:07 PM
scanon accepted D43970: [InstCombine] Allow fptrunc (fpext X)) to be reduced to a single fpext/ftrunc.

LGTM.

Mar 2 2018, 10:05 AM
scanon added inline comments to D43970: [InstCombine] Allow fptrunc (fpext X)) to be reduced to a single fpext/ftrunc.
Mar 2 2018, 8:45 AM

Mar 1 2018

scanon added a comment to D43970: [InstCombine] Allow fptrunc (fpext X)) to be reduced to a single fpext/ftrunc.

We should be able to go farther and just do a fptrunc if SrcSize > DstSize.

Mar 1 2018, 2:02 PM

Feb 7 2018

scanon added a comment to D42879: InstCombine: 1./x >= 0. -> x >= 0..

In that case, you still have trouble because even 1/x can produce zero if someone is running with flush-to-zero enabled.

IIUC, we also have out-of-tree targets with no option; they always operate with FTZ behavior.

I think it's still possible to allow this kind of transform in instcombine with more fast-math-flags. Clang/gcc's -fassociative-math translates indirectly to 'reassoc' in IR FMF and says it may "reorder floating-point comparisons".

Feb 7 2018, 8:37 AM · Restricted Project

Feb 6 2018

scanon added a comment to D42879: InstCombine: 1./x >= 0. -> x >= 0..

Underflow or overflow doesn't change sign, so 0 < C < inf && X >= 0 --> C/X >= 0.

It doesn't change the sign. However we have to differentiate between three cases here: negative, null (or minus null), and positive.

Underflow can change a value from positive or negative to null.
My understanding is that in case of underflow of large positive X the expression C/X <= 0 may be true while X <= 0 is not.

Feb 6 2018, 4:26 PM · Restricted Project
scanon added a comment to D42879: InstCombine: 1./x >= 0. -> x >= 0..

Underflow or overflow doesn't change sign, so 0 < C < inf && X >= 0 --> C/X >= 0.

Feb 6 2018, 4:08 PM · Restricted Project

Jan 25 2018

scanon added a comment to D41868: APFloat/x87: Fix string conversion for "unnormal" values (pr35860).

(After checking the architecture manual)

Jan 25 2018, 7:16 AM
scanon added a comment to D41868: APFloat/x87: Fix string conversion for "unnormal" values (pr35860).

My recollection is that on 386 and later unnormals with a zero significand are treated as an invalid operand; should these print as 0 or as NaN?

Jan 25 2018, 6:00 AM

Dec 4 2017

scanon accepted D40792: DAG: Match truncated rotation (PR35487).

Yup, there's likely something more general that we could match, but it's also worth taking this as is.

Dec 4 2017, 11:09 AM

Nov 27 2017

scanon added a comment to D37989: InstCombine: Insert missing canonicalizes.

IEEE 754 rules are that everything canonicalizes except bitwise operations (copy, abs, negate, copysign) and decimal re-encoding operations (which you don't care about).

Does this mean that we need to make all other float optimizations in LLVM do the same?

for example, we cannot optimize fmul(x, 1) to x, we must optimize it to fcanonicalize(x), right? thus preventing pretty much all float optimizations, since presumably that will act as a barrier.

Nov 27 2017, 11:23 AM
scanon added a comment to D37989: InstCombine: Insert missing canonicalizes.

IEEE 754 rules are that everything canonicalizes except bitwise operations (copy, abs, negate, copysign) and decimal re-encoding operations (which you don't care about).

Nov 27 2017, 11:05 AM

Oct 30 2017

scanon accepted D39225: Fix APFloat mod sign.

mod is not bound to the IEEE 754 remainder operation. It binds the C fmod operation. You're looking for the remainder operation.

Oct 30 2017, 9:32 AM

Sep 13 2017

scanon accepted D34695: _Float16 preprocessor macro definitions.

LGTM as well.

Sep 13 2017, 8:18 AM

Sep 12 2017

scanon added inline comments to D34695: _Float16 preprocessor macro definitions.
Sep 12 2017, 8:59 AM
scanon added inline comments to D34695: _Float16 preprocessor macro definitions.
Sep 12 2017, 8:36 AM

Sep 6 2017

scanon accepted D35222: InstSimplify: canonicalize is idempotent.

LGTM. Sorry that I didn't see this earlier.

Sep 6 2017, 8:30 AM

Aug 21 2017

scanon requested changes to D36961: [APFloat] Fix IsInteger() for DoubleAPFloat.

... except, please add another test-case where the other component is not an integer as well.

Aug 21 2017, 9:37 AM
scanon accepted D36961: [APFloat] Fix IsInteger() for DoubleAPFloat.

This looks fine.

Aug 21 2017, 9:35 AM

Aug 4 2017

scanon added a comment to D28335: [WIP] [RFC] Don't lower floating point intrinsics to libcalls which modify errno.

Huh, I guess we do use the x87 sin/cos. It's probably a terrible idea (the microcoded routines are both slow and wildly inaccurate for large inputs), but we do it.

Aug 4 2017, 4:08 PM

Mar 31 2017

scanon committed rL299257: Fix 80-column violation in previous commit..
Fix 80-column violation in previous commit.
Mar 31 2017, 1:47 PM
scanon committed rL299256: Fix APFloat mod (committing for simonbyrne).
Fix APFloat mod (committing for simonbyrne)
Mar 31 2017, 1:44 PM
scanon closed D29346: Fix APFloat mod by committing rL299256: Fix APFloat mod (committing for simonbyrne).
Mar 31 2017, 1:44 PM
scanon added a comment to D31533: Do not translate rint into nearbyint, but truncate it like nearbyint.

If rint() is faster than nearbyint(), should we canonicalize nearbyint()->rint()?

Mar 31 2017, 11:34 AM
scanon added a reviewer for D31398: [X86][X86 intrinsics]Folding cmp(sub(a,b),0) into cmp(a,b) optimization: hfinkel.

(x-y) == 0 --> x == y does not require nsz (zeros of any sign compare equal), nor does it require nnan (if x or y is NaN, both comparisons are false). It *does* require ninf (because inf-inf = NaN), and it also requires that subnormals are not flushed by the CPU. There's been some churn around flushing recently, Hal may have thoughts (+Hal).

Mar 31 2017, 7:44 AM
scanon accepted D31533: Do not translate rint into nearbyint, but truncate it like nearbyint.

LGTM.

Mar 31 2017, 6:56 AM
scanon added a comment to D31182: [InstCombine] fadd double (sitofp x), y check that the promotion is valid .

This addresses my concerns. Gentle ping to the other reviewers.

Mar 31 2017, 6:55 AM

Mar 21 2017

scanon added inline comments to D31164: [IR] Add AllowContract to FastMathFlags.
Mar 21 2017, 9:42 AM
scanon added inline comments to D31182: [InstCombine] fadd double (sitofp x), y check that the promotion is valid .
Mar 21 2017, 9:38 AM
scanon added a comment to D31182: [InstCombine] fadd double (sitofp x), y check that the promotion is valid .

The assumption is that an integer add is more canonical and/or cheaper than an FP add. Is that universally true?

Mar 21 2017, 9:31 AM

Mar 8 2017

scanon added a comment to D30527: Replacing float with new class Fraction for LSR alternative way of resolving complex solution.

What's the rationale for using rationals here instead of a (simpler) fixed-point representation, if we want to get rid of float?

Mar 8 2017, 8:35 AM

Feb 7 2017

scanon added a comment to D29346: Fix APFloat mod.

Great, thanks Simon! This looks fine numerically. @gottesmm, can you double-check for style, etc?

Feb 7 2017, 9:49 AM

Feb 1 2017

scanon added a comment to D29346: Fix APFloat mod.

Numerically this is sound, and something that I've wanted to fix for a while but haven't had time to deal with. Thanks for doing it! Please add some test cases that would detect the old error (@gottesmm can likely point you in the right direction).

Feb 1 2017, 5:58 AM

Jan 19 2017

scanon added a comment to D28862: [compiler-rt] [test] Use approximate comparison on float types.

These tests should either be exact, or should have a tolerance that's mathematically sound. +/-1ulp is not sound; the allowed error should be proportional to the magnitude of the larger of the real and imaginary components of the result -- e.g. if one component is very small compared to the other, the smaller one may have *no* "correct" bits and still be acceptable.

Jan 19 2017, 7:01 AM

Jan 6 2017

scanon accepted D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().

OK, I'm satisfied with that.

Jan 6 2017, 10:00 AM
scanon added inline comments to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().
Jan 6 2017, 7:54 AM

Jan 4 2017

scanon added inline comments to D27932: InstSimplify: Eliminate fabs on known positive.
Jan 4 2017, 11:28 AM
scanon added inline comments to D27028: Add intrinsics for constrained floating point operations.
Jan 4 2017, 9:32 AM
scanon added inline comments to D27932: InstSimplify: Eliminate fabs on known positive.
Jan 4 2017, 9:28 AM

Dec 23 2016

scanon requested changes to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().

I don't particularly care about the shift, since the code is completely equivalent either way, though it would be nice to clean up. However, please replace "mantissa" with "significand" before committing.

Dec 23 2016, 4:54 AM
scanon added inline comments to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().
Dec 23 2016, 4:51 AM

Dec 22 2016

scanon added inline comments to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().
Dec 22 2016, 10:41 AM
scanon added inline comments to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().
Dec 22 2016, 10:36 AM
scanon added a comment to D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf().

Please s/mantissa/significand/. I know that "mantissa" is used in a number of places in llvm sources, but it's incorrect terminology. Significand is the IEEE-754 nomenclature, which any new work should follow.

Dec 22 2016, 10:20 AM

Sep 26 2016

scanon added a comment to D24925: [testsuite] turn fp-contract off because we can check those results more precisely.

The tests in question are broken. They blindly apply a relative error tolerance that is not motivated by sound numerical analysis, despite the existence of well-known and well-founded error bounds for these problems, in every basic numerical analysis textbook.

Sep 26 2016, 10:56 AM

Sep 22 2016

scanon accepted D24481: make “#pragma STDC FP_CONTRACT” on by default.

LGTM

Sep 22 2016, 10:44 AM

Sep 12 2016

scanon added a comment to D24481: make “#pragma STDC FP_CONTRACT” on by default.

Abe, I had a patch to do the same thing last year (that we ended up backing out because it exposed a bug which has since been fixed). Your approach looks a bit different from the one that I took originally, and you seem to be missing some of the arm64 test changes that I had to put in:

Sep 12 2016, 4:40 PM
scanon added a reviewer for D24481: make “#pragma STDC FP_CONTRACT” on by default: hfinkel.
Sep 12 2016, 4:37 PM

Jul 15 2016

scanon added a comment to D18639: Use __builtin_isnan/isinf/isfinite in complex.

I am not the right person to review the C++ template details, but everything else seems OK to me.

Jul 15 2016, 8:02 AM

Jul 1 2016

scanon added a comment to D18639: Use __builtin_isnan/isinf/isfinite in complex.

I agree with Marshall. Aside from the points he raises, this approach looks fine.

Jul 1 2016, 8:49 AM

May 26 2016

scanon added a comment to D19391: transform obscured FP sign bit ops into a fabs/fneg using TLI hook.

Numerically, I'm fine with this. Someone else can address the approach and style, etc.

May 26 2016, 9:20 AM

May 23 2016

scanon added inline comments to D19178: Broaden FoldItoFPtoI to try and establish whether the integer value fits into the float type.
May 23 2016, 7:38 AM