const Constant *BaseCV = nullptr,
uint64_t Offset = 0);
+static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP);
+
/// isRepeatedByteSequence - Determine whether the given value is
/// composed of a repeated sequence of identical bytes and return the
/// byte value. If it is not a repeated sequence, return -1.
ElementByteSize);
}
} else {
- // FP Constants are printed as integer constants to avoid losing precision.
- for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
- APFloat Num = CDS->getElementAsAPFloat(I);
- if (AP.isVerbose()) {
- if (ElementByteSize == 4)
- AP.OutStreamer->GetCommentOS() << "float " << Num.convertToFloat()
- << '\n';
- else if (ElementByteSize == 8)
- AP.OutStreamer->GetCommentOS() << "double " << Num.convertToDouble()
- << '\n';
- else
- llvm_unreachable("Unexpected float width");
- }
- AP.OutStreamer->EmitIntValue(Num.bitcastToAPInt().getLimitedValue(),
- ElementByteSize);
- }
+ for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I)
+ emitGlobalConstantFP(cast<ConstantFP>(CDS->getElementAsConstant(I)), AP);
}
unsigned Size = DL.getTypeAllocSize(CDS->getType());
float 3.000000e+00> }, align 16
; CHECK: const1
; CHECK: .zero 16
-; CHECK: float 1.0
-; CHECK: float 2.0
-; CHECK: float 3.0
+; CHECK: float 1
+; CHECK: float 2
+; CHECK: float 3
; CHECK: .zero 4
; check that this transformation doesn't happen:
; (sint_to_fp (setcc x, y, cc)) -> (select_cc x, y, -1.0, 0.0,, cc)
;
-; CHECK-NOT: # double -1.000000e+00
+; CHECK-NOT: # double -1
%tobool1 = icmp ne i32 %a, 0
%not.tobool = icmp ne i64 %b, 0
store double %add, double* @foo12.d4, align 8
ret double %add
}
-
define void @test_copysign_const_magnitude_d(double %X) {
; CHECK: [[SIGNMASK:L.+]]:
-; CHECK-NEXT: .quad -9223372036854775808 ## double -0.000000e+00
-; CHECK-NEXT: .quad 0 ## double 0.000000e+00
+; CHECK-NEXT: .quad -9223372036854775808 ## double -0
+; CHECK-NEXT: .quad 0 ## double 0
; CHECK: [[ZERO:L.+]]:
; CHECK-NEXT: .space 16
; CHECK: [[ONE:L.+]]:
-; CHECK-NEXT: .quad 4607182418800017408 ## double 1.000000e+00
-; CHECK-NEXT: .quad 0 ## double 0.000000e+00
+; CHECK-NEXT: .quad 4607182418800017408 ## double 1
+; CHECK-NEXT: .quad 0 ## double 0
; CHECK-LABEL: test_copysign_const_magnitude_d:
; CHECK: id
define void @test_copysign_const_magnitude_f(float %X) {
; CHECK: [[SIGNMASK:L.+]]:
-; CHECK-NEXT: .long 2147483648 ## float -0.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
+; CHECK-NEXT: .long 2147483648 ## float -0
+; CHECK-NEXT: .long 0 ## float 0
+; CHECK-NEXT: .long 0 ## float 0
+; CHECK-NEXT: .long 0 ## float 0
; CHECK: [[ZERO:L.+]]:
; CHECK-NEXT: .space 16
; CHECK: [[ONE:L.+]]:
-; CHECK-NEXT: .long 1065353216 ## float 1.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
-; CHECK-NEXT: .long 0 ## float 0.000000e+00
+; CHECK-NEXT: .long 1065353216 ## float 1
+; CHECK-NEXT: .long 0 ## float 0
+; CHECK-NEXT: .long 0 ## float 0
+; CHECK-NEXT: .long 0 ## float 0
; CHECK-LABEL: test_copysign_const_magnitude_f:
; CHECK: id
ret float %z
}
-; CHECK: float 5.000000e+00
-; CHECK: float 5.000000e+00
-; CHECK: float 5.000000e+00
-; CHECK: float 5.000000e+00
+; CHECK: float 5
+; CHECK: float 5
+; CHECK: float 5
+; CHECK: float 5
define <4 x float> @fadd_2const_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_2const_4f32:
; CHECK: # BB#0:
ret float %z
}
-; CHECK: float 2.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 5.000000e+00
+; CHECK: float 2
+; CHECK: float 3
+; CHECK: float 4
+; CHECK: float 5
define <4 x float> @fadd_x_fmul_x_c_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_x_fmul_x_c_4f32:
; CHECK: # BB#0:
ret float %z
}
-; CHECK: float 2.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 5.000000e+00
+; CHECK: float 2
+; CHECK: float 3
+; CHECK: float 4
+; CHECK: float 5
define <4 x float> @fadd_fmul_x_c_x_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_fmul_x_c_x_4f32:
; CHECK: # BB#0:
ret float %w
}
-; CHECK: float 3.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 5.000000e+00
-; CHECK: float 6.000000e+00
+; CHECK: float 3
+; CHECK: float 4
+; CHECK: float 5
+; CHECK: float 6
define <4 x float> @fadd_fadd_x_x_fmul_x_c_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_4f32:
; CHECK: # BB#0:
ret float %w
}
-; CHECK: float 3.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 5.000000e+00
-; CHECK: float 6.000000e+00
+; CHECK: float 3
+; CHECK: float 4
+; CHECK: float 5
+; CHECK: float 6
define <4 x float> @fadd_fmul_x_c_fadd_x_x_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_4f32:
; CHECK: # BB#0:
ret float %z
}
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
+; CHECK: float 3
+; CHECK: float 3
+; CHECK: float 3
+; CHECK: float 3
define <4 x float> @fadd_x_fadd_x_x_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_x_fadd_x_x_4f32:
; CHECK: # BB#0:
ret float %z
}
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
-; CHECK: float 3.000000e+00
+; CHECK: float 3
+; CHECK: float 3
+; CHECK: float 3
+; CHECK: float 3
define <4 x float> @fadd_fadd_x_x_x_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_fadd_x_x_x_4f32:
; CHECK: # BB#0:
ret float %z
}
-; CHECK: float 4.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 4.000000e+00
-; CHECK: float 4.000000e+00
+; CHECK: float 4
+; CHECK: float 4
+; CHECK: float 4
+; CHECK: float 4
define <4 x float> @fadd_fadd_x_x_fadd_x_x_4f32(<4 x float> %x) #0 {
; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_4f32:
; CHECK: # BB#0:
}
; We should be able to pre-multiply the two constant vectors.
-; CHECK: float 5.000000e+00
-; CHECK: float 1.200000e+01
-; CHECK: float 2.100000e+01
-; CHECK: float 3.200000e+01
+; CHECK: float 5
+; CHECK: float 12
+; CHECK: float 21
+; CHECK: float 32
; CHECK-LABEL: fmul_v4f32_two_consts_no_splat:
; CHECK: mulps
; CHECK-NOT: mulps
}
; Same as above, but reverse operands to make sure non-canonical form is also handled.
-; CHECK: float 5.000000e+00
-; CHECK: float 1.200000e+01
-; CHECK: float 2.100000e+01
-; CHECK: float 3.200000e+01
+; CHECK: float 5
+; CHECK: float 12
+; CHECK: float 21
+; CHECK: float 32
; CHECK-LABEL: fmul_v4f32_two_consts_no_splat_non_canonical:
; CHECK: mulps
; CHECK-NOT: mulps
; More than one use of a constant multiply should not inhibit the optimization.
; Instead of a chain of 2 dependent mults, this test will have 2 independent mults.
-; CHECK: float 6.000000e+00
-; CHECK: float 1.400000e+01
-; CHECK: float 2.400000e+01
-; CHECK: float 3.600000e+01
+; CHECK: float 6
+; CHECK: float 14
+; CHECK: float 24
+; CHECK: float 36
; CHECK-LABEL: fmul_v4f32_two_consts_no_splat_multiple_use:
; CHECK: mulps
; CHECK: ret
%mul3 = fmul fast <4 x float> %a, %mul2
ret <4 x float> %mul3
-; CHECK: float 2.400000e+01
-; CHECK: float 2.400000e+01
-; CHECK: float 2.400000e+01
-; CHECK: float 2.400000e+01
+; CHECK: float 24
+; CHECK: float 24
+; CHECK: float 24
+; CHECK: float 24
; CHECK-LABEL: PR22698_splats:
; CHECK: mulps
; CHECK: ret
%mul3 = fmul fast <4 x float> %a, %mul2
ret <4 x float> %mul3
-; CHECK: float 4.500000e+01
-; CHECK: float 1.200000e+02
-; CHECK: float 2.310000e+02
-; CHECK: float 3.840000e+02
+; CHECK: float 45
+; CHECK: float 120
+; CHECK: float 231
+; CHECK: float 384
; CHECK-LABEL: PR22698_no_splats:
; CHECK: mulps
; CHECK: ret
; CST-NEXT: .long 65535 # 0xffff
; CST: [[FPMASKCSTADDR:.LCPI[0-9_]+]]:
-; CST-NEXT: .long 1199570944 # float 6.553600e+04
-; CST-NEXT: .long 1199570944 # float 6.553600e+04
-; CST-NEXT: .long 1199570944 # float 6.553600e+04
-; CST-NEXT: .long 1199570944 # float 6.553600e+04
+; CST-NEXT: .long 1199570944 # float 65536
+; CST-NEXT: .long 1199570944 # float 65536
+; CST-NEXT: .long 1199570944 # float 65536
+; CST-NEXT: .long 1199570944 # float 65536
; AVX2: [[FPMASKCSTADDR:.LCPI[0-9_]+]]:
; AVX2-NEXT: .long 1199570944 # float 65536
; AVX-NEXT: .long 65535 # 0xffff
; AVX: [[FPMASKCSTADDR_v8:.LCPI[0-9_]+]]:
-; AVX-NEXT: .long 1199570944 # float 6.553600e+04
-; AVX-NEXT: .long 1199570944 # float 6.553600e+04
-; AVX-NEXT: .long 1199570944 # float 6.553600e+04
-; AVX-NEXT: .long 1199570944 # float 6.553600e+04
+; AVX-NEXT: .long 1199570944 # float 65536
+; AVX-NEXT: .long 1199570944 # float 65536
+; AVX-NEXT: .long 1199570944 # float 65536
+; AVX-NEXT: .long 1199570944 # float 65536
; AVX2: [[FPMASKCSTADDR_v8:.LCPI[0-9_]+]]:
; AVX2-NEXT: .long 1199570944 # float 65536
; CST-NEXT: .long 1392508928 ## 0x53000000
; CST: [[MAGICCSTADDR:LCPI0_[0-9]+]]:
-; CST-NEXT: .long 3539992704 ## float -5.497642e+11
-; CST-NEXT: .long 3539992704 ## float -5.497642e+11
-; CST-NEXT: .long 3539992704 ## float -5.497642e+11
-; CST-NEXT: .long 3539992704 ## float -5.497642e+11
+; CST-NEXT: .long 3539992704 ## float -5.49764202E+11
+; CST-NEXT: .long 3539992704 ## float -5.49764202E+11
+; CST-NEXT: .long 3539992704 ## float -5.49764202E+11
+; CST-NEXT: .long 3539992704 ## float -5.49764202E+11
; AVX2: [[LOWCSTADDR:LCPI0_[0-9]+]]:
; AVX2-NEXT: .long 1258291200 ## 0x4b000000
; Also test the general purpose constant folding of int->fp.
define void @foo2(<4 x float>* noalias %result) nounwind {
; CHECK-LABEL: LCPI2_0:
-; CHECK-NEXT: .long 1082130432 ## float 4.000000e+00
-; CHECK-NEXT: .long 1084227584 ## float 5.000000e+00
-; CHECK-NEXT: .long 1086324736 ## float 6.000000e+00
-; CHECK-NEXT: .long 1088421888 ## float 7.000000e+00
+; CHECK-NEXT: .long 1082130432 ## float 4
+; CHECK-NEXT: .long 1084227584 ## float 5
+; CHECK-NEXT: .long 1086324736 ## float 6
+; CHECK-NEXT: .long 1088421888 ## float 7
; CHECK-LABEL: foo2:
; CHECK: movaps LCPI2_0(%rip), %xmm0
; Test the general purpose constant folding of uint->fp.
define void @foo4(<4 x float>* noalias %result) nounwind {
; CHECK-LABEL: LCPI4_0:
-; CHECK-NEXT: .long 1065353216 ## float 1.000000e+00
-; CHECK-NEXT: .long 1123942400 ## float 1.270000e+02
-; CHECK-NEXT: .long 1124073472 ## float 1.280000e+02
-; CHECK-NEXT: .long 1132396544 ## float 2.550000e+02
+; CHECK-NEXT: .long 1065353216 ## float 1
+; CHECK-NEXT: .long 1123942400 ## float 127
+; CHECK-NEXT: .long 1124073472 ## float 128
+; CHECK-NEXT: .long 1132396544 ## float 255
; CHECK-LABEL: foo4:
; CHECK: movaps LCPI4_0(%rip), %xmm0