[all-commits] [llvm/llvm-project] f3732c: Transform vector SET{LE/ULT/ULE} -> SETLT and SET{...
goldsteinn via All-commits
all-commits at lists.llvm.org
Tue Feb 14 16:59:23 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f3732c2b18df305a1927b9d4a94610421a2750e7
https://github.com/llvm/llvm-project/commit/f3732c2b18df305a1927b9d4a94610421a2750e7
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/urem-seteq-illegal-types.ll
M llvm/test/CodeGen/X86/vector-compare-simplify.ll
M llvm/test/CodeGen/X86/vector-popcnt-128-ult-ugt.ll
M llvm/test/CodeGen/X86/vector-popcnt-256-ult-ugt.ll
M llvm/test/CodeGen/X86/vector-popcnt-512-ult-ugt.ll
Log Message:
-----------
Transform vector SET{LE/ULT/ULE} -> SETLT and SET{GE/UGT/UGE} -> SETGT if possible
SETLT and SETGT can use `{v}pcmpgt` directly whereas the other SETCC
variants require some other instructions as well. On AVX512, which has
vector comparisons for all SETCC variants, this can still be
preferable if the destination is a vector. And if the destination is a
mask, its the same performance.
The transform for unsigned SETCC takes place if we know from
`KnownBits` that LHS/RHS have the same sign.
The transform for LE/GE -> LT/GT takes place if LHS/RHS is constant
and we can inc/dec all elements in the operand without overflowing
(both signed and unsigned).
Alive2 Links (on i8 so they don't timeout):
sge_s: https://alive2.llvm.org/ce/z/rMPt9_
sge_s_2: https://alive2.llvm.org/ce/z/G74Mhs
sge_u: https://alive2.llvm.org/ce/z/PTWARM
sge_u_2: https://alive2.llvm.org/ce/z/L9dsNn
sgt_s: https://alive2.llvm.org/ce/z/q2CHEK
sgt_u: https://alive2.llvm.org/ce/z/YPLnZ8
sle_s: https://alive2.llvm.org/ce/z/HyYhQ_
sle_s_2: https://alive2.llvm.org/ce/z/ck6NkT
sle_u: https://alive2.llvm.org/ce/z/tyF_wN
sle_u_2: https://alive2.llvm.org/ce/z/et8t98
slt_s: https://alive2.llvm.org/ce/z/oCP43b
slt_u: https://alive2.llvm.org/ce/z/EpLLPx
uge_s: https://alive2.llvm.org/ce/z/rqSDwi
uge_s_2: https://alive2.llvm.org/ce/z/67UTXu
uge_u: https://alive2.llvm.org/ce/z/yBNG9C
uge_u_2: https://alive2.llvm.org/ce/z/UhHYc_
ugt_s: https://alive2.llvm.org/ce/z/tY9va4
ugt_u: https://alive2.llvm.org/ce/z/F9zeAT
ule_s: https://alive2.llvm.org/ce/z/1MNgka
ule_s_2: https://alive2.llvm.org/ce/z/oiS7Ls
ule_u: https://alive2.llvm.org/ce/z/8DveC3
ule_u_2: https://alive2.llvm.org/ce/z/jGp2M7
ult_s: https://alive2.llvm.org/ce/z/chzfwP
ult_u: https://alive2.llvm.org/ce/z/Jj_JYu
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D142254
Commit: e29c4393236fae95c57b9eb631a806ff47dc38cd
https://github.com/llvm/llvm-project/commit/e29c4393236fae95c57b9eb631a806ff47dc38cd
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
A llvm/test/CodeGen/X86/icmp-pow2-logic-npow2.ll
Log Message:
-----------
Add tests for folding `(and/or (icmp eq/ne A, Pow2), (icmp eq/ne A, -Pow2))`; NFC
Differential Revision: https://reviews.llvm.org/D142343
Commit: 54a9e992c84cc4b1668329494f4355e7d0b8e470
https://github.com/llvm/llvm-project/commit/54a9e992c84cc4b1668329494f4355e7d0b8e470
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
M llvm/include/llvm/CodeGen/TargetLowering.h
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/lib/Target/X86/X86ISelLowering.h
M llvm/test/CodeGen/X86/icmp-pow2-logic-npow2.ll
Log Message:
-----------
Add Transform for `(and/or (eq/ne A,Pow2),(eq/ne A,-Pow2))`->`(eq/ne (and (and A,Pow2),~(Pow2*2)), 0)`
In many instances this can be preferable if the `icmp` -> `i1` cannot be
done in one instruction (such as X86 for scalars).
At the moment guarded behind `TLI.isDesirableToCombineLogicOpOfSETCC`.
alive2 links:
https://alive2.llvm.org/ce/z/nLm5sN
https://alive2.llvm.org/ce/z/moEcyE
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D142344
Commit: 8b5c3902475b3c23ea87e58bc87541f543782e54
https://github.com/llvm/llvm-project/commit/8b5c3902475b3c23ea87e58bc87541f543782e54
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/test/CodeGen/X86/icmp-pow2-logic-npow2.ll
Log Message:
-----------
Transform `(icmp eq/ne Abs(A), Pow2)` -> `(and/or (icmp eq/ne A,Pow2), (icmp eq/ne A,-Pow2))`
Only if Abs(A) has one use, in which case the `(and/or (icmp eq/ne
A,Pow2), (icmp eq/ne A,-Pow2))` can be optimized in
`DAGCombiner::foldAndOrOfSETCC`.
Alive Links:
EQ: https://alive2.llvm.org/ce/z/gTxSgV
NE: https://alive2.llvm.org/ce/z/MUf57Y
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D142345
Commit: abf6692f951339872fa78ac7a607c4a11a12b2e2
https://github.com/llvm/llvm-project/commit/abf6692f951339872fa78ac7a607c4a11a12b2e2
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
A llvm/test/CodeGen/X86/icmp-abs-C-vec.ll
A llvm/test/CodeGen/X86/icmp-abs-C.ll
Log Message:
-----------
Tests for (and/or (icmp eq/ne A, C), (icmp eq/ne A, -C)) <--> (icmp eq/ne (ABS A), ABS(C)); NFC
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D142600
Commit: 42e11a6ea32174b322d26756450793f1d8405f08
https://github.com/llvm/llvm-project/commit/42e11a6ea32174b322d26756450793f1d8405f08
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-02-14 (Tue, 14 Feb 2023)
Changed paths:
M llvm/include/llvm/CodeGen/TargetLowering.h
M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
M llvm/lib/Target/X86/X86ISelLowering.cpp
M llvm/lib/Target/X86/X86ISelLowering.h
M llvm/test/CodeGen/X86/icmp-abs-C-vec.ll
M llvm/test/CodeGen/X86/icmp-abs-C.ll
Log Message:
-----------
Add transform (and/or (icmp eq/ne (A, C)), (icmp eq/ne (A, -C))) -> (icmp eq/ne (ABS A), ABS(C))
This can be beneficial if there is a fast `ABS` (For example with X86
`vpabs`) or if there is a dominating ABS(A) in the `DAG`.
Note `C` is constant so `ABS(C)` is just a constant.
Alive2 Links:
EQ: https://alive2.llvm.org/ce/z/829F-c
NE: https://alive2.llvm.org/ce/z/tsS8bU
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D142601
Compare: https://github.com/llvm/llvm-project/compare/3e0866bf616b...42e11a6ea321
More information about the All-commits
mailing list