Skip to content

Commit ff94646

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: Idf773def00fbb66714d4aa98b658dba7332d77cd
2 parents fd720dc + 0e93d04 commit ff94646

File tree

23 files changed

+702
-437
lines changed

23 files changed

+702
-437
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
277277
}
278278

279279
bool dataTraverseStmtPre(Stmt *S) {
280-
if (S && !shouldIgnore(S))
280+
if (!S) {
281+
return true;
282+
}
283+
if (Check->IgnoreMacros && S->getBeginLoc().isMacroID()) {
284+
return false;
285+
}
286+
if (!shouldIgnore(S))
281287
StmtStack.push_back(S);
282288
return true;
283289
}
@@ -583,6 +589,7 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
583589
SimplifyBooleanExprCheck::SimplifyBooleanExprCheck(StringRef Name,
584590
ClangTidyContext *Context)
585591
: ClangTidyCheck(Name, Context),
592+
IgnoreMacros(Options.get("IgnoreMacros", false)),
586593
ChainedConditionalReturn(Options.get("ChainedConditionalReturn", false)),
587594
ChainedConditionalAssignment(
588595
Options.get("ChainedConditionalAssignment", false)),
@@ -671,6 +678,7 @@ void SimplifyBooleanExprCheck::reportBinOp(const ASTContext &Context,
671678
}
672679

673680
void SimplifyBooleanExprCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
681+
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
674682
Options.store(Opts, "ChainedConditionalReturn", ChainedConditionalReturn);
675683
Options.store(Opts, "ChainedConditionalAssignment",
676684
ChainedConditionalAssignment);

clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SimplifyBooleanExprCheck : public ClangTidyCheck {
6464
StringRef Description, SourceRange ReplacementRange,
6565
StringRef Replacement);
6666

