[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
Carrot created this revision. Herald added a subscriber: nemanjai. Usually compare expression should return i1 type, so EmitScalarConversion is called before return return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); But when ppc intrinsic is called to compare vectors, the ppc intrinsic can return i32 even E->getType() is BoolTy, in this case EmitScalarConversion does nothing, an i32 type result is returned and causes crash later. This patch detects this case and truncates the result before return. https://reviews.llvm.org/D38656 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/ppc-vector-compare.cc Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,17 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = + dyn_cast(Result->getType()); + if ((ResultTy->getBitWidth() > 1) && + (E->getType() == CGF.getContext().BoolTy)) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,17 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = + dyn_cast(Result->getType()); + if ((ResultTy->getBitWidth() > 1) && + (E->getType() == CGF.getContext().BoolTy)) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
Carrot added a comment. I worked on a similar bug as 31161, and then found this one, it should be same as in comment7. What is the current status of the work on that bug? https://reviews.llvm.org/D38656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
Carrot updated this revision to Diff 118236. Carrot marked 3 inline comments as done. https://reviews.llvm.org/D38656 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/ppc-vector-compare.cc Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,16 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = cast(Result->getType()); + if (ResultTy->getBitWidth() > 1 && + E->getType() == CGF.getContext().BoolTy) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,16 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = cast(Result->getType()); + if (ResultTy->getBitWidth() > 1 && + E->getType() == CGF.getContext().BoolTy) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
Carrot added a comment. In https://reviews.llvm.org/D38656#892740, @nemanjai wrote: > In https://reviews.llvm.org/D38656#892072, @Carrot wrote: > > > I worked on a similar bug as 31161, and then found this one, it should be > > same as in comment7. > > What is the current status of the work on that bug? > > > No one has had time to finalize a fix to it. Please go ahead with this patch. > If this patch indeed fixes the bug, please close it. This patch fixes the second part of bug 31161 described in comment7. I will check it in soon. For the first part of the bug, I will retest your patch in comment1, plus incorrect handling of type long in our case, and then send it out. https://reviews.llvm.org/D38656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
This revision was automatically updated to reflect the committed changes. Closed by commit rL315358: [CGExprScalar] In EmitCompare trunc the result if it has different type as E… (authored by Carrot). Changed prior to commit: https://reviews.llvm.org/D38656?vs=118236&id=118464#toc Repository: rL LLVM https://reviews.llvm.org/D38656 Files: cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/test/CodeGen/ppc-vector-compare.cc Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc === --- cfe/trunk/test/CodeGen/ppc-vector-compare.cc +++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp === --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,16 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = cast(Result->getType()); + if (ResultTy->getBitWidth() > 1 && + E->getType() == CGF.getContext().BoolTy) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc === --- cfe/trunk/test/CodeGen/ppc-vector-compare.cc +++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN:-o - | FileCheck %s + +#include + +// CHECK-LABEL: @_Z5test1Dv8_tS_ +// CHECK: @llvm.ppc.altivec.vcmpequh.p +bool test1(vector unsigned short v1, vector unsigned short v2) { + return v1 == v2; +} + Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp === --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp @@ -3214,6 +3214,16 @@ Value *CR6Param = Builder.getInt32(CR6); llvm::Function *F = CGF.CGM.getIntrinsic(ID); Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg}); + + // The result type of intrinsic may not be same as E->getType(). + // If E->getType() is not BoolTy, EmitScalarConversion will do the + // conversion work. If E->getType() is BoolTy, EmitScalarConversion will + // do nothing, if ResultTy is not i1 at the same time, it will cause + // crash later. + llvm::IntegerType *ResultTy = cast(Result->getType()); + if (ResultTy->getBitWidth() > 1 && + E->getType() == CGF.getContext().BoolTy) +Result = Builder.CreateTrunc(Result, Builder.getInt1Ty()); return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), E->getExprLoc()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38820: [CGExprScalar] Add missing types in function GetIntrinsic
Carrot created this revision. 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. https://reviews.llvm.org/D38820 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/ppc-vector-compare.cc Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ 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 @@ -9,3 +9,26 @@ 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; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3120,16 +3120,25 @@ 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; } } Index: test/CodeGen/ppc-vector-compare.cc === --- test/CodeGen/ppc-vector-compare.cc +++ 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 @@ -9,3 +9,26 @@ 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; +} + Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -3120,16 +3120,25 @@ 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 Builti
[PATCH] D38820: [CGExprScalar] Add missing types in function GetIntrinsic
Carrot added a comment. ping https://reviews.llvm.org/D38820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38820: [CGExprScalar] Add missing types in function GetIntrinsic
This revision was automatically updated to reflect the committed changes. Closed by commit rL316179: [CGExprScalar] Add missing types in function GetIntrinsic (authored by Carrot). Changed prior to commit: https://reviews.llvm.org/D38820?vs=118680&id=119613#toc Repository: rL LLVM https://reviews.llvm.org/D38820 Files: cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/test/CodeGen/ppc-vector-compare.cc Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp === --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp @@ -3120,16 +3120,25 @@ 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; } } Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc === --- cfe/trunk/test/CodeGen/ppc-vector-compare.cc +++ cfe/trunk/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 @@ -9,3 +9,26 @@ 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; +} + Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp === --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp @@ -3120,16 +3120,25 @@ 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; } } Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc === --- cfe/trunk/test/CodeGen/ppc-vector-compare.cc +++ cfe/trunk/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 -trip
[PATCH] D132531: [AArch64] Reserve more physical registers
Carrot created this revision. Carrot added a reviewer: dmgreen. Herald added subscribers: hiraditya, kristof.beyls. Herald added a project: All. Carrot requested review of this revision. Herald added subscribers: llvm-commits, cfe-commits, MaskRay. Herald added projects: clang, LLVM. Reserved physical registers can't be assigned to virtual registers, but they can still be used as ABI required. So we can reserve X8, X16, X17 and X19. Similarly argument registers can be reserved even if they are used by function call. With this change we can reserve most of the physical registers, it is much easier to test and debug register allocator. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D132531 Files: clang/lib/Driver/ToolChains/Arch/AArch64.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64FastISel.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp llvm/lib/Target/AArch64/AArch64RegisterInfo.h llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp llvm/test/CodeGen/AArch64/arm64-platform-reg.ll llvm/test/CodeGen/AArch64/arm64-reserved-arg-reg-call-error.ll Index: llvm/test/CodeGen/AArch64/arm64-reserved-arg-reg-call-error.ll === --- llvm/test/CodeGen/AArch64/arm64-reserved-arg-reg-call-error.ll +++ /dev/null @@ -1,19 +0,0 @@ -; RUN: not llc < %s -mtriple=arm64-linux-gnu -mattr=+reserve-x1 2>&1 | FileCheck %s -; RUN: not llc < %s -mtriple=arm64-linux-gnu -mattr=+reserve-x1 -fast-isel 2>&1 | FileCheck %s -; RUN: not llc < %s -mtriple=arm64-linux-gnu -mattr=+reserve-x1 -global-isel 2>&1 | FileCheck %s - -; CHECK: error: -; CHECK-SAME: AArch64 doesn't support function calls if any of the argument registers is reserved. -define void @call_function() { - call void @foo() - ret void -} -declare void @foo() - -; CHECK: error: -; CHECK-SAME: AArch64 doesn't support function calls if any of the argument registers is reserved. -define void @call_memcpy(i8* %out, i8* %in) { - call void @llvm.memcpy.p0i8.p0i8.i64(i8* %out, i8* %in, i64 800, i1 false) - ret void -} -declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i1) Index: llvm/test/CodeGen/AArch64/arm64-platform-reg.ll === --- llvm/test/CodeGen/AArch64/arm64-platform-reg.ll +++ llvm/test/CodeGen/AArch64/arm64-platform-reg.ll @@ -13,6 +13,7 @@ ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x5 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X5 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x6 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X6 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x7 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X7 +; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x8 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X8 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x9 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X9 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x10 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X10 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x11 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X11 @@ -20,6 +21,9 @@ ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x13 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X13 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x14 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X14 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x15 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X15 +; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x16 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X16 +; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x17 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X17 +; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x19 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X19 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x20 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X20 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x21 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X21 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x22 -o - %s | FileCheck %s --check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X22 @@ -51,6 +55,7 @@ ; RUN: -mattr=+reserve-x5 \ ; RUN: -mattr=+reserve-x6 \ ; RUN: -mattr=+reserve-x7 \ +; RUN: -mattr=+reserve-x8 \ ; RUN: -mattr=+reserve-x9 \ ; RUN: -mattr=+reserve-x10 \ ; RUN: -mattr=+reserve-x11 \ @@ -58,7 +63,10 @@ ; RUN: -mattr=+reserve-x13 \ ; RUN: -mattr=+reserve-x14 \ ; RUN: -mattr=+reserve-x15 \ +; RUN: -mattr=+reserve-x16 \ +; RUN: -mattr=+reserve-x17 \ ; RUN: -mattr=+reserve-x18 \ +; RUN: -mattr=+reserve-x19 \ ; RUN: -
[PATCH] D132531: [AArch64] Reserve more physical registers
Carrot added a comment. A reserved physical register doesn't mean it can't be used by compiler/linker, it just means it can't be used by register allocator, see the comments in TargetRegisterInfo::getReservedRegs(). The most common example is the stack pointer. So when we reserve X8, X16, X17 and X19, it means we can't allocate them to virtual registers, compiler/linker can still use X8 to pass return address, and use X16 and X17 in a veneer. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132531/new/ https://reviews.llvm.org/D132531 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D132531: [AArch64] Reserve more physical registers
Carrot added a comment. I want to reserve most of the physical registers, so only a small number of registers can be used by register allocator. Then I can write small test cases to simulate high register pressure situation, it will be much easier to test and debug register allocation changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132531/new/ https://reviews.llvm.org/D132531 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D132531: [AArch64] Reserve more physical registers
Carrot abandoned this revision. Carrot added a comment. Thanks for the clarification, I will propose another patch for my purpose. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132531/new/ https://reviews.llvm.org/D132531 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass
Carrot added a comment. Finally complain comes. It slows down a hot path in tcmalloc. A simplified test case is at https://godbolt.org/z/T6sshjf7M Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104099/new/ https://reviews.llvm.org/D104099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass
Carrot added a comment. I'm trying to understand the problem in this pass. It looks both of @thopre's and @lebedev.ri's problems are loop related. Is there any other regression not loop related? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104099/new/ https://reviews.llvm.org/D104099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits