Skip to content

Commit ea66a9b

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:bc9823cf60bf91cc8b45248c4205cd2c67b2a3d5 into amd-gfx:922c3da159e1
Local branch amd-gfx 922c3da Merged main:5d8354c009d5625fa140be47de1f91275f4698d3 into amd-gfx:065d13b47a5a Remote branch main bc9823c [X86][BF16] Change MVT to EVT in combineFP_EXTEND
2 parents 922c3da + bc9823c commit ea66a9b

File tree

22 files changed

+305
-95
lines changed

22 files changed

+305
-95
lines changed

clang/include/clang/Lex/LiteralSupport.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,10 @@ class NumericLiteralParser {
118118
/// bits of the result and return true. Otherwise, return false.
119119
bool GetIntegerValue(llvm::APInt &Val);
120120

121-
/// GetFloatValue - Convert this numeric literal to a floating value, using
122-
/// the specified APFloat fltSemantics (specifying float, double, etc).
123-
/// The optional bool isExact (passed-by-reference) has its value
124-
/// set to true if the returned APFloat can represent the number in the
125-
/// literal exactly, and false otherwise.
126-
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result);
121+
/// Convert this numeric literal to a floating value, using the specified
122+
/// APFloat fltSemantics (specifying float, double, etc) and rounding mode.
123+
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result,
124+
llvm::RoundingMode RM);
127125

128126
/// GetFixedPointValue - Convert this numeric literal value into a
129127
/// scaled integer that represents this value. Returns true if an overflow

clang/lib/Analysis/ThreadSafetyCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
177177
return CapabilityExpr();
178178

