[all-commits] [llvm/llvm-project] 3ddd5a: [AArch64][SVE] Add more ptest removal tests
Cullen Rhodes via All-commits
all-commits at lists.llvm.org
Tue Nov 15 02:54:35 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3ddd5a848f0da3fd54bd6f4d42441020c5d60735
https://github.com/llvm/llvm-project/commit/3ddd5a848f0da3fd54bd6f4d42441020c5d60735
Author: Cullen Rhodes <cullen.rhodes at arm.com>
Date: 2022-11-15 (Tue, 15 Nov 2022)
Changed paths:
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll
Log Message:
-----------
[AArch64][SVE] Add more ptest removal tests
Precommit test containing examples where PTEST is incorrectly optimized
away. Later patches will fix incorrect optimizations.
Reviewed By: bsmith
Differential Revision: https://reviews.llvm.org/D137715
Commit: ce3e7eb96888f55347a1e1714c5ae65e7a472a70
https://github.com/llvm/llvm-project/commit/ce3e7eb96888f55347a1e1714c5ae65e7a472a70
Author: Cullen Rhodes <cullen.rhodes at arm.com>
Date: 2022-11-15 (Tue, 15 Nov 2022)
Changed paths:
M llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpeq.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpeq.mir
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpge.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpgt.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmphi.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmphs.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmple.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmplo.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpls.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmplt.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-cmpne.ll
M llvm/test/CodeGen/AArch64/sve-ptest-removal-pfirst-pnext.ll
M llvm/test/CodeGen/AArch64/sve-setcc.ll
Log Message:
-----------
[AArch64][SVE] Fix bad PTEST(PG, OP(PG, ...)) optimization
AArch64InstrInfo::optimizePTestInstr attempts to remove a PTEST of a
predicate generating operation that identically sets flags (implictly).
When the PTEST and the predicate-generating operation use the same mask
the PTEST is currently removed. This is incorrect since it doesn't
consider element size. PTEST operates on 8-bit predicates, but for
instructions like compare that also support 16/32/64-bit predicates, the
implicit PTEST performed by the instruction will consider fewer lanes
for these element sizes and could set different first or last active
flags.
For example, consider the following instruction sequence
ptrue p0.b ; P0=1111-1111-1111-1111
index z0.s, #0, #1 ; Z0=<0,1,2,3>
index z1.s, #1, #1 ; Z1=<1,2,3,4>
cmphi p1.s, p0/z, z1.s, z0.s ; P1=0001-0001-0001-0001
; ^ last active
ptest p0, p1.b ; P1=0001-0001-0001-0001
; ^ last active
where the compare generates a canonical all active 32-bit predicate (equivalent
to 'ptrue p1.s, all'). The implicit PTEST sets the last active flag, whereas
the PTEST instruction with the same mask doesn't.
This patch restricts the optimization to instructions operating on 8-bit
predicates. One caveat is the optimization is safe regardless of element
size for any active, this will be addressed in a later patch.
Reviewed By: bsmith
Differential Revision: https://reviews.llvm.org/D137716
Compare: https://github.com/llvm/llvm-project/compare/b95f54350c85...ce3e7eb96888
More information about the All-commits
mailing list