Skip to content

Commit b327416

Browse files
committed
Merge commit '6b3bb44227fc' into amd-staging
2 parents 983af84 + 6b3bb44 commit b327416

File tree

14 files changed

+139
-38
lines changed

14 files changed

+139
-38
lines changed

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ class ParseTreeDumper {
491491
NODE(OmpWhenClause, Modifier)
492492
NODE(parser, OmpDirectiveName)
493493
NODE(parser, OmpDirectiveSpecification)
494+
NODE_ENUM(OmpDirectiveSpecification, Flags)
494495
NODE(parser, OmpTraitPropertyName)
495496
NODE(parser, OmpTraitScore)
496497
NODE(parser, OmpTraitPropertyExtension)

flang/include/flang/Parser/parse-tree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,15 +4502,16 @@ struct OmpClauseList {
45024502
// --- Directives and constructs
45034503

45044504
struct OmpDirectiveSpecification {
4505-
CharBlock source;
4505+
ENUM_CLASS(Flags, None, DeprecatedSyntax);
45064506
TUPLE_CLASS_BOILERPLATE(OmpDirectiveSpecification);
45074507
llvm::omp::Directive DirId() const { //
45084508
return std::get<OmpDirectiveName>(t).v;
45094509
}
45104510
const OmpClauseList &Clauses() const;
45114511

4512+
CharBlock source;
45124513
std::tuple<OmpDirectiveName, std::optional<std::list<OmpArgument>>,
4513-
std::optional<OmpClauseList>>
4514+
std::optional<OmpClauseList>, Flags>
45144515
t;
45154516
};
45164517

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,33 @@ TYPE_PARSER(sourced(construct<OmpErrorDirective>(
996996

997997
// --- Parsers for directives and constructs --------------------------
998998

999-
TYPE_PARSER(sourced(construct<OmpDirectiveSpecification>( //
1000-
sourced(OmpDirectiveNameParser{}),
1001-
maybe(parenthesized(nonemptyList(Parser<OmpArgument>{}))),
1002-
maybe(Parser<OmpClauseList>{}))))
999+
OmpDirectiveSpecification static makeFlushFromOldSyntax1(Verbatim &&text,
1000+
std::optional<OmpClauseList> &&clauses,
1001+
std::optional<std::list<OmpArgument>> &&args,
1002+
OmpDirectiveSpecification::Flags &&flags) {
1003+
return OmpDirectiveSpecification{OmpDirectiveName(text), std::move(args),
1004+
std::move(clauses), std::move(flags)};
1005+
}
1006+
1007+
TYPE_PARSER(sourced(
1008+
// Parse the old syntax: FLUSH [clauses] [(objects)]
1009+
construct<OmpDirectiveSpecification>(
1010+
// Force this old-syntax parser to fail for FLUSH followed by '('.
1011+
// Otherwise it could succeed on the new syntax but have one of
1012+
// lists absent in the parsed result.
1013+
// E.g. for FLUSH(x) SEQ_CST it would find no clauses following
1014+
// the directive name, parse the argument list "(x)" and stop.
1015+
applyFunction<OmpDirectiveSpecification>(makeFlushFromOldSyntax1,
1016+
verbatim("FLUSH"_tok) / !lookAhead("("_tok),
1017+
maybe(Parser<OmpClauseList>{}),
1018+
maybe(parenthesized(nonemptyList(Parser<OmpArgument>{}))),
1019+
pure(OmpDirectiveSpecification::Flags::DeprecatedSyntax))) ||
1020+
// Parse the standard syntax: directive [(arguments)] [clauses]
1021+
construct<OmpDirectiveSpecification>( //
1022+
sourced(OmpDirectiveNameParser{}),
1023+
maybe(parenthesized(nonemptyList(Parser<OmpArgument>{}))),
1024+
maybe(Parser<OmpClauseList>{}),
1025+
pure(OmpDirectiveSpecification::Flags::None))))
10031026

10041027
TYPE_PARSER(sourced(construct<OmpNothingDirective>("NOTHING" >> ok)))
10051028

flang/lib/Parser/unparse.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,14 +2094,30 @@ class UnparseVisitor {
20942094
Word(llvm::omp::getOpenMPDirectiveName(x).str());
20952095
}
20962096
void Unparse(const OmpDirectiveSpecification &x) {
2097-
using ArgList = std::list<parser::OmpArgument>;
2097+
auto unparseArgs{[&]() {
2098+
using ArgList = std::list<parser::OmpArgument>;
2099+
if (auto &args{std::get<std::optional<ArgList>>(x.t)}) {
2100+
Put("(");
2101+
Walk(*args);
2102+
Put(")");
2103+
}
2104+
}};
2105+
auto unparseClauses{[&]() { //
2106+
Walk(std::get<std::optional<OmpClauseList>>(x.t));
2107+
}};
2108+
20982109
Walk(std::get<OmpDirectiveName>(x.t));
2099-
if (auto &args{std::get<std::optional<ArgList>>(x.t)}) {
2100-
Put("(");
2101-
Walk(*args);
2102-
Put(")");
2110+
auto flags{std::get<OmpDirectiveSpecification::Flags>(x.t)};
2111+
if (flags == OmpDirectiveSpecification::Flags::DeprecatedSyntax) {
2112+
if (x.DirId() == llvm::omp::Directive::OMPD_flush) {
2113+
// FLUSH clause arglist
2114+
unparseClauses();
2115+
unparseArgs();
2116+
}
2117+
} else {
2118+
unparseArgs();
2119+
unparseClauses();
21032120
}
2104-
Walk(std::get<std::optional<OmpClauseList>>(x.t));
21052121
}
21062122
void Unparse(const OmpTraitScore &x) {
21072123
Word("SCORE(");
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=52 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
2+
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=52 %s | FileCheck --check-prefix="PARSE-TREE" %s
3+
4+
subroutine f00()
5+
integer :: x
6+
!$omp metadirective when(user={condition(.true.)}: flush seq_cst (x))
7+
end
8+
9+
!UNPARSE: SUBROUTINE f00
10+
!UNPARSE: INTEGER x
11+
!UNPARSE: !$OMP METADIRECTIVE WHEN(USER={CONDITION(.true._4)}: FLUSH SEQ_CST(x))
12+
!UNPARSE: END SUBROUTINE
13+
14+
!PARSE-TREE: OmpMetadirectiveDirective
15+
!PARSE-TREE: | OmpClauseList -> OmpClause -> When -> OmpWhenClause
16+
!PARSE-TREE: | | Modifier -> OmpContextSelectorSpecification -> OmpTraitSetSelector
17+
!PARSE-TREE: | | | OmpTraitSetSelectorName -> Value = User
18+
!PARSE-TREE: | | | OmpTraitSelector
19+
!PARSE-TREE: | | | | OmpTraitSelectorName -> Value = Condition
20+
!PARSE-TREE: | | | | Properties
21+
!PARSE-TREE: | | | | | OmpTraitProperty -> Scalar -> Expr = '.true._4'
22+
!PARSE-TREE: | | | | | | LiteralConstant -> LogicalLiteralConstant
23+
!PARSE-TREE: | | | | | | | bool = 'true'
24+
!PARSE-TREE: | | OmpDirectiveSpecification
25+
!PARSE-TREE: | | | OmpDirectiveName -> llvm::omp::Directive = flush
26+
!PARSE-TREE: | | | OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x'
27+
!PARSE-TREE: | | | OmpClauseList -> OmpClause -> SeqCst
28+
!PARSE-TREE: | | | Flags = DeprecatedSyntax
29+
30+
subroutine f01()
31+
integer :: x
32+
!$omp metadirective when(user={condition(.true.)}: flush(x) seq_cst)
33+
end
34+
35+
!UNPARSE: SUBROUTINE f01
36+
!UNPARSE: INTEGER x
37+
!UNPARSE: !$OMP METADIRECTIVE WHEN(USER={CONDITION(.true._4)}: FLUSH(x) SEQ_CST)
38+
!UNPARSE: END SUBROUTINE
39+
40+
!PARSE-TREE: OmpMetadirectiveDirective
41+
!PARSE-TREE: | OmpClauseList -> OmpClause -> When -> OmpWhenClause
42+
!PARSE-TREE: | | Modifier -> OmpContextSelectorSpecification -> OmpTraitSetSelector
43+
!PARSE-TREE: | | | OmpTraitSetSelectorName -> Value = User
44+
!PARSE-TREE: | | | OmpTraitSelector
45+
!PARSE-TREE: | | | | OmpTraitSelectorName -> Value = Condition
46+
!PARSE-TREE: | | | | Properties
47+
!PARSE-TREE: | | | | | OmpTraitProperty -> Scalar -> Expr = '.true._4'
48+
!PARSE-TREE: | | | | | | LiteralConstant -> LogicalLiteralConstant
49+
!PARSE-TREE: | | | | | | | bool = 'true'
50+
!PARSE-TREE: | | OmpDirectiveSpecification
51+
!PARSE-TREE: | | | OmpDirectiveName -> llvm::omp::Directive = flush
52+
!PARSE-TREE: | | | OmpArgument -> OmpLocator -> OmpObject -> Designator -> DataRef -> Name = 'x'
53+
!PARSE-TREE: | | | OmpClauseList -> OmpClause -> SeqCst
54+
!PARSE-TREE: | | | Flags = None

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,19 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
971971

972972
forwardUses(MI);
973973

974+
// It's possible that the previous transformation has resulted in a no-op
975+
// register move (i.e. one where source and destination registers are the
976+
// same and are not referring to a reserved register). If so, delete it.
977+
CopyOperands = isCopyInstr(MI, *TII, UseCopyInstr);
978+
if (CopyOperands &&
979+
CopyOperands->Source->getReg() == CopyOperands->Destination->getReg() &&
980+
!MRI->isReserved(CopyOperands->Source->getReg())) {
981+
MI.eraseFromParent();
982+
NumDeletes++;
983+
Changed = true;
984+
continue;
985+
}
986+
974987
// Not a copy.
975988
SmallVector<Register, 4> Defs;
976989
const MachineOperand *RegMask = nullptr;

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58095,9 +58095,13 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
5809558095
MVT SrcVT = Op0.getOperand(0).getSimpleValueType();
5809658096
SrcVT = MVT::getVectorVT(SrcVT.getScalarType(),
5809758097
NumOps * SrcVT.getVectorNumElements());
58098-
return DAG.getNode(Op0.getOpcode(), DL, VT,
58099-
ConcatSubOperand(SrcVT, Ops, 0),
58100-
ConcatSubOperand(SrcVT, Ops, 1));
58098+
SDValue Concat0 = CombineSubOperand(SrcVT, Ops, 0);
58099+
SDValue Concat1 = CombineSubOperand(SrcVT, Ops, 1);
58100+
if (Concat0 || Concat1)
58101+
return DAG.getNode(
58102+
Op0.getOpcode(), DL, VT,
58103+
Concat0 ? Concat0 : ConcatSubOperand(SrcVT, Ops, 0),
58104+
Concat1 ? Concat1 : ConcatSubOperand(SrcVT, Ops, 1));
5810158105
}
5810258106
break;
5810358107
case X86ISD::VPERMV:

llvm/test/CodeGen/RISCV/GlobalISel/constbarrier-rv32.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ define void @constant_fold_barrier_i128(ptr %p) {
3838
; RV32-NEXT: seqz a7, a6
3939
; RV32-NEXT: and a1, a7, a1
4040
; RV32-NEXT: add a7, a4, zero
41-
; RV32-NEXT: add a5, a5, zero
4241
; RV32-NEXT: sltu a4, a4, a4
4342
; RV32-NEXT: or a1, a3, a1
4443
; RV32-NEXT: add a7, a7, a1

llvm/test/CodeGen/RISCV/GlobalISel/constbarrier-rv64.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ define i128 @constant_fold_barrier_i128(i128 %x) {
2626
; RV64-NEXT: and a0, a0, a2
2727
; RV64-NEXT: add a0, a0, a2
2828
; RV64-NEXT: sltu a2, a0, a2
29-
; RV64-NEXT: add a1, a1, zero
3029
; RV64-NEXT: add a1, a1, a2
3130
; RV64-NEXT: ret
3231
entry:

llvm/test/CodeGen/RISCV/machine-copyprop-noop-removal.mir

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
## This test was added to capture a case where MachineCopyPropagation risks
55
## leaving a no-op register move (add, x0, reg).
6-
## FIXME: No-op register move is left behind after machine-cp.
76

87
---
98
name: ham
@@ -22,7 +21,6 @@ body: |
2221
; CHECK-NEXT: liveins: $x10
2322
; CHECK-NEXT: {{ $}}
2423
; CHECK-NEXT: $x11 = ADDI $x0, 0
25-
; CHECK-NEXT: renamable $x10 = ADD $x0, killed renamable $x10
2624
; CHECK-NEXT: BEQ renamable $x10, $x0, %bb.4
2725
; CHECK-NEXT: {{ $}}
2826
; CHECK-NEXT: bb.2:

0 commit comments

Comments
 (0)