Skip to content

Commit 1d001a3

Browse files
Merge branch 'main' into drop-cmp0116-old
2 parents 795a1cc + 5d4a0d5 commit 1d001a3

File tree

67 files changed

+2119
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2119
-321
lines changed

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "../utils/FixItHintUtils.h"
1111
#include "clang/AST/ASTContext.h"
1212
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
1314
#include "clang/Lex/Lexer.h"
1415
#include "clang/Tooling/FixIt.h"
1516
#include <queue>
@@ -26,6 +27,8 @@ AST_MATCHER(Stmt, isMacroExpansion) {
2627
return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc);
2728
}
2829

30+
AST_MATCHER(Stmt, isC23) { return Finder->getASTContext().getLangOpts().C23; }
31+
2932
bool isNULLMacroExpansion(const Stmt *Statement, ASTContext &Context) {
3033
SourceManager &SM = Context.getSourceManager();
3134
const LangOptions &LO = Context.getLangOpts();
@@ -298,6 +301,11 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
298301
hasCastKind(CK_FloatingToBoolean),
299302
hasCastKind(CK_PointerToBoolean),
300303
hasCastKind(CK_MemberPointerToBoolean)),
304+
// Exclude cases of C23 comparison result.
305+
unless(allOf(isC23(),
306+
hasSourceExpression(ignoringParens(
307+
binaryOperator(hasAnyOperatorName(
308+
">", ">=", "==", "!=", "<", "<=")))))),
301309
// Exclude case of using if or while statements with variable
302310
// declaration, e.g.:
303311
// if (int var = functionCall()) {}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ Changes in existing checks
249249
- Improved :doc:`readability-implicit-bool-conversion
250250
<clang-tidy/checks/readability/implicit-bool-conversion>` check
251251
by adding the option `UseUpperCaseLiteralSuffix` to select the
252-
case of the literal suffix in fixes.
252+
case of the literal suffix in fixes and fixing false positive for implicit
253+
conversion of comparison result in C23.
253254

254255
- Improved :doc:`readability-redundant-smartptr-get
255256
<clang-tidy/checks/readability/redundant-smartptr-get>` check to

clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ void implicitConversionToBoolFromUnaryMinusAndZeroLiterals() {
304304
// CHECK-FIXES: functionTakingBool((-0.0) != 0.0);
305305
}
306306

307+
void ignoreImplicitCastToBoolForComparisonResult() {
308+
bool boolFromComparison0 = 1 != 0;
309+
bool boolFromComparison1 = 1 == 0;
310+
bool boolFromComparison2 = 1 > 0;
311+
bool boolFromComparison3 = 1 >= 0;
312+
bool boolFromComparison4 = 1 < 0;
313+
bool boolFromComparison5 = 1 <= 0;
314+
}
315+
307316
void ignoreExplicitCastsToBool() {
308317
int integer = 10;
309318
bool boolComingFromInt = (bool)integer;

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,10 @@ X86 Support
628628
* Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
629629
``*_(mask(z)))_minmax_s[s|d|h]``.
630630

631+
- Supported intrinsics for ``SM4 and AVX10.2``.
632+
* Supported SM4 intrinsics of ``_mm512_sm4key4_epi32`` and
633+
``_mm512_sm4rnds4_epi32``.
634+
631635
- All intrinsics in adcintrin.h can now be used in constant expressions.
632636

633637
- All intrinsics in adxintrin.h can now be used in constant expressions.

clang/include/clang/Basic/BuiltinsX86.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,10 @@ TARGET_BUILTIN(__builtin_ia32_vsm4key4256, "V8UiV8UiV8Ui", "nV:256:", "sm4")
21792179
TARGET_BUILTIN(__builtin_ia32_vsm4rnds4128, "V4UiV4UiV4Ui", "nV:128:", "sm4")
21802180
TARGET_BUILTIN(__builtin_ia32_vsm4rnds4256, "V8UiV8UiV8Ui", "nV:256:", "sm4")
21812181

2182+
// SM4_EVEX
2183+
TARGET_BUILTIN(__builtin_ia32_vsm4key4512, "V16UiV16UiV16Ui", "nV:512:", "avx10.2-512,sm4")
2184+
TARGET_BUILTIN(__builtin_ia32_vsm4rnds4512, "V16UiV16UiV16Ui", "nV:512:", "avx10.2-512,sm4")
2185+
21822186
// AVX10 MINMAX
21832187
TARGET_BUILTIN(__builtin_ia32_vminmaxnepbf16128, "V8yV8yV8yIi", "nV:128:", "avx10.2-256")
21842188
TARGET_BUILTIN(__builtin_ia32_vminmaxnepbf16256, "V16yV16yV16yIi", "nV:256:", "avx10.2-256")

clang/include/clang/Sema/SemaInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ inline InheritableAttr *getDLLAttr(Decl *D) {
5858
}
5959