179179
if (const auto* SLit = dyn_cast<StringLiteral>(AttrExp)) {
180-
if (SLit->getString() == StringRef("*"))
180+
if (SLit->getString() == "*")
181181
// The "*" expr is a universal lock, which essentially turns off
182182
// checks until it is removed from the lockset.
183183
return CapabilityExpr(new (Arena) til::Wildcard(), StringRef("wildcard"),

clang/lib/Lex/LiteralSupport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,8 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) {
15201520
}
15211521

15221522
llvm::APFloat::opStatus
1523-
NumericLiteralParser::GetFloatValue(llvm::APFloat &Result) {
1523+
NumericLiteralParser::GetFloatValue(llvm::APFloat &Result,
1524+
llvm::RoundingMode RM) {
15241525
using llvm::APFloat;
15251526

15261527
unsigned n = std::min(SuffixBegin - ThisTokBegin, ThisTokEnd - ThisTokBegin);
@@ -1534,8 +1535,7 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat &Result) {
15341535
Str = Buffer;
15351536
}
15361537

1537-
auto StatusOrErr =
1538-
Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
1538+
auto StatusOrErr = Result.convertFromString(Str, RM);
15391539
assert(StatusOrErr && "Invalid floating point representation");
15401540
return !errorToBool(StatusOrErr.takeError()) ? *StatusOrErr
15411541
: APFloat::opInvalidOp;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
640640

641641
if (const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
642642
if (StrLit->getLength() == 0 ||
643-
(StrLit->isOrdinary() && StrLit->getString() == StringRef("*"))) {
643+
(StrLit->isOrdinary() && StrLit->getString() == "*")) {
644644
// Pass empty strings to the analyzer without warnings.
645645
// Treat "*" as the universal lock.
646646
Args.push_back(ArgExp);
@@ -3645,7 +3645,7 @@ bool Sema::checkTargetClonesAttrString(
36453645
llvm::sort(CurFeatures);
36463646
SmallString<64> Res;
36473647
for (auto &CurFeat : CurFeatures) {
3648-
if (!Res.equals(""))
3648+
if (!Res.empty())
36493649
Res.append("+");
36503650
Res.append(CurFeat);
36513651
}

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3699,7 +3699,10 @@ static Expr *BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal,
36993699
using llvm::APFloat;
37003700
APFloat Val(Format);
37013701

3702-
APFloat::opStatus result = Literal.GetFloatValue(Val);
3702+
llvm::RoundingMode RM = S.CurFPFeatures.getRoundingMode();
3703+
if (RM == llvm::RoundingMode::Dynamic)
3704+
RM = llvm::RoundingMode::NearestTiesToEven;
3705+
APFloat::opStatus result = Literal.GetFloatValue(Val, RM);
37033706

37043707
// Overflow is always an error, but underflow is only an error if
37053708
// we underflowed to zero (APFloat reports denormals as underflow).

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14601460
(!PP.getHeaderSearchInfo()
14611461
.getHeaderSearchOpts()
14621462
.ModuleMapFileHomeIsCwd ||
1463-
WritingModule->Directory->getName() != StringRef("."))) {
1463+
WritingModule->Directory->getName() != ".")) {
14641464
// Module directory.
14651465
auto Abbrev = std::make_shared<BitCodeAbbrev>();
14661466
Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));

clang/test/AST/const-fpfeatures.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ float FI1u = 0xFFFFFFFFU;
1919
float _Complex C1u = C0;
2020
// CHECK: @C1u = {{.*}} { float, float } { float 0x3FF0000020000000, float 0x3FF0000020000000 }
2121

22+
float FLu = 0.1F;
23+
// CHECK: @FLu = {{.*}} float 0x3FB99999A0000000
24+
2225

2326
#pragma STDC FENV_ROUND FE_DOWNWARD
2427

@@ -35,3 +38,6 @@ float FI1d = 0xFFFFFFFFU;
3538

3639
float _Complex C1d = C0;
3740
// CHECK: @C1d = {{.*}} { float, float } { float 1.000000e+00, float 1.000000e+00 }
41+
42+
float FLd = 0.1F;
43+
// CHECK: @FLd = {{.*}} float 0x3FB9999980000000

clang/test/AST/const-fpfeatures.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,108 @@ float V7 = []() -> float {
7979
0x0.000001p0F);
8080
}();
8181
// CHECK: @V7 = {{.*}} float 1.000000e+00
82+
83+
#pragma STDC FENV_ROUND FE_DYNAMIC
84+
85+
template<float V> struct L {
86+
constexpr L() : value(V) {}
87+
float value;
88+
};
89+
90+
#pragma STDC FENV_ROUND FE_DOWNWARD
91+
L<0.1F> val_d;
92+
// CHECK: @val_d = {{.*}} { float 0x3FB9999980000000 }
93+
94+
#pragma STDC FENV_ROUND FE_UPWARD
95+
L<0.1F> val_u;
96+
// CHECK: @val_u = {{.*}} { float 0x3FB99999A0000000 }
97+
98+
99+
// Check literals in macros.
100+
101+
#pragma STDC FENV_ROUND FE_DOWNWARD
102+
#define CONSTANT_0_1 0.1F
103+
104+
#pragma STDC FENV_ROUND FE_UPWARD
105+
float C1_ru = CONSTANT_0_1;
106+
// CHECK: @C1_ru = {{.*}} float 0x3FB99999A0000000
107+
108+
#pragma STDC FENV_ROUND FE_DOWNWARD
109+
float C1_rd = CONSTANT_0_1;
110+
// CHECK: @C1_rd = {{.*}} float 0x3FB9999980000000
111+
112+
#pragma STDC FENV_ROUND FE_DOWNWARD
113+
#define PRAGMA(x) _Pragma(#x)
114+
#define CONSTANT_0_1_RM(v, rm) ([](){ PRAGMA(STDC FENV_ROUND rm); return v; }())
115+
116+
#pragma STDC FENV_ROUND FE_UPWARD
117+
float C2_rd = CONSTANT_0_1_RM(0.1F, FE_DOWNWARD);
118+
float C2_ru = CONSTANT_0_1_RM(0.1F, FE_UPWARD);
119+
// CHECK: @C2_rd = {{.*}} float 0x3FB9999980000000
120+
// CHECK: @C2_ru = {{.*}} float 0x3FB99999A0000000
121+
122+
#pragma STDC FENV_ROUND FE_DOWNWARD
123+
float C3_rd = CONSTANT_0_1_RM(0.1F, FE_DOWNWARD);
124+
float C3_ru = CONSTANT_0_1_RM(0.1F, FE_UPWARD);
125+
// CHECK: @C3_rd = {{.*}} float 0x3FB9999980000000
126+
// CHECK: @C3_ru = {{.*}} float 0x3FB99999A0000000
127+
128+
// Check literals in template instantiations.
129+
130+
#pragma STDC FENV_ROUND FE_DYNAMIC
131+
132+
template<typename T, T C>
133+
constexpr T foo() {
134+
return C;
135+
}
136+
137+
#pragma STDC FENV_ROUND FE_DOWNWARD
138+
float var_d = foo<float, 0.1F>();
139+
// CHECK: @var_d = {{.*}} float 0x3FB9999980000000
140+
141+
#pragma STDC FENV_ROUND FE_UPWARD
142+
float var_u = foo<float, 0.1F>();
143+
// CHECK: @var_u = {{.*}} float 0x3FB99999A0000000
144+
145+
#pragma STDC FENV_ROUND FE_DYNAMIC
146+
147+
template<typename T, T f> void foo2() {
148+
T Val = f;
149+
}
150+
151+
void func_01() {
152+
#pragma STDC FENV_ROUND FE_DOWNWARD
153+
foo2<float, 0.1f>();
154+
}
155+
156+
void func_02() {
157+
#pragma STDC FENV_ROUND FE_UPWARD
158+
foo2<float, 0.1f>();
159+
}
160+
161+
// CHECK-LABEL: define {{.*}} void @_Z4foo2IfTnT_Lf3dccccccEEvv()
162+
// CHECK: store float 0x3FB9999980000000, ptr
163+
164+
// CHECK-LABEL: define {{.*}} void @_Z4foo2IfTnT_Lf3dcccccdEEvv()
165+
// CHECK: store float 0x3FB99999A0000000, ptr
166+
167+
168+
#pragma STDC FENV_ROUND FE_DOWNWARD
169+
template <int C>
170+
float tfunc_01() {
171+
return 0.1F; // Must be 0x3FB9999980000000 in all instantiations.
172+
}
173+
template float tfunc_01<0>();
174+
// CHECK-LABEL: define {{.*}} float @_Z8tfunc_01ILi0EEfv()
175+
// CHECK: ret float 0x3FB9999980000000
176+
177+
#pragma STDC FENV_ROUND FE_UPWARD
178+
template float tfunc_01<1>();
179+
// CHECK-LABEL: define {{.*}} float @_Z8tfunc_01ILi1EEfv()
180+
// CHECK: ret float 0x3FB9999980000000
181+
182+
template<> float tfunc_01<2>() {
183+
return 0.1F;
184+
}
185+
// CHECK-LABEL: define {{.*}} float @_Z8tfunc_01ILi2EEfv()
186+
// CHECK: ret float 0x3FB99999A0000000

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,9 @@ class CombinerHelper {
822822
// Given a binop \p MI, commute operands 1 and 2.
823823
void applyCommuteBinOpOperands(MachineInstr &MI);
824824

825+
/// Combine select to integer min/max.
826+
bool matchSelectIMinMax(const MachineOperand &MO, BuildFnTy &MatchInfo);
827+
825828
/// Combine selects.
826829
bool matchSelect(MachineInstr &MI, BuildFnTy &MatchInfo);
827830

@@ -962,9 +965,6 @@ class CombinerHelper {
962965

963966
bool tryFoldSelectOfConstants(GSelect *Select, BuildFnTy &MatchInfo);
964967

965-
/// Try to fold (icmp X, Y) ? X : Y -> integer minmax.
966-
bool tryFoldSelectToIntMinMax(GSelect *Select, BuildFnTy &MatchInfo);
967-
968968
bool isOneOrOneSplat(Register Src, bool AllowUndefs);
969969
bool isZeroOrZeroSplat(Register Src, bool AllowUndefs);
970970
bool isConstantSplatVector(Register Src, int64_t SplatValue,

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 498990
19+
#define LLVM_MAIN_REVISION 498998
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,14 @@ enum EdgeKind_aarch64 : Edge::Kind {
171171
///
172172
/// Fixup expression:
173173
///
174-
/// Fixup <- (Target - Fixup) >> 2 : int19
174+
/// Fixup <- (Target - Fixup + Addend) >> 2 : int19
175+
///
176+
/// Notes:
177+
/// The '19' in the name refers to the number operand bits and follows the
178+
/// naming convention used by the corresponding ELF relocation.
179+
/// Since the low two bits must be zero (because of the 32-bit alignment of
180+
/// the target) the operand is effectively a signed 21-bit number.
181+
///
175182
///
176183
/// Errors:
177184
/// - The result of the unshifted part of the fixup expression must be
@@ -377,6 +384,11 @@ inline bool isADR(uint32_t Instr) {
377384
return (Instr & ADRMask) == 0x10000000;
378385
}
379386

387+
inline bool isLDRLiteral(uint32_t Instr) {
388+
constexpr uint32_t LDRLitMask = 0x3b000000;
389+
return (Instr & LDRLitMask) == 0x18000000;
390+
}
391+
380392
// Returns the amount the address operand of LD/ST (imm12)
381393
// should be shifted right by.
382394
//
@@ -494,16 +506,14 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E) {
494506
}
495507
case LDRLiteral19: {
496508
assert((FixupAddress.getValue() & 0x3) == 0 && "LDR is not 32-bit aligned");
497-
assert(E.getAddend() == 0 && "LDRLiteral19 with non-zero addend");
498509
uint32_t RawInstr = *(ulittle32_t *)FixupPtr;
499-
assert(RawInstr == 0x58000010 && "RawInstr isn't a 64-bit LDR literal");
500-
int64_t Delta = E.getTarget().getAddress() - FixupAddress;
510+
assert(isLDRLiteral(RawInstr) && "RawInstr is not an LDR Literal");
511+
int64_t Delta = E.getTarget().getAddress() + E.getAddend() - FixupAddress;
501512
if (Delta & 0x3)
502513
return make_error<JITLinkError>("LDR literal target is not 32-bit "
503514
"aligned");
504-
if (Delta < -(1 << 20) || Delta > ((1 << 20) - 1))
515+
if (!isInt<21>(Delta))
505516
return makeTargetOutOfRangeError(G, B, E);
506-
507517
uint32_t EncodedImm = ((static_cast<uint32_t>(Delta) >> 2) & 0x7ffff) << 5;
508518
uint32_t FixedInstr = RawInstr | EncodedImm;
509519
*(ulittle32_t *)FixupPtr = FixedInstr;

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,13 @@ def select_to_minmax: GICombineRule<
13071307
[{ return Helper.matchSimplifySelectToMinMax(*${root}, ${info}); }]),
13081308
(apply [{ Helper.applyBuildFn(*${root}, ${info}); }])>;
13091309

1310+
def select_to_iminmax: GICombineRule<
1311+
(defs root:$root, build_fn_matchinfo:$info),
1312+
(match (G_ICMP $tst, $tst1, $x, $y),
1313+
(G_SELECT $root, $tst, $x, $y),
1314+
[{ return Helper.matchSelectIMinMax(${root}, ${info}); }]),
1315+
(apply [{ Helper.applyBuildFnMO(${root}, ${info}); }])>;
1316+
13101317
def match_selects : GICombineRule<
13111318
(defs root:$root, build_fn_matchinfo:$matchinfo),
13121319
(match (wip_match_opcode G_SELECT):$root,
@@ -1670,7 +1677,7 @@ def phi_combines : GICombineGroup<[extend_through_phis]>;
16701677
def bitreverse_shift : GICombineGroup<[bitreverse_shl, bitreverse_lshr]>;
16711678

16721679
def select_combines : GICombineGroup<[select_undef_cmp, select_constant_cmp,
1673-
match_selects]>;
1680+
select_to_iminmax, match_selects]>;
16741681

16751682
def trivial_combines : GICombineGroup<[copy_prop, mul_to_shl, add_p2i_to_ptradd,
16761683
mul_by_neg_one, idempotent_prop]>;

llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Error BasicBlockSectionsProfileReader::ReadV1Profile() {
170170
return false;
171171
// Return a match if debug-info-filename is not specified. Otherwise,
172172
// check for equality.
173-
return DIFilename.empty() || It->second.equals(DIFilename);
173+
return DIFilename.empty() || It->second == DIFilename;
174174
});
175175
if (!FunctionFound) {
176176
// Skip the following profile by setting the profile iterator (FI) to
@@ -317,7 +317,7 @@ Error BasicBlockSectionsProfileReader::ReadV0Profile() {
317317
return false;
318318
// Return a match if debug-info-filename is not specified. Otherwise,
319319
// check for equality.
320-
return DIFilename.empty() || It->second.equals(DIFilename);
320+
return DIFilename.empty() || It->second == DIFilename;
321321
});
322322
if (!FunctionFound) {
323323
// Skip the following profile by setting the profile iterator (FI) to

0 commit comments

Comments
 (0)