[llvm] r254988 - AsmPrinter: Use emitGlobalConstantFP to emit elements of constant data
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 18:37:49 PST 2015
Author: bogner
Date: Mon Dec 7 20:37:48 2015
New Revision: 254988
URL: http://llvm.org/viewvc/llvm-project?rev=254988&view=rev
Log:
AsmPrinter: Use emitGlobalConstantFP to emit elements of constant data
It's strange to duplicate the logic for emitting FP values into
emitGlobalConstantDataSequential, and it's even stranger that we end
up printing the verbose assembly comments differently between the two
paths. Just call into emitGlobalConstantFP rather than crudely
duplicating its logic.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/test/CodeGen/ARM/constants.ll
llvm/trunk/test/CodeGen/Mips/sitofp-selectcc-opt.ll
llvm/trunk/test/CodeGen/X86/copysign-constant-magnitude.ll
llvm/trunk/test/CodeGen/X86/fadd-combines.ll
llvm/trunk/test/CodeGen/X86/fmul-combines.ll
llvm/trunk/test/CodeGen/X86/vec_uint_to_fp-fastmath.ll
llvm/trunk/test/CodeGen/X86/vec_uint_to_fp.ll
llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Dec 7 20:37:48 2015
@@ -1873,6 +1873,8 @@ static void emitGlobalConstantImpl(const
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.
@@ -1951,22 +1953,8 @@ static void emitGlobalConstantDataSequen
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());
Modified: llvm/trunk/test/CodeGen/ARM/constants.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/constants.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/constants.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/constants.ll Mon Dec 7 20:37:48 2015
@@ -63,7 +63,7 @@ define i32 @f8() nounwind {
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
Modified: llvm/trunk/test/CodeGen/Mips/sitofp-selectcc-opt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/sitofp-selectcc-opt.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/sitofp-selectcc-opt.ll (original)
+++ llvm/trunk/test/CodeGen/Mips/sitofp-selectcc-opt.ll Mon Dec 7 20:37:48 2015
@@ -7,7 +7,7 @@ entry:
; 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
@@ -19,4 +19,3 @@ entry:
store double %add, double* @foo12.d4, align 8
ret double %add
}
-
Modified: llvm/trunk/test/CodeGen/X86/copysign-constant-magnitude.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/copysign-constant-magnitude.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/copysign-constant-magnitude.ll (original)
+++ llvm/trunk/test/CodeGen/X86/copysign-constant-magnitude.ll Mon Dec 7 20:37:48 2015
@@ -5,13 +5,13 @@ target triple = "x86_64-apple-macosx10.1
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
@@ -50,17 +50,17 @@ define void @test_copysign_const_magnitu
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
Modified: llvm/trunk/test/CodeGen/X86/fadd-combines.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fadd-combines.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fadd-combines.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fadd-combines.ll Mon Dec 7 20:37:48 2015
@@ -28,10 +28,10 @@ define float @fadd_2const_f32(float %x)
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:
@@ -53,10 +53,10 @@ define float @fadd_x_fmul_x_c_f32(float
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:
@@ -78,10 +78,10 @@ define float @fadd_fmul_x_c_x_f32(float
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:
@@ -104,10 +104,10 @@ define float @fadd_fadd_x_x_fmul_x_c_f32
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:
@@ -131,10 +131,10 @@ define float @fadd_fmul_x_c_fadd_x_x_f32
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:
@@ -157,10 +157,10 @@ define float @fadd_x_fadd_x_x_f32(float
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:
@@ -182,10 +182,10 @@ define float @fadd_fadd_x_x_x_f32(float
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:
@@ -207,10 +207,10 @@ define float @fadd_fadd_x_x_fadd_x_x_f32
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:
Modified: llvm/trunk/test/CodeGen/X86/fmul-combines.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fmul-combines.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fmul-combines.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fmul-combines.ll Mon Dec 7 20:37:48 2015
@@ -56,10 +56,10 @@ define <4 x float> @fmul_c3_c4_v4f32(<4
}
; 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
@@ -71,10 +71,10 @@ define <4 x float> @fmul_v4f32_two_const
}
; 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
@@ -87,10 +87,10 @@ define <4 x float> @fmul_v4f32_two_const
; 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
@@ -110,10 +110,10 @@ define <4 x float> @PR22698_splats(<4 x
%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
@@ -126,10 +126,10 @@ define <4 x float> @PR22698_no_splats(<4
%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
Modified: llvm/trunk/test/CodeGen/X86/vec_uint_to_fp-fastmath.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_uint_to_fp-fastmath.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/vec_uint_to_fp-fastmath.ll (original)
+++ llvm/trunk/test/CodeGen/X86/vec_uint_to_fp-fastmath.ll Mon Dec 7 20:37:48 2015
@@ -14,10 +14,10 @@
; 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
@@ -69,10 +69,10 @@ define <4 x float> @test_uitofp_v4i32_to
; 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
Modified: llvm/trunk/test/CodeGen/X86/vec_uint_to_fp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_uint_to_fp.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/vec_uint_to_fp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/vec_uint_to_fp.ll Mon Dec 7 20:37:48 2015
@@ -23,10 +23,10 @@
; 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
Modified: llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll?rev=254988&r1=254987&r2=254988&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/x86-setcc-int-to-fp-combine.ll Mon Dec 7 20:37:48 2015
@@ -39,10 +39,10 @@ define void @foo1(<4 x float> %val, <4 x
; 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
@@ -72,10 +72,10 @@ define <4 x float> @foo3(<4 x float> %va
; 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
More information about the llvm-commits
mailing list