6060
/// Retrieve the depth and index of a template parameter.
61-
inline std::pair<unsigned, unsigned> getDepthAndIndex(NamedDecl *ND) {
61+
inline std::pair<unsigned, unsigned> getDepthAndIndex(const NamedDecl *ND) {
6262
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(ND))
6363
return std::make_pair(TTP->getDepth(), TTP->getIndex());
6464

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20492,8 +20492,8 @@ static NVPTXMmaInfo getNVPTXMmaInfo(unsigned BuiltinID) {
2049220492
#undef MMA_VARIANTS_B1_XOR
2049320493
}
2049420494

20495-
static Value *MakeLdgLdu(unsigned IntrinsicID, CodeGenFunction &CGF,
20496-
const CallExpr *E) {
20495+
static Value *MakeLdu(unsigned IntrinsicID, CodeGenFunction &CGF,
20496+
const CallExpr *E) {
2049720497
Value *Ptr = CGF.EmitScalarExpr(E->getArg(0));
2049820498
QualType ArgType = E->getArg(0)->getType();
2049920499
clang::CharUnits Align = CGF.CGM.getNaturalPointeeTypeAlignment(ArgType);
@@ -20503,6 +20503,21 @@ static Value *MakeLdgLdu(unsigned IntrinsicID, CodeGenFunction &CGF,
2050320503
{Ptr, ConstantInt::get(CGF.Builder.getInt32Ty(), Align.getQuantity())});
2050420504
}
2050520505

20506+
static Value *MakeLdg(CodeGenFunction &CGF, const CallExpr *E) {
20507+
Value *Ptr = CGF.EmitScalarExpr(E->getArg(0));
20508+
QualType ArgType = E->getArg(0)->getType();
20509+
clang::CharUnits AlignV = CGF.CGM.getNaturalPointeeTypeAlignment(ArgType);
20510+
llvm::Type *ElemTy = CGF.ConvertTypeForMem(ArgType->getPointeeType());
20511+
20512+
// Use addrspace(1) for NVPTX ADDRESS_SPACE_GLOBAL
20513+
auto *ASC = CGF.Builder.CreateAddrSpaceCast(Ptr, CGF.Builder.getPtrTy(1));
20514+
auto *LD = CGF.Builder.CreateAlignedLoad(ElemTy, ASC, AlignV.getAsAlign());
20515+
MDNode *MD = MDNode::get(CGF.Builder.getContext(), {});
20516+
LD->setMetadata(LLVMContext::MD_invariant_load, MD);
20517+
20518+
return LD;
20519+
}
20520+
2050620521
static Value *MakeScopedAtomic(unsigned IntrinsicID, CodeGenFunction &CGF,
2050720522
const CallExpr *E) {
2050820523
Value *Ptr = CGF.EmitScalarExpr(E->getArg(0));
@@ -20536,9 +20551,11 @@ static Value *MakeHalfType(unsigned IntrinsicID, unsigned BuiltinID,
2053620551
return nullptr;
2053720552
}
2053820553

20539-
if (IntrinsicID == Intrinsic::nvvm_ldg_global_f ||
20540-
IntrinsicID == Intrinsic::nvvm_ldu_global_f)
20541-
return MakeLdgLdu(IntrinsicID, CGF, E);
20554+
if (BuiltinID == NVPTX::BI__nvvm_ldg_h || BuiltinID == NVPTX::BI__nvvm_ldg_h2)
20555+
return MakeLdg(CGF, E);
20556+
20557+
if (IntrinsicID == Intrinsic::nvvm_ldu_global_f)
20558+
return MakeLdu(IntrinsicID, CGF, E);
2054220559

2054320560
SmallVector<Value *, 16> Args;
2054420561
auto *F = CGF.CGM.getIntrinsic(IntrinsicID);
@@ -20675,16 +20692,15 @@ Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID,
2067520692
case NVPTX::BI__nvvm_ldg_ul2:
2067620693
case NVPTX::BI__nvvm_ldg_ull:
2067720694
case NVPTX::BI__nvvm_ldg_ull2:
20678-
// PTX Interoperability section 2.2: "For a vector with an even number of
20679-
// elements, its alignment is set to number of elements times the alignment
20680-
// of its member: n*alignof(t)."
20681-
return MakeLdgLdu(Intrinsic::nvvm_ldg_global_i, *this, E);
2068220695
case NVPTX::BI__nvvm_ldg_f:
2068320696
case NVPTX::BI__nvvm_ldg_f2:
2068420697
case NVPTX::BI__nvvm_ldg_f4:
2068520698
case NVPTX::BI__nvvm_ldg_d:
2068620699
case NVPTX::BI__nvvm_ldg_d2:
20687-
return MakeLdgLdu(Intrinsic::nvvm_ldg_global_f, *this, E);
20700+
// PTX Interoperability section 2.2: "For a vector with an even number of
20701+
// elements, its alignment is set to number of elements times the alignment
20702+
// of its member: n*alignof(t)."
20703+
return MakeLdg(*this, E);
2068820704

2068920705
case NVPTX::BI__nvvm_ldu_c:
2069020706
case NVPTX::BI__nvvm_ldu_sc:
@@ -20715,13 +20731,13 @@ Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID,
2071520731
case NVPTX::BI__nvvm_ldu_ul2:
2071620732
case NVPTX::BI__nvvm_ldu_ull:
2071720733
case NVPTX::BI__nvvm_ldu_ull2:
20718-
return MakeLdgLdu(Intrinsic::nvvm_ldu_global_i, *this, E);
20734+
return MakeLdu(Intrinsic::nvvm_ldu_global_i, *this, E);
2071920735
case NVPTX::BI__nvvm_ldu_f:
2072020736
case NVPTX::BI__nvvm_ldu_f2:
2072120737
case NVPTX::BI__nvvm_ldu_f4:
2072220738
case NVPTX::BI__nvvm_ldu_d:
2072320739
case NVPTX::BI__nvvm_ldu_d2:
20724-
return MakeLdgLdu(Intrinsic::nvvm_ldu_global_f, *this, E);
20740+
return MakeLdu(Intrinsic::nvvm_ldu_global_f, *this, E);
2072520741

2072620742
case NVPTX::BI__nvvm_atom_cta_add_gen_i:
2072720743
case NVPTX::BI__nvvm_atom_cta_add_gen_l:
@@ -21195,14 +21211,11 @@ Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID,
2119521211
return MakeHalfType(Intrinsic::nvvm_fmin_xorsign_abs_f16x2, BuiltinID, E,
2119621212
*this);
2119721213
case NVPTX::BI__nvvm_ldg_h:
21198-
return MakeHalfType(Intrinsic::nvvm_ldg_global_f, BuiltinID, E, *this);
2119921214
case NVPTX::BI__nvvm_ldg_h2:
21200-
return MakeHalfType(Intrinsic::nvvm_ldg_global_f, BuiltinID, E, *this);
21215+
return MakeHalfType(Intrinsic::not_intrinsic, BuiltinID, E, *this);
2120121216
case NVPTX::BI__nvvm_ldu_h:
21217+
case NVPTX::BI__nvvm_ldu_h2:
2120221218
return MakeHalfType(Intrinsic::nvvm_ldu_global_f, BuiltinID, E, *this);
21203-
case NVPTX::BI__nvvm_ldu_h2: {
21204-
return MakeHalfType(Intrinsic::nvvm_ldu_global_f, BuiltinID, E, *this);
21205-
}
2120621219
case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
2120721220
return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
2120821221
Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *this, E,

clang/lib/Headers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ set(x86_files
243243
shaintrin.h
244244
sm3intrin.h
245245
sm4intrin.h
246+
sm4evexintrin.h
246247
smmintrin.h
247248
tbmintrin.h
248249
tmmintrin.h

clang/lib/Headers/immintrin.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ _storebe_i64(void * __P, long long __D) {
677677
#include <avx10_2_512satcvtintrin.h>
678678
#endif
679679

680+
#if !defined(__SCE__) || __has_feature(modules) || \
681+
(defined(__AVX10_2_512__) && defined(__SM4__))
682+
#include <sm4evexintrin.h>
683+
#endif
684+
680685
#if !defined(__SCE__) || __has_feature(modules) || defined(__ENQCMD__)
681686
#include <enqcmdintrin.h>
682687
#endif

clang/lib/Headers/sm4evexintrin.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*===--------------- sm4evexintrin.h - SM4 EVEX intrinsics -----------------===
2+
*
3+
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
* See https://llvm.org/LICENSE.txt for license information.
5+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*
7+
*===----------------------------------------------------------------------===
8+
*/
9+
#ifndef __IMMINTRIN_H
10+
#error "Never use <sm4evexintrin.h> directly; include <immintrin.h> instead."
11+
#endif // __IMMINTRIN_H
12+
13+
#ifndef __SM4EVEXINTRIN_H
14+
#define __SM4EVEXINTRIN_H
15+
16+
#define __DEFAULT_FN_ATTRS512 \
17+
__attribute__((__always_inline__, __nodebug__, \
18+
__target__("sm4,avx10.2-512"), __min_vector_width__(512)))
19+
20+
static __inline__ __m512i __DEFAULT_FN_ATTRS512
21+
_mm512_sm4key4_epi32(__m512i __A, __m512i __B) {
22+
return (__m512i)__builtin_ia32_vsm4key4512((__v16su)__A, (__v16su)__B);
23+
}
24+
25+
static __inline__ __m512i __DEFAULT_FN_ATTRS512
26+
_mm512_sm4rnds4_epi32(__m512i __A, __m512i __B) {
27+
return (__m512i)__builtin_ia32_vsm4rnds4512((__v16su)__A, (__v16su)__B);
28+
}
29+
30+
#undef __DEFAULT_FN_ATTRS512
31+
32+
#endif // __SM4EVEXINTRIN_H

0 commit comments

Comments
 (0)