[PATCH] D46892: [X86] Lowering adds/addus/subs/subus intrinsics to native IR (Clang part)
tkrupa updated this revision to Diff 159461. tkrupa added a comment. Removed signed intrinsics lowering due to the pattern being too complicated - instead some minor optimizations were introduced on LLVM side. Repository: rC Clang https://reviews.llvm.org/D46892 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx2-builtins.c test/CodeGen/avx512bw-builtins.c test/CodeGen/avx512vlbw-builtins.c test/CodeGen/sse2-builtins.c Index: test/CodeGen/sse2-builtins.c === --- test/CodeGen/sse2-builtins.c +++ test/CodeGen/sse2-builtins.c @@ -59,13 +59,19 @@ __m128i test_mm_adds_epu8(__m128i A, __m128i B) { // CHECK-LABEL: test_mm_adds_epu8 - // CHECK: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}) + // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}) + // CHECK: add <16 x i8> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}} return _mm_adds_epu8(A, B); } __m128i test_mm_adds_epu16(__m128i A, __m128i B) { // CHECK-LABEL: test_mm_adds_epu16 - // CHECK: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}}) + // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}}) + // CHECK: add <8 x i16> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <8 x i16> %{{.*}}, %{{.*}} + // CHECK: select <8 x i1> %{{.*}}, <8 x i16> , <8 x i16> {{.*}} return _mm_adds_epu16(A, B); } @@ -1422,13 +1428,19 @@ __m128i test_mm_subs_epu8(__m128i A, __m128i B) { // CHECK-LABEL: test_mm_subs_epu8 - // CHECK: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}) + // CHECK-NOT: call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}) + // CHECK: icmp ugt <16 x i8> {{.*}}, {{.*}} + // CHECK: select <16 x i1> {{.*}}, <16 x i8> {{.*}}, <16 x i8> {{.*}} + // CHECK: sub <16 x i8> {{.*}}, {{.*}} return _mm_subs_epu8(A, B); } __m128i test_mm_subs_epu16(__m128i A, __m128i B) { // CHECK-LABEL: test_mm_subs_epu16 - // CHECK: call <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}}) + // CHECK-NOT: call <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16> %{{.*}}, <8 x i16> %{{.*}}) + // CHECK: icmp ugt <8 x i16> {{.*}}, {{.*}} + // CHECK: select <8 x i1> {{.*}}, <8 x i16> {{.*}}, <8 x i16> {{.*}} + // CHECK: sub <8 x i16> {{.*}}, {{.*}} return _mm_subs_epu16(A, B); } Index: test/CodeGen/avx512vlbw-builtins.c === --- test/CodeGen/avx512vlbw-builtins.c +++ test/CodeGen/avx512vlbw-builtins.c @@ -1123,49 +1123,73 @@ } __m128i test_mm_mask_adds_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) { // CHECK-LABEL: @test_mm_mask_adds_epu8 - // CHECK: @llvm.x86.sse2.paddus.b + // CHECK-NOT: @llvm.x86.sse2.paddus.b + // CHECK: add <16 x i8> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}} // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}} return _mm_mask_adds_epu8(__W,__U,__A,__B); } __m128i test_mm_maskz_adds_epu8(__mmask16 __U, __m128i __A, __m128i __B) { // CHECK-LABEL: @test_mm_maskz_adds_epu8 - // CHECK: @llvm.x86.sse2.paddus.b + // CHECK-NOT: @llvm.x86.sse2.paddus.b + // CHECK: add <16 x i8> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <16 x i8> %{{.*}}, %{{.*}} + // CHECK: select <16 x i1> %{{.*}}, <16 x i8> , <16 x i8> {{.*}} // CHECK: select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}} return _mm_maskz_adds_epu8(__U,__A,__B); } __m256i test_mm256_mask_adds_epu8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_mask_adds_epu8 - // CHECK: @llvm.x86.avx2.paddus.b + // CHECK-NOT: @llvm.x86.avx2.paddus.b + // CHECK: add <32 x i8> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <32 x i8> %{{.*}}, %{{.*}} + // CHECK: select <32 x i1> %{{.*}}, <32 x i8> , <32 x i8> {{.*}} // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} return _mm256_mask_adds_epu8(__W,__U,__A,__B); } __m256i test_mm256_maskz_adds_epu8(__mmask32 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_maskz_adds_epu8 - // CHECK: @llvm.x86.avx2.paddus.b + // CHECK-NOT: @llvm.x86.avx2.paddus.b + // CHECK: add <32 x i8> %{{.*}}, %{{.*}} + // CHECK: icmp ugt <32 x i8> %{{.*}}, %{{.*}} + // CHECK: select <32 x i1> %{{.*}}, <32 x i8> , <32 x i8> {{.*}} // CHECK: select <32 x i1> %{{.*}}, <32 x i8> %{{.*}}, <32 x i8> %{{.*}} return _mm256_maskz_adds_epu8(__U,__A,__B); } __m128i test_mm_mask_adds_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { // CHECK-LABEL: @test_mm_mask_adds_epu16 - // CHECK: @llvm.x86.sse2.paddus.w + // CHECK-NOT: @llvm.x86.sse2.paddus.w + // CHECK: add <8 x i16> %{{.*}}, %{{.*}} + //
[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer
ebevhan added a comment. I think the solution to a lot of diagnostic and behavior issues with address spaces is to remove predication on OpenCL. It's a bit odd to have a language feature that is enabled out of the box regardless of langoptions (address spaces) but won't actually work properly unless you're building OpenCL. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6943 +def err_typecheck_incompatible_conditional_pointer_operands : Error< + "unable to find common type between %0 and %1 for conditional operation">; This error is very similar to the one in my first comment, `conditional operator with the second and third operands of type ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *') which are pointers to non-overlapping address spaces`. It would normally be emitted at 6472, but won't be since OpenCL isn't enabled. Comment at: test/Sema/conditional-expr.c:78 + // expected-error@-1{{converting '__attribute__((address_space(2))) int *' to type 'void *' changes address space of pointer}} + // expected-error@-2{{converting '__attribute__((address_space(3))) int *' to type 'void *' changes address space of pointer}} rjmccall wrote: > leonardchan wrote: > > rjmccall wrote: > > > Also, these diagnostics seem wrong. Where is `void *` coming from? > > When dumping the AST this is what the resulting type is for the conditional > > expression already is if the operands are 2 pointers with different address > > spaces. > > > > According to this comment, the reason seems to be because this is what GCC > > does: > > > > ``` > > 6512 // In this situation, we assume void* type. No especially good > > 6513 // reason, but this is what gcc does, and we do have to pick > > 6514 // to get a consistent AST. > > ``` > That makes sense in general, but in this case it's not a great diagnostic; we > should just emit an error when trying to pick a common type. Is it possible that you are getting `void *` because we aren't running the qualifier removal at 6495? I don't think I've ever seen spurious `void *`'s show up in our downstream diagnostics. Repository: rC Clang https://reviews.llvm.org/D50278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49223: [AST] Check described template at structural equivalence check.
balazske updated this revision to Diff 159458. balazske marked an inline comment as done. balazske added a comment. - Renamed methods, simplified code, comments updated. Repository: rC Clang https://reviews.llvm.org/D49223 Files: include/clang/AST/ASTStructuralEquivalence.h lib/AST/ASTStructuralEquivalence.cpp unittests/AST/StructuralEquivalenceTest.cpp Index: unittests/AST/StructuralEquivalenceTest.cpp === --- unittests/AST/StructuralEquivalenceTest.cpp +++ unittests/AST/StructuralEquivalenceTest.cpp @@ -78,11 +78,18 @@ } bool testStructuralMatch(Decl *D0, Decl *D1) { -llvm::DenseSet> NonEquivalentDecls; -StructuralEquivalenceContext Ctx( -D0->getASTContext(), D1->getASTContext(), NonEquivalentDecls, -StructuralEquivalenceKind::Default, false, false); -return Ctx.IsEquivalent(D0, D1); +llvm::DenseSet> NonEquivalentDecls01; +llvm::DenseSet> NonEquivalentDecls10; +StructuralEquivalenceContext Ctx01( +D0->getASTContext(), D1->getASTContext(), +NonEquivalentDecls01, StructuralEquivalenceKind::Default, false, false); +StructuralEquivalenceContext Ctx10( +D1->getASTContext(), D0->getASTContext(), +NonEquivalentDecls10, StructuralEquivalenceKind::Default, false, false); +bool Eq01 = Ctx01.IsEquivalent(D0, D1); +bool Eq10 = Ctx10.IsEquivalent(D1, D0); +EXPECT_EQ(Eq01, Eq10); +return Eq01; } bool testStructuralMatch(std::tuple t) { @@ -215,6 +222,14 @@ struct StructuralEquivalenceFunctionTest : StructuralEquivalenceTest { }; +TEST_F(StructuralEquivalenceFunctionTest, TemplateVsNonTemplate) { + auto t = makeNamedDecls( + "void foo();", + "template void foo();", + Lang_CXX); + EXPECT_FALSE(testStructuralMatch(t)); +} + TEST_F(StructuralEquivalenceFunctionTest, ParamConstWithRef) { auto t = makeNamedDecls("void foo(int&);", "void foo(const int&);", Lang_CXX); @@ -618,6 +633,14 @@ EXPECT_FALSE(testStructuralMatch(R0, R1)); } +TEST_F(StructuralEquivalenceRecordTest, TemplateVsNonTemplate) { + auto t = makeDecls( + "struct A { };", + "template struct A { };", + Lang_CXX, + cxxRecordDecl(hasName("A"))); + EXPECT_FALSE(testStructuralMatch(t)); +} TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) { auto t = makeNamedDecls( Index: lib/AST/ASTStructuralEquivalence.cpp === --- lib/AST/ASTStructuralEquivalence.cpp +++ lib/AST/ASTStructuralEquivalence.cpp @@ -1023,7 +1023,7 @@ return true; // If any of the records has external storage and we do a minimal check (or - // AST import) we assmue they are equivalent. (If we didn't have this + // AST import) we assume they are equivalent. (If we didn't have this // assumption then `RecordDecl::LoadFieldsFromExternalStorage` could trigger // another AST import which in turn would call the structural equivalency // check again and finally we'd have an improper result.) @@ -1497,6 +1497,141 @@ return !Finish(); } +bool StructuralEquivalenceContext::CheckCommonEquivalence(Decl *D1, Decl *D2) { + // Check for equivalent described template. + TemplateDecl *Template1 = D1->getDescribedTemplate(); + TemplateDecl *Template2 = D2->getDescribedTemplate(); + if ((Template1 != nullptr) != (Template2 != nullptr)) +return false; + if (Template1 && !IsStructurallyEquivalent(*this, Template1, Template2)) +return false; + + // FIXME: Move check for identifier names into this function. + + return true; +} + +bool StructuralEquivalenceContext::CheckKindSpecificEquivalence( +Decl *D1, Decl *D2) { + // FIXME: Switch on all declaration kinds. For now, we're just going to + // check the obvious ones. + if (auto *Record1 = dyn_cast(D1)) { +if (auto *Record2 = dyn_cast(D2)) { + // Check for equivalent structure names. + IdentifierInfo *Name1 = Record1->getIdentifier(); + if (!Name1 && Record1->getTypedefNameForAnonDecl()) +Name1 = Record1->getTypedefNameForAnonDecl()->getIdentifier(); + IdentifierInfo *Name2 = Record2->getIdentifier(); + if (!Name2 && Record2->getTypedefNameForAnonDecl()) +Name2 = Record2->getTypedefNameForAnonDecl()->getIdentifier(); + if (!::IsStructurallyEquivalent(Name1, Name2) || + !::IsStructurallyEquivalent(*this, Record1, Record2)) +return false; +} else { + // Record/non-record mismatch. + return false; +} + } else if (auto *Enum1 = dyn_cast(D1)) { +if (auto *Enum2 = dyn_cast(D2)) { + // Check for equivalent enum names. + IdentifierInfo *Name1 = Enum1->getIdentifier(); + if (!Name1 && Enum1->getTypedefNameForAnonDecl()) +Name1 = Enum1->getTypedefNameForAnonDecl()->getIdentifier(); + IdentifierInfo *Name2 = Enum2->getIdentifier(); + if (!Name2 &&
Re: r338627 - [test] Fix %hmaptool path for standalone builds
Merged to 7.0 in r339102. On Wed, Aug 1, 2018 at 10:38 PM, Michal Gorny via cfe-commits wrote: > Author: mgorny > Date: Wed Aug 1 13:38:22 2018 > New Revision: 338627 > > URL: http://llvm.org/viewvc/llvm-project?rev=338627=rev > Log: > [test] Fix %hmaptool path for standalone builds > > Fix %hmaptool path to refer to clang_tools_dir instead of > llvm_tools_dir, in order to fix standalone builds. The tool is built > as part of clang, so it won't be found in installed LLVM tools. > > Differential Revision: https://reviews.llvm.org/D50156 > > Modified: > cfe/trunk/test/lit.cfg.py > > Modified: cfe/trunk/test/lit.cfg.py > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=338627=338626=338627=diff > == > --- cfe/trunk/test/lit.cfg.py (original) > +++ cfe/trunk/test/lit.cfg.py Wed Aug 1 13:38:22 2018 > @@ -71,7 +71,7 @@ llvm_config.add_tool_substitutions(tools > > config.substitutions.append( > ('%hmaptool', "'%s' %s" % (config.python_executable, > - os.path.join(config.llvm_tools_dir, > 'hmaptool' > + os.path.join(config.clang_tools_dir, > 'hmaptool' > > # Plugins (loadable modules) > # TODO: This should be supplied by Makefile or autoconf. > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50170: [libcxxabi] Fix test_exception_address_alignment test for ARM
hans added a comment. What do you other reviewers say? I'm not familiar with this code, but this seems reasonable to me. Repository: rCXXA libc++abi https://reviews.llvm.org/D50170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50349: Port getStartLoc -> getBeginLoc
hans added a comment. In https://reviews.llvm.org/D50349#1190029, @rsmith wrote: > +Hans (release manager for LLVM 7) > > Hans, this patch series will affect the API of common Clang classes, > resulting in patches to Clang SVN needing some (mechanical) modifications to > be applied to the Clang 7 release branch if we land it now. What do you think > about that? Would you prefer that we wait until after the 7.0.0 release to > make cherry-picks easier? Thanks for the heads up. It looks mechanical enough that if it does cause merge conflicts, they will be easy enough to resolve. No need to wait. Repository: rC Clang https://reviews.llvm.org/D50349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits