diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 93787672b4440b..3cf77137ec12eb 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -9,6 +9,7 @@ #include "check-omp-structure.h" #include "flang/Parser/parse-tree.h" #include "flang/Semantics/tools.h" +#include namespace Fortran::semantics { @@ -160,8 +161,8 @@ void OmpStructureChecker::Enter(const parser::OmpEndSectionsDirective &x) { switch (dir.v) { // 2.7.2 end-sections -> END SECTIONS [nowait-clause] case llvm::omp::Directive::OMPD_sections: - SetContextDirectiveEnum(llvm::omp::Directive::OMPD_end_sections); - SetContextAllowedOnce(OmpClauseSet{llvm::omp::Clause::OMPC_nowait}); + PushContextAndClauseSets( + dir.source, llvm::omp::Directive::OMPD_end_sections); break; default: // no clauses are allowed @@ -183,8 +184,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPDeclareTargetConstruct &x) { PushContext(dir.source, llvm::omp::Directive::OMPD_declare_target); const auto &spec{std::get(x.t)}; if (std::holds_alternative(spec.u)) { - SetContextAllowed( - OmpClauseSet{llvm::omp::Clause::OMPC_to, llvm::omp::Clause::OMPC_link}); + SetClauseSets(llvm::omp::Directive::OMPD_declare_target); } } @@ -248,17 +248,13 @@ void OmpStructureChecker::Enter(const parser::OmpEndBlockDirective &x) { switch (dir.v) { // 2.7.3 end-single-clause -> copyprivate-clause | // nowait-clause - case llvm::omp::Directive::OMPD_single: { - SetContextDirectiveEnum(llvm::omp::Directive::OMPD_end_single); - OmpClauseSet allowed{llvm::omp::Clause::OMPC_copyprivate}; - SetContextAllowed(allowed); - OmpClauseSet allowedOnce{llvm::omp::Clause::OMPC_nowait}; - SetContextAllowedOnce(allowedOnce); - } break; + case llvm::omp::Directive::OMPD_single: + PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_end_single); + break; // 2.7.4 end-workshare -> END WORKSHARE [nowait-clause] case llvm::omp::Directive::OMPD_workshare: - SetContextDirectiveEnum(llvm::omp::Directive::OMPD_end_workshare); - SetContextAllowed(OmpClauseSet{llvm::omp::Clause::OMPC_nowait}); + PushContextAndClauseSets( + dir.source, llvm::omp::Directive::OMPD_end_workshare); break; default: // no clauses are allowed @@ -300,11 +296,8 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) { std::get(clause->u)}; if (orderedClause.v) { - if (FindClause(llvm::omp::Clause::OMPC_linear)) { - context_.Say(clause->source, - "A loop directive may not have both a LINEAR clause and " - "an ORDERED clause with a parameter"_err_en_US); - } + CheckNotAllowedIfClause( + llvm::omp::Clause::OMPC_ordered, {llvm::omp::Clause::OMPC_linear}); if (auto *clause2{FindClause(llvm::omp::Clause::OMPC_collapse)}) { const auto &collapseClause{ @@ -347,19 +340,13 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) { } } } - // TODO: A list-item cannot appear in more than one aligned clause } // SIMD // 2.7.3 Single Construct Restriction if (GetContext().directive == llvm::omp::Directive::OMPD_end_single) { - if (auto *clause{FindClause(llvm::omp::Clause::OMPC_copyprivate)}) { - if (FindClause(llvm::omp::Clause::OMPC_nowait)) { - context_.Say(clause->source, - "The COPYPRIVATE clause must not be used with " - "the NOWAIT clause"_err_en_US); - } - } + CheckNotAllowedIfClause( + llvm::omp::Clause::OMPC_copyprivate, {llvm::omp::Clause::OMPC_nowait}); } GetContext().requiredClauses.IterateOverMembers( @@ -410,7 +397,6 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Ordered &x) { // the parameter of ordered clause is optional if (const auto &expr{x.v}) { RequiresConstantPositiveParameter(llvm::omp::Clause::OMPC_ordered, *expr); - // 2.8.3 Loop SIMD Construct Restriction if (llvm::omp::doSimdSet.test(GetContext().directive)) { context_.Say(GetContext().clauseSource, @@ -436,13 +422,7 @@ void OmpStructureChecker::Enter(const parser::OmpAlignedClause &x) { if (const auto &expr{ std::get>(x.t)}) { - if (const auto v{GetIntValue(*expr)}) { - if (*v <= 0) { - context_.Say(GetContext().clauseSource, - "The ALIGNMENT parameter of the ALIGNED clause must be " - "a constant positive integer expression"_err_en_US); - } - } + RequiresConstantPositiveParameter(llvm::omp::Clause::OMPC_aligned, *expr); } // 2.8.1 TODO: list-item attribute check } @@ -501,6 +481,28 @@ void OmpStructureChecker::Enter(const parser::OmpLinearClause &x) { } } } + +void OmpStructureChecker::CheckAllowedMapTypes( + const parser::OmpMapType::Type &type, + const std::list &allowedMapTypeList) { + const auto found{std::find( + std::begin(allowedMapTypeList), std::end(allowedMapTypeList), type)}; + if (found == std::end(allowedMapTypeList)) { + std::string commaSeperatedMapTypes; + llvm::interleave( + allowedMapTypeList.begin(), allowedMapTypeList.end(), + [&](const parser::OmpMapType::Type &mapType) { + commaSeperatedMapTypes.append(parser::ToUpperCaseLetters( + parser::OmpMapType::EnumToString(mapType))); + }, + [&] { commaSeperatedMapTypes.append(", "); }); + context_.Say(GetContext().clauseSource, + "Only the %s map types are permitted " + "for MAP clauses on the %s directive"_err_en_US, + commaSeperatedMapTypes, ContextDirectiveAsFortran()); + } +} + void OmpStructureChecker::Enter(const parser::OmpMapClause &x) { CheckAllowed(llvm::omp::Clause::OMPC_map); if (const auto &maptype{std::get>(x.t)}) { @@ -513,31 +515,16 @@ void OmpStructureChecker::Enter(const parser::OmpMapClause &x) { case llvm::omp::Directive::OMPD_target_teams_distribute_simd: case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do: case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do_simd: - case llvm::omp::Directive::OMPD_target_data: { - if (type != Type::To && type != Type::From && type != Type::Tofrom && - type != Type::Alloc) { - context_.Say(GetContext().clauseSource, - "Only the TO, FROM, TOFROM, or ALLOC map types are permitted " - "for MAP clauses on the %s directive"_err_en_US, - ContextDirectiveAsFortran()); - } - } break; - case llvm::omp::Directive::OMPD_target_enter_data: { - if (type != Type::To && type != Type::Alloc) { - context_.Say(GetContext().clauseSource, - "Only the TO or ALLOC map types are permitted " - "for MAP clauses on the %s directive"_err_en_US, - ContextDirectiveAsFortran()); - } - } break; - case llvm::omp::Directive::OMPD_target_exit_data: { - if (type != Type::Delete && type != Type::Release && type != Type::From) { - context_.Say(GetContext().clauseSource, - "Only the FROM, RELEASE, or DELETE map types are permitted " - "for MAP clauses on the %s directive"_err_en_US, - ContextDirectiveAsFortran()); - } - } break; + case llvm::omp::Directive::OMPD_target_data: + CheckAllowedMapTypes( + type, {Type::To, Type::From, Type::Tofrom, Type::Alloc}); + break; + case llvm::omp::Directive::OMPD_target_enter_data: + CheckAllowedMapTypes(type, {Type::To, Type::Alloc}); + break; + case llvm::omp::Directive::OMPD_target_exit_data: + CheckAllowedMapTypes(type, {Type::From, Type::Release, Type::Delete}); + break; default: break; } diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index fbb319f30f9f95..cf10608efa725e 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -171,7 +171,8 @@ class OmpStructureChecker // specific clause related bool ScheduleModifierHasType(const parser::OmpScheduleClause &, const parser::OmpScheduleModifierType::ModType &); - + void CheckAllowedMapTypes(const parser::OmpMapType::Type &, + const std::list &); llvm::StringRef getClauseName(llvm::omp::Clause clause) override; llvm::StringRef getDirectiveName(llvm::omp::Directive directive) override; diff --git a/flang/test/Semantics/omp-clause-validity01.f90 b/flang/test/Semantics/omp-clause-validity01.f90 index aa51dfd9dcbb0c..5ff748ec33c6d7 100644 --- a/flang/test/Semantics/omp-clause-validity01.f90 +++ b/flang/test/Semantics/omp-clause-validity01.f90 @@ -214,8 +214,9 @@ a = 3.14 enddo + !ERROR: Clause LINEAR is not allowed if clause ORDERED appears on the DO directive + !ERROR: Clause LINEAR is not allowed if clause ORDERED appears on the DO directive !ERROR: The parameter of the ORDERED clause must be a constant positive integer expression - !ERROR: A loop directive may not have both a LINEAR clause and an ORDERED clause with a parameter !$omp do ordered(1-1) private(b) linear(b) linear(a) do i = 1, N a = 3.14 @@ -319,7 +320,7 @@ !ERROR: LASTPRIVATE clause is not allowed on the SINGLE directive !$omp single private(a) lastprivate(c) a = 3.14 - !ERROR: The COPYPRIVATE clause must not be used with the NOWAIT clause + !ERROR: Clause NOWAIT is not allowed if clause COPYPRIVATE appears on the END SINGLE directive !ERROR: At most one NOWAIT clause can appear on the END SINGLE directive !$omp end single copyprivate(a) nowait nowait c = 2 @@ -365,7 +366,7 @@ a = 3.14 enddo - !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression + !ERROR: The parameter of the ALIGNED clause must be a constant positive integer expression !$omp simd aligned(b:-2) do i = 1, N a = 3.14 @@ -552,7 +553,7 @@ enddo !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression - !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression + !ERROR: The parameter of the ALIGNED clause must be a constant positive integer expression !$omp taskloop simd simdlen(-1) aligned(a:-2) do i = 1, N a = 3.14 diff --git a/flang/test/Semantics/omp-combined-constructs.f90 b/flang/test/Semantics/omp-combined-constructs.f90 index 78821cf0e06cb7..afb70b7eda66f3 100644 --- a/flang/test/Semantics/omp-combined-constructs.f90 +++ b/flang/test/Semantics/omp-combined-constructs.f90 @@ -205,7 +205,7 @@ program main enddo !$omp end target teams - !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET TEAMS directive + !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET TEAMS directive !$omp target teams map(delete:a) do i = 1, N a(i) = 3.14 @@ -305,7 +305,7 @@ program main enddo !$omp end target teams distribute - !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE directive + !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE directive !$omp target teams distribute map(delete:a) do i = 1, N a(i) = 3.14 @@ -398,7 +398,7 @@ program main enddo !$omp end target teams distribute parallel do - !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE PARALLEL DO directive + !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE PARALLEL DO directive !$omp target teams distribute parallel do map(delete:a) do i = 1, N a(i) = 3.14 @@ -498,7 +498,7 @@ program main enddo !$omp end target teams distribute parallel do simd - !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive + !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive !$omp target teams distribute parallel do simd map(delete:a) do i = 1, N a(i) = 3.14 diff --git a/flang/test/Semantics/omp-device-constructs.f90 b/flang/test/Semantics/omp-device-constructs.f90 index 7b3eef22524f02..8386744571d2ff 100644 --- a/flang/test/Semantics/omp-device-constructs.f90 +++ b/flang/test/Semantics/omp-device-constructs.f90 @@ -109,7 +109,7 @@ program main enddo !$omp end target - !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET directive + !ERROR: Only the TO, FROM, TOFROM, ALLOC map types are permitted for MAP clauses on the TARGET directive !$omp target map(delete:a) do i = 1, N a = 3.14 @@ -132,7 +132,7 @@ program main !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive !$omp target enter data map(to:a) if(.true.) if(.false.) - !ERROR: Only the TO or ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive + !ERROR: Only the TO, ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive !$omp target enter data map(from:a) !$omp target exit data map(delete:a) @@ -140,7 +140,7 @@ program main !ERROR: At most one DEVICE clause can appear on the TARGET EXIT DATA directive !$omp target exit data map(from:a) device(0) device(1) - !ERROR: Only the FROM, RELEASE, or DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive + !ERROR: Only the FROM, RELEASE, DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive !$omp target exit data map(to:a) !$omp target diff --git a/llvm/include/llvm/Analysis/DominanceFrontier.h b/llvm/include/llvm/Analysis/DominanceFrontier.h index f67929c997f936..cef5e03b3b7a7c 100644 --- a/llvm/include/llvm/Analysis/DominanceFrontier.h +++ b/llvm/include/llvm/Analysis/DominanceFrontier.h @@ -26,7 +26,6 @@ #include #include #include -#include namespace llvm { diff --git a/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h b/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h index f7bbd07a63ab5a..e3e679608784a4 100644 --- a/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h +++ b/llvm/include/llvm/CodeGen/MachineDominanceFrontier.h @@ -14,7 +14,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Support/GenericDomTree.h" -#include namespace llvm { diff --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h index cf3af4d38223b6..46bf73cdd7b634 100644 --- a/llvm/include/llvm/CodeGen/MachineDominators.h +++ b/llvm/include/llvm/CodeGen/MachineDominators.h @@ -23,7 +23,6 @@ #include "llvm/Support/GenericDomTreeConstruction.h" #include #include -#include namespace llvm { diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td index e7351769754756..3a93dd73edeb0f 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -895,7 +895,12 @@ def OMP_Distribute : Directive<"distribute"> { VersionedClause ]; } -def OMP_DeclareTarget : Directive<"declare target"> {} +def OMP_DeclareTarget : Directive<"declare target"> { + let allowedClauses = [ + VersionedClause, + VersionedClause + ]; +} def OMP_EndDeclareTarget : Directive<"end declare target"> {} def OMP_DistributeParallelFor : Directive<"distribute parallel for"> { let allowedClauses = [ @@ -1606,9 +1611,24 @@ def OMP_ParallelWorkshare : Directive<"parallel workshare"> { def OMP_Workshare : Directive<"workshare"> {} def OMP_EndDo : Directive<"end do"> {} def OMP_EndDoSimd : Directive<"end do simd"> {} -def OMP_EndSections : Directive<"end sections"> {} -def OMP_EndSingle : Directive<"end single"> {} -def OMP_EndWorkshare : Directive<"end workshare"> {} +def OMP_EndSections : Directive<"end sections"> { + let allowedOnceClauses = [ + VersionedClause + ]; +} +def OMP_EndSingle : Directive<"end single"> { + let allowedClauses = [ + VersionedClause + ]; + let allowedOnceClauses = [ + VersionedClause + ]; +} +def OMP_EndWorkshare : Directive<"end workshare"> { + let allowedClauses = [ + VersionedClause + ]; +} def OMP_Unknown : Directive<"unknown"> { let isDefault = true; } diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index e59ebd701528b5..15b04c0c7357e4 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -779,14 +779,14 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) { if (TLI.getPointerTy(DL) == MVT::i64) { Opc = X86::MOV64rm; RC = &X86::GR64RegClass; - - if (Subtarget->isPICStyleRIPRel()) - StubAM.Base.Reg = X86::RIP; } else { Opc = X86::MOV32rm; RC = &X86::GR32RegClass; } + if (Subtarget->isPICStyleRIPRel()) + StubAM.Base.Reg = X86::RIP; + LoadReg = createResultReg(RC); MachineInstrBuilder LoadMI = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), LoadReg); diff --git a/llvm/test/Analysis/BasicAA/recphi.ll b/llvm/test/Analysis/BasicAA/recphi.ll index f0ddb8c94751b1..26114fc60e1cac 100644 --- a/llvm/test/Analysis/BasicAA/recphi.ll +++ b/llvm/test/Analysis/BasicAA/recphi.ll @@ -188,6 +188,28 @@ bb5: ; preds = %bb3, %bb4 ret i16 0 } +; CHECK-LABEL: Function: dynamic_offset +; CHECK: NoAlias: i8* %a, i8* %p.base +; CHECK: MayAlias: i8* %p, i8* %p.base +; CHECK: MayAlias: i8* %a, i8* %p +; CHECK: MayAlias: i8* %p.base, i8* %p.next +; CHECK: MayAlias: i8* %a, i8* %p.next +; CHECK: MayAlias: i8* %p, i8* %p.next +define void @dynamic_offset(i1 %c, i8* noalias %p.base) { +entry: + %a = alloca i8 + br label %loop + +loop: + %p = phi i8* [ %p.base, %entry ], [ %p.next, %loop ] + %offset = call i16 @call(i32 0) + %p.next = getelementptr inbounds i8, i8* %p, i16 %offset + br i1 %c, label %loop, label %exit + +exit: + ret void +} + ; TODO: Currently yields an asymmetric result. ; CHECK-LABEL: Function: symmetry ; CHECK: MayAlias: i32* %p, i32* %p.base diff --git a/llvm/test/CodeGen/X86/pic.ll b/llvm/test/CodeGen/X86/pic.ll index f03dc3f4a28552..8cf0602c57a871 100644 --- a/llvm/test/CodeGen/X86/pic.ll +++ b/llvm/test/CodeGen/X86/pic.ll @@ -1,4 +1,6 @@ -; RUN: llc < %s -mcpu=generic -mtriple=i686-pc-linux-gnu -relocation-model=pic -asm-verbose=false -post-RA-scheduler=false | FileCheck %s -check-prefix=LINUX +; RUN: llc < %s -mcpu=generic -mtriple=i686-pc-linux-gnu -relocation-model=pic -asm-verbose=false -post-RA-scheduler=false | FileCheck %s -check-prefixes=CHECK,CHECK-I686 +; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-linux-gnux32 -relocation-model=pic -asm-verbose=false -post-RA-scheduler=false | FileCheck %s -check-prefixes=CHECK,CHECK-X32 +; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-linux-gnux32 -relocation-model=pic -asm-verbose=false -post-RA-scheduler=false -fast-isel | FileCheck %s -check-prefixes=CHECK,CHECK-X32 @ptr = external global i32* @dst = external global i32 @@ -11,15 +13,19 @@ entry: store i32 %tmp.s, i32* @dst ret void -; LINUX-LABEL: test0: -; LINUX: calll .L0$pb -; LINUX-NEXT: .L0$pb: -; LINUX-NEXT: popl -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L0$pb), -; LINUX: movl dst@GOT(%eax), -; LINUX: movl ptr@GOT(%eax), -; LINUX: movl src@GOT(%eax), -; LINUX: ret +; CHECK-LABEL: test0: +; CHECK-I686: calll .L0$pb +; CHECK-I686-NEXT: .L0$pb: +; CHECK-I686-NEXT: popl +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L0$pb), +; CHECK-I686: movl dst@GOT(%eax), +; CHECK-I686: movl ptr@GOT(%eax), +; CHECK-I686: movl src@GOT(%eax), +; CHECK-I686: ret +; CHECK-DAG-X32: movl dst@GOTPCREL(%rip), +; CHECK-DAG-X32: movl ptr@GOTPCREL(%rip), +; CHECK-DAG-X32: movl src@GOTPCREL(%rip), +; CHECK-X32: retq } @ptr2 = global i32* null @@ -33,15 +39,19 @@ entry: store i32 %tmp.s, i32* @dst2 ret void -; LINUX-LABEL: test1: -; LINUX: calll .L1$pb -; LINUX-NEXT: .L1$pb: -; LINUX-NEXT: popl -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L1$pb), %eax -; LINUX: movl dst2@GOT(%eax), -; LINUX: movl ptr2@GOT(%eax), -; LINUX: movl src2@GOT(%eax), -; LINUX: ret +; CHECK-LABEL: test1: +; CHECK-I686: calll .L1$pb +; CHECK-I686-NEXT: .L1$pb: +; CHECK-I686-NEXT: popl +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L1$pb), %eax +; CHECK-I686: movl dst2@GOT(%eax), +; CHECK-I686: movl ptr2@GOT(%eax), +; CHECK-I686: movl src2@GOT(%eax), +; CHECK-I686: ret +; CHECK-DAG-X32: movl dst2@GOTPCREL(%rip), +; CHECK-DAG-X32: movl ptr2@GOTPCREL(%rip), +; CHECK-DAG-X32: movl src2@GOTPCREL(%rip), +; CHECK-X32: retq } @@ -51,18 +61,24 @@ define void @test2() nounwind { entry: %ptr = call i8* @malloc(i32 40) ret void -; LINUX-LABEL: test2: -; LINUX: pushl %ebx -; LINUX-NEXT: subl $8, %esp -; LINUX-NEXT: calll .L2$pb -; LINUX-NEXT: .L2$pb: -; LINUX-NEXT: popl %ebx -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L2$pb), %ebx -; LINUX: movl $40, (%esp) -; LINUX: calll malloc@PLT -; LINUX: addl $8, %esp -; LINUX: popl %ebx -; LINUX: ret +; CHECK-LABEL: test2: +; CHECK-I686: pushl %ebx +; CHECK-I686-NEXT: subl $8, %esp +; CHECK-I686-NEXT: calll .L2$pb +; CHECK-I686-NEXT: .L2$pb: +; CHECK-I686-NEXT: popl %ebx +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L2$pb), %ebx +; CHECK-I686: movl $40, (%esp) +; CHECK-I686: calll malloc@PLT +; CHECK-I686: addl $8, %esp +; CHECK-I686: popl %ebx +; CHECK-I686: ret +; CHECK-X32: pushq %rax +; CHECK-X32: movl $40, %edi +; CHECK-X32: callq malloc@PLT +; CHECK-X32: popq %rax +; CHECK-X32: retq + } @pfoo = external global void(...)* @@ -74,14 +90,17 @@ entry: %tmp1 = load void(...)*, void(...)** @pfoo call void(...) %tmp1() ret void -; LINUX-LABEL: test3: -; LINUX: calll .L3$pb -; LINUX-NEXT: .L3$pb: -; LINUX: popl -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L3$pb), %[[REG3:e..]] -; LINUX: calll afoo@PLT -; LINUX: movl pfoo@GOT(%[[REG3]]), -; LINUX: calll * +; CHECK-LABEL: test3: +; CHECK-I686: calll .L3$pb +; CHECK-I686-NEXT: .L3$pb: +; CHECK-I686: popl +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L3$pb), %[[REG3:e..]] +; CHECK-I686: calll afoo@PLT +; CHECK-I686: movl pfoo@GOT(%[[REG3]]), +; CHECK-I686: calll * +; CHECK-X32: callq afoo@PLT +; CHECK-X32: movl pfoo@GOTPCREL(%rip), +; CHECK-X32: callq * } declare void(...)* @afoo(...) @@ -90,11 +109,13 @@ define void @test4() nounwind { entry: call void(...) @foo() ret void -; LINUX-LABEL: test4: -; LINUX: calll .L4$pb -; LINUX: popl %ebx -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L4$pb), %ebx -; LINUX: calll foo@PLT +; CHECK-LABEL: test4: +; CHECK-I686: calll .L4$pb +; CHECK-I686: popl %ebx +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L4$pb), %ebx +; CHECK-I686: calll foo@PLT +; CHECK-X32: callq foo@PLT + } declare void @foo(...) @@ -111,16 +132,21 @@ entry: store i32 %tmp.s, i32* @dst6 ret void -; LINUX-LABEL: test5: -; LINUX: calll .L5$pb -; LINUX-NEXT: .L5$pb: -; LINUX-NEXT: popl %eax -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L5$pb), %eax -; LINUX: leal dst6@GOTOFF(%eax), %ecx -; LINUX: movl %ecx, ptr6@GOTOFF(%eax) -; LINUX: movl src6@GOTOFF(%eax), %ecx -; LINUX: movl %ecx, dst6@GOTOFF(%eax) -; LINUX: ret +; CHECK-LABEL: test5: +; CHECK-I686: calll .L5$pb +; CHECK-I686-NEXT: .L5$pb: +; CHECK-I686-NEXT: popl %eax +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L5$pb), %eax +; CHECK-I686: leal dst6@GOTOFF(%eax), %ecx +; CHECK-I686: movl %ecx, ptr6@GOTOFF(%eax) +; CHECK-I686: movl src6@GOTOFF(%eax), %ecx +; CHECK-I686: movl %ecx, dst6@GOTOFF(%eax) +; CHECK-I686: ret +; CHECK-X32: leal dst6(%rip), %eax +; CHECK-X32: movl %eax, ptr6(%rip) +; CHECK-X32: movl src6(%rip), %eax +; CHECK-X32: movl %eax, dst6(%rip) +; CHECK-X32: retq } @@ -131,13 +157,14 @@ entry: %retval = select i1 %tmp, double 4.561230e+02, double 1.234560e+02 ret double %retval -; LINUX: .LCPI6_0: +; CHECK: .LCPI6_0: -; LINUX-LABEL: test6: -; LINUX: calll .L6$pb -; LINUX: .L6$pb: -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L6$pb), -; LINUX: fldl .LCPI6_0@GOTOFF( +; CHECK-LABEL: test6: +; CHECK-I686: calll .L6$pb +; CHECK-I686: .L6$pb: +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L6$pb), +; CHECK-I686: fldl .LCPI6_0@GOTOFF( +; CHECK-X32: .LCPI6_0(%rip), } @@ -185,22 +212,38 @@ bb12: tail call void(...) @foo6() ret void -; LINUX-LABEL: test7: -; LINUX: calll .L7$pb -; LINUX: .L7$pb: -; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L7$pb), -; LINUX: .LJTI7_0@GOTOFF( -; LINUX: jmpl * - -; LINUX: .p2align 2 -; LINUX-NEXT: .LJTI7_0: -; LINUX: .long .LBB7_2@GOTOFF -; LINUX: .long .LBB7_8@GOTOFF -; LINUX: .long .LBB7_4@GOTOFF -; LINUX: .long .LBB7_6@GOTOFF -; LINUX: .long .LBB7_5@GOTOFF -; LINUX: .long .LBB7_8@GOTOFF -; LINUX: .long .LBB7_7@GOTOFF +; CHECK-LABEL: test7: +; CHECK-I686: calll .L7$pb +; CHECK-I686: .L7$pb: +; CHECK-I686: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L7$pb), +; CHECK-I686: .LJTI7_0@GOTOFF( +; CHECK-I686: jmpl * +; CHECK-X32: leal .LJTI7_0(%rip), %eax +; CHECK-X32: addl (%eax,%edi,4), %eax +; CHECK-X32: jmpq *%rax + +; CHECK: .p2align 2 +; CHECK-NEXT: .LJTI7_0: +; CHECK-I686: .long .LBB7_2@GOTOFF +; CHECK-I686: .long .LBB7_8@GOTOFF +; CHECK-I686: .long .LBB7_4@GOTOFF +; CHECK-I686: .long .LBB7_6@GOTOFF +; CHECK-I686: .long .LBB7_5@GOTOFF +; CHECK-I686: .long .LBB7_8@GOTOFF +; CHECK-I686: .long .LBB7_7@GOTOFF +; CHECK-X32: .long .LBB7_3-.LJTI7_0 +; CHECK-X32: .long .LBB7_3-.LJTI7_0 +; CHECK-X32: .long .LBB7_12-.LJTI7_0 +; CHECK-X32: .long .LBB7_8-.LJTI7_0 +; CHECK-X32: .long .LBB7_12-.LJTI7_0 +; CHECK-X32: .long .LBB7_10-.LJTI7_0 +; CHECK-X32: .long .LBB7_8-.LJTI7_0 +; CHECK-X32: .long .LBB7_9-.LJTI7_0 +; CHECK-X32: .long .LBB7_10-.LJTI7_0 +; CHECK-X32: .long .LBB7_9-.LJTI7_0 +; CHECK-X32: .long .LBB7_12-.LJTI7_0 +; CHECK-X32: .long .LBB7_14-.LJTI7_0 +; CHECK-X32: .long .LBB7_14-.LJTI7_0 } declare void @foo1(...) diff --git a/llvm/test/CodeGen/X86/vector-reduce-or-cmp.ll b/llvm/test/CodeGen/X86/vector-reduce-or-cmp.ll index 1d00782f21778c..a06c7052044e65 100644 --- a/llvm/test/CodeGen/X86/vector-reduce-or-cmp.ll +++ b/llvm/test/CodeGen/X86/vector-reduce-or-cmp.ll @@ -3,8 +3,8 @@ ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefixes=SSE,SSE41 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2 -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512 -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512vl | FileCheck %s --check-prefixes=AVX,AVX512 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512,AVX512BW +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw,+avx512vl | FileCheck %s --check-prefixes=AVX,AVX512,AVX512BWVL ; ; vXi64 @@ -1122,22 +1122,43 @@ define i32 @mask_v3i1(<3 x i32> %a, <3 x i32> %b) { ; AVX2-NEXT: movl $1, %eax ; AVX2-NEXT: retq ; -; AVX512-LABEL: mask_v3i1: -; AVX512: # %bb.0: -; AVX512: vpcmpneqd %{{.}}mm1, %{{.}}mm0, %k0 -; AVX512-NEXT: kshiftrw $2, %k0, %k1 -; AVX512-NEXT: korw %k1, %k0, %k1 -; AVX512-NEXT: kshiftrw $1, %k0, %k0 -; AVX512-NEXT: korw %k0, %k1, %k0 -; AVX512-NEXT: kmovd %k0, %eax -; AVX512-NEXT: testb $1, %al -; AVX512-NEXT: je .LBB27_2 -; AVX512-NEXT: # %bb.1: -; AVX512-NEXT: xorl %eax, %eax -; AVX512: retq -; AVX512-NEXT: .LBB27_2: -; AVX512-NEXT: movl $1, %eax -; AVX512: retq +; AVX512BW-LABEL: mask_v3i1: +; AVX512BW: # %bb.0: +; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1 +; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0 +; AVX512BW-NEXT: vpcmpneqd %zmm1, %zmm0, %k0 +; AVX512BW-NEXT: kshiftrw $2, %k0, %k1 +; AVX512BW-NEXT: korw %k1, %k0, %k1 +; AVX512BW-NEXT: kshiftrw $1, %k0, %k0 +; AVX512BW-NEXT: korw %k0, %k1, %k0 +; AVX512BW-NEXT: kmovd %k0, %eax +; AVX512BW-NEXT: testb $1, %al +; AVX512BW-NEXT: je .LBB27_2 +; AVX512BW-NEXT: # %bb.1: +; AVX512BW-NEXT: xorl %eax, %eax +; AVX512BW-NEXT: vzeroupper +; AVX512BW-NEXT: retq +; AVX512BW-NEXT: .LBB27_2: +; AVX512BW-NEXT: movl $1, %eax +; AVX512BW-NEXT: vzeroupper +; AVX512BW-NEXT: retq +; +; AVX512BWVL-LABEL: mask_v3i1: +; AVX512BWVL: # %bb.0: +; AVX512BWVL-NEXT: vpcmpneqd %xmm1, %xmm0, %k0 +; AVX512BWVL-NEXT: kshiftrw $2, %k0, %k1 +; AVX512BWVL-NEXT: korw %k1, %k0, %k1 +; AVX512BWVL-NEXT: kshiftrw $1, %k0, %k0 +; AVX512BWVL-NEXT: korw %k0, %k1, %k0 +; AVX512BWVL-NEXT: kmovd %k0, %eax +; AVX512BWVL-NEXT: testb $1, %al +; AVX512BWVL-NEXT: je .LBB27_2 +; AVX512BWVL-NEXT: # %bb.1: +; AVX512BWVL-NEXT: xorl %eax, %eax +; AVX512BWVL-NEXT: retq +; AVX512BWVL-NEXT: .LBB27_2: +; AVX512BWVL-NEXT: movl $1, %eax +; AVX512BWVL-NEXT: retq %1 = icmp ne <3 x i32> %a, %b %2 = call i1 @llvm.vector.reduce.or.v3i1(<3 x i1> %1) br i1 %2, label %3, label %4