summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-12-09 00:02:37 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-12-09 00:02:37 +0000
commit502775a2ee08e2fe1df7dd0741722a31debffa16 (patch)
tree7d41f265f7421a4f62356f723683626a072646a3 /clang/lib/CodeGen/CGExprConstant.cpp
parent01fb31cc89d3ce145f3cacd669981de5edd5de8d (diff)
downloadbcm5719-llvm-502775a2ee08e2fe1df7dd0741722a31debffa16.tar.gz
bcm5719-llvm-502775a2ee08e2fe1df7dd0741722a31debffa16.zip
[CodeGen][X86] Fix handling of __fp16 vectors.
This commit fixes a bug in IRGen where it generates completely broken code for __fp16 vectors on X86. For example when the following code is compiled: half4 hv0, hv1, hv2; // these are vectors of __fp16. void foo221() { hv0 = hv1 + hv2; } clang generates the following IR, in which two i16 vectors are added: @hv1 = common global <4 x i16> zeroinitializer, align 8 @hv2 = common global <4 x i16> zeroinitializer, align 8 @hv0 = common global <4 x i16> zeroinitializer, align 8 define void @foo221() { %0 = load <4 x i16>, <4 x i16>* @hv1, align 8 %1 = load <4 x i16>, <4 x i16>* @hv2, align 8 %add = add <4 x i16> %0, %1 store <4 x i16> %add, <4 x i16>* @hv0, align 8 ret void } To fix the bug, this commit uses the code committed in r314056, which modified clang to promote and truncate __fp16 vectors to and from float vectors in the AST. It also fixes another IRGen bug where a short value is assigned to an __fp16 variable without any integer-to-floating-point conversion, as shown in the following example: __fp16 a; short b; void foo1() { a = b; } @b = common global i16 0, align 2 @a = common global i16 0, align 2 define void @foo1() #0 { %0 = load i16, i16* @b, align 2 store i16 %0, i16* @a, align 2 ret void } rdar://problem/20625184 Differential Revision: https://reviews.llvm.org/D40112 llvm-svn: 320215
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 3e35d4cb9c6..d1b9e13a6f9 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1825,7 +1825,7 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const APValue &Value,
const llvm::APFloat &Init = Value.getFloat();
if (&Init.getSemantics() == &llvm::APFloat::IEEEhalf() &&
!CGM.getContext().getLangOpts().NativeHalfType &&
- !CGM.getContext().getLangOpts().HalfArgsAndReturns)
+ CGM.getContext().getTargetInfo().useFP16ConversionIntrinsics())
return llvm::ConstantInt::get(CGM.getLLVMContext(),
Init.bitcastToAPInt());
else
OpenPOWER on IntegriCloud