diff options
| author | Guozhi Wei <carrot@google.com> | 2017-10-19 20:11:23 +0000 |
|---|---|---|
| committer | Guozhi Wei <carrot@google.com> | 2017-10-19 20:11:23 +0000 |
| commit | 769095bd07fc90e6e9eaae5c8b1cd09f543db2e1 (patch) | |
| tree | 592554480f5b042a7d4e6e912cbc2d65a606a7bd | |
| parent | e1f894d59e5df8a575d69395a8a0e1798bfdec75 (diff) | |
| download | bcm5719-llvm-769095bd07fc90e6e9eaae5c8b1cd09f543db2e1.tar.gz bcm5719-llvm-769095bd07fc90e6e9eaae5c8b1cd09f543db2e1.zip | |
[CGExprScalar] Add missing types in function GetIntrinsic
In function GetIntrinsic, not all types are covered. Types double and long long are missed, type long is wrongly treated same as int, it should be same as long long. These problems cause compiler crashes when compiling code in PR31161. This patch fixed the problem.
Differential Revision: https://reviews.llvm.org/D38820
llvm-svn: 316179
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 13 | ||||
| -rw-r--r-- | clang/test/CodeGen/ppc-vector-compare.cc | 25 |
2 files changed, 35 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 68a2f13e70b..7c111036177 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -3120,16 +3120,25 @@ static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT, return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequh_p : llvm::Intrinsic::ppc_altivec_vcmpgtsh_p; case BuiltinType::UInt: - case BuiltinType::ULong: return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : llvm::Intrinsic::ppc_altivec_vcmpgtuw_p; case BuiltinType::Int: - case BuiltinType::Long: return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequw_p : llvm::Intrinsic::ppc_altivec_vcmpgtsw_p; + case BuiltinType::ULong: + case BuiltinType::ULongLong: + return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p : + llvm::Intrinsic::ppc_altivec_vcmpgtud_p; + case BuiltinType::Long: + case BuiltinType::LongLong: + return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequd_p : + llvm::Intrinsic::ppc_altivec_vcmpgtsd_p; case BuiltinType::Float: return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpeqfp_p : llvm::Intrinsic::ppc_altivec_vcmpgtfp_p; + case BuiltinType::Double: + return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_vsx_xvcmpeqdp_p : + llvm::Intrinsic::ppc_vsx_xvcmpgtdp_p; } } diff --git a/clang/test/CodeGen/ppc-vector-compare.cc b/clang/test/CodeGen/ppc-vector-compare.cc index 43fbf84c6db..e1c92bb6bef 100644 --- a/clang/test/CodeGen/ppc-vector-compare.cc +++ b/clang/test/CodeGen/ppc-vector-compare.cc @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: %clang_cc1 -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s \ // RUN: -o - | FileCheck %s #include <altivec.h> @@ -9,3 +9,26 @@ bool test1(vector unsigned short v1, vector unsigned short v2) { return v1 == v2; } +// CHECK-LABEL: @_Z5test2Dv2_mS_Dv2_lS0_Dv2_yS1_Dv2_xS2_Dv2_dS3_ +bool test2(vector unsigned long v1, vector unsigned long v2, + vector long v3, vector long v4, + vector unsigned long long v5, vector unsigned long long v6, + vector long long v7, vector long long v8, + vector double v9, vector double v10) { + // CHECK: @llvm.ppc.altivec.vcmpequd.p + bool res = v1 == v2; + + // CHECK: @llvm.ppc.altivec.vcmpequd.p + res |= v3 == v4; + + // CHECK: @llvm.ppc.altivec.vcmpequd.p + res |= v5 == v6; + + // CHECK: @llvm.ppc.altivec.vcmpequd.p + res |= v7 == v8; + + // CHECK: @llvm.ppc.vsx.xvcmpeqdp.p + res |= v9 == v10; + return res; +} + |