67+
const bool IgnoreMacros;
6768
const bool ChainedConditionalReturn;
6869
const bool ChainedConditionalAssignment;
6970
const bool SimplifyDeMorgan;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ Changes in existing checks
496496
<clang-tidy/checks/readability/non-const-parameter>` check to ignore
497497
false-positives in initializer list of record.
498498

499+
- Improved :doc:`readability-simplify-boolean-expr
500+
<clang-tidy/checks/readability/simplify-boolean-expr>` check by adding the
501+
new option `IgnoreMacros` that allows to ignore boolean expressions originating
502+
from expanded macros.
503+
499504
- Improved :doc:`readability-simplify-subscript-expr
500505
<clang-tidy/checks/readability/simplify-subscript-expr>` check by extending
501506
the default value of the `Types` option to include ``std::span``.

clang-tools-extra/docs/clang-tidy/checks/readability/simplify-boolean-expr.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ Examples:
8282
Options
8383
-------
8484

85+
.. option:: IgnoreMacros
86+
87+
If `true`, ignore boolean expressions originating from expanded macros.
88+
Default is `false`.
89+
8590
.. option:: ChainedConditionalReturn
8691

8792
If `true`, conditional boolean return statements at the end of an
@@ -99,8 +104,8 @@ Options
99104

100105
.. option:: SimplifyDeMorganRelaxed
101106

102-
If `true`, :option:`SimplifyDeMorgan` will also transform negated
103-
conjunctions and disjunctions where there is no negation on either operand.
107+
If `true`, :option:`SimplifyDeMorgan` will also transform negated
108+
conjunctions and disjunctions where there is no negation on either operand.
104109
This option has no effect if :option:`SimplifyDeMorgan` is `false`.
105110
Default is `false`.
106111

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %check_clang_tidy -check-suffixes=,MACROS %s readability-simplify-boolean-expr %t
2+
3+
// Ignore expressions in macros.
4+
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t \
5+
// RUN: -- -config="{CheckOptions: {readability-simplify-boolean-expr.IgnoreMacros: true}}" \
6+
// RUN: --
7+
8+
#define NEGATE(expr) !(expr)
9+
10+
bool without_macro(bool a, bool b) {
11+
return !(!a && b);
12+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem
13+
// CHECK-FIXES: return a || !b;
14+
}
15+
16+
bool macro(bool a, bool b) {
17+
return NEGATE(!a && b);
18+
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem
19+
// CHECK-FIXES: return NEGATE(!a && b);
20+
}

clang/docs/UsersManual.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,6 +3963,60 @@ implicitly included in later levels.
39633963
- ``-march=x86-64-v3``: (close to Haswell) AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE
39643964
- ``-march=x86-64-v4``: AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL
39653965

3966+
`Intel AVX10 ISA <https://cdrdv2.intel.com/v1/dl/getContent/784267>`_ is
3967+
a major new vector ISA incorporating the modern vectorization aspects of
3968+
Intel AVX-512. This ISA will be supported on all future Intel processors.
3969+
Users are supposed to use the new options ``-mavx10.N`` and ``-mavx10.N-512``
3970+
on these processors and should not use traditional AVX512 options anymore.
3971+
3972+
The ``N`` in ``-mavx10.N`` represents a continuous integer number starting
3973+
from ``1``. ``-mavx10.N`` is an alias of ``-mavx10.N-256``, which means to
3974+
enable all instructions within AVX10 version N at a maximum vector length of
3975+
256 bits. ``-mavx10.N-512`` enables all instructions at a maximum vector
3976+
length of 512 bits, which is a superset of instructions ``-mavx10.N`` enabled.
3977+
3978+
Current binaries built with AVX512 features can run on Intel AVX10/512 capable
3979+
processors without re-compile, but cannot run on AVX10/256 capable processors.
3980+
Users need to re-compile their code with ``-mavx10.N``, and maybe update some
3981+
code that calling to 512-bit X86 specific intrinsics and passing or returning
3982+
512-bit vector types in function call, if they want to run on AVX10/256 capable
3983+
processors. Binaries built with ``-mavx10.N`` can run on both AVX10/256 and
3984+
AVX10/512 capable processors.
3985+
3986+
Users can add a ``-mno-evex512`` in the command line with AVX512 options if
3987+
they want to run the binary on both legacy AVX512 and new AVX10/256 capable
3988+
processors. The option has the same constraints as ``-mavx10.N``, i.e.,
3989+
cannot call to 512-bit X86 specific intrinsics and pass or return 512-bit vector
3990+
types in function call.
3991+
3992+
Users should avoid using AVX512 features in function target attributes when
3993+
developing code for AVX10. If they have to do so, they need to add an explicit
3994+
``evex512`` or ``no-evex512`` together with AVX512 features for 512-bit or
3995+
non-512-bit functions respectively to avoid unexpected code generation. Both
3996+
command line option and target attribute of EVEX512 feature can only be used
3997+
with AVX512. They don't affect vector size of AVX10.
3998+
3999+
User should not mix the use AVX10 and AVX512 options together at any time,
4000+
because the option combinations are conflicting sometimes. For example, a
4001+
combination of ``-mavx512f -mavx10.1-256`` doesn't show a clear intention to
4002+
compiler, since instructions in AVX512F and AVX10.1/256 intersect but do not
4003+
overlap. In this case, compiler will emit warning for it, but the behavior
4004+
is determined. It will generate the same code as option ``-mavx10.1-512``.
4005+
A similar case is ``-mavx512f -mavx10.2-256``, which equals to
4006+
``-mavx10.1-512 -mavx10.2-256``, because ``avx10.2-256`` implies ``avx10.1-256``
4007+
and ``-mavx512f -mavx10.1-256`` equals to ``-mavx10.1-512``.
4008+
4009+
There are some new macros introduced with AVX10 support. ``-mavx10.1-256`` will
4010+
enable ``__AVX10_1__`` and ``__EVEX256__``, while ``-mavx10.1-512`` enables
4011+
``__AVX10_1__``, ``__EVEX256__``, ``__EVEX512__`` and ``__AVX10_1_512__``.
4012+
Besides, both ``-mavx10.1-256`` and ``-mavx10.1-512`` will enable all AVX512
4013+
feature specific macros. A AVX512 feature will enable both ``__EVEX256__``,
4014+
``__EVEX512__`` and its own macro. So ``__EVEX512__`` can be used to guard code
4015+
that can run on both legacy AVX512 and AVX10/512 capable processors but cannot
4016+
run on AVX10/256, while a AVX512 macro like ``__AVX512F__`` cannot tell the
4017+
difference among the three options. Users need to check additional macros
4018+
``__AVX10_1__`` and ``__EVEX512__`` if they want to make distinction.
4019+
39664020
ARM
39674021
^^^
39684022

0 commit comments

Comments
 (0)