llvm.org GIT mirror llvm / 1fd63df
Express the number of ULPs in fpaccuracy metadata as a real rather than a rational number, eg as 2.5 rather than 5, 2. OK'd by Peter Collingbourne. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154387 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 8 years ago
4 changed file(s) with 48 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
30203020
30213021
30223022
3023

The maximum relative error may be any rational number. The metadata node

3024 shall consist of a pair of unsigned integers respectively representing
3025 the numerator and denominator. For example, 2.5 ULP:

3023

The metadata node shall consist of a single non-negative floating

3024 point number representing the maximum relative error. For example,
3025 2.5 ULP:

30263026
30273027
30283028

                  
                
3029 !0 = metadata !{ i32 5, i32 2 }
3029 !0 = metadata !{ float 2.5 }
30303030
30313031
30323032
319319 const fltSemantics &getSemantics() const { return *semantics; }
320320 bool isZero() const { return category == fcZero; }
321321 bool isNonZero() const { return category != fcZero; }
322 bool isNormal() const { return category == fcNormal; }
322323 bool isNaN() const { return category == fcNaN; }
323324 bool isInfinity() const { return category == fcInfinity; }
324325 bool isNegative() const { return sign; }
16521652 }
16531653 }
16541654
1655 if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpaccuracy)) {
1656 Assert1(I.getType()->isFPOrFPVectorTy(),
1657 "fpaccuracy requires a floating point result!", &I);
1658 Assert1(MD->getNumOperands() == 1, "fpaccuracy takes one operand!", &I);
1659 ConstantFP *Op = dyn_cast_or_null(MD->getOperand(0));
1660 Assert1(Op, "fpaccuracy ULPs not a floating point number!", &I);
1661 APFloat ULPs = Op->getValueAPF();
1662 Assert1(ULPs.isNormal() || ULPs.isZero(),
1663 "fpaccuracy ULPs not a normal number!", &I);
1664 Assert1(!ULPs.isNegative(), "fpaccuracy ULPs is negative!", &I);
1665 }
1666
16551667 MDNode *MD = I.getMetadata(LLVMContext::MD_range);
16561668 Assert1(!MD || isa(I), "Ranges are only for loads!", &I);
16571669
0 ; RUN: not llvm-as < %s |& FileCheck %s
1
2 define void @foo(i32 %i, float %f, <2 x float> %g) {
3 %s = add i32 %i, %i, !fpaccuracy !0
4 ; CHECK: fpaccuracy requires a floating point result!
5 %t = fadd float %f, %f, !fpaccuracy !1
6 ; CHECK: fpaccuracy takes one operand!
7 %u = fadd float %f, %f, !fpaccuracy !2
8 ; CHECK: fpaccuracy takes one operand!
9 %v = fadd float %f, %f, !fpaccuracy !3
10 ; CHECK: fpaccuracy ULPs not a floating point number!
11 %w = fadd float %f, %f, !fpaccuracy !0
12 ; Above line is correct.
13 %w2 = fadd <2 x float> %g, %g, !fpaccuracy !0
14 ; Above line is correct.
15 %x = fadd float %f, %f, !fpaccuracy !4
16 ; CHECK: fpaccuracy ULPs is negative!
17 %y = fadd float %f, %f, !fpaccuracy !5
18 ; CHECK: fpaccuracy ULPs is negative!
19 %z = fadd float %f, %f, !fpaccuracy !6
20 ; CHECK: fpaccuracy ULPs not a normal number!
21 ret void
22 }
23
24 !0 = metadata !{ float 1.0 }
25 !1 = metadata !{ }
26 !2 = metadata !{ float 1.0, float 1.0 }
27 !3 = metadata !{ i32 1 }
28 !4 = metadata !{ float -1.0 }
29 !5 = metadata !{ float -0.0 }
30 !6 = metadata !{ float 0x7FFFFFFF00000000 }