[PATCH] D152658: [InstCombine] Change SimplifyDemandedVectorElts to use PoisonElts instead of UndefElts
Manuel Brito via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 11 14:35:46 PDT 2023
ManuelJBrito created this revision.
ManuelJBrito added reviewers: t.p.northover, uweigand, arsenm, RKSimon, efriedma, nikic, spatel.
Herald added subscribers: pmatos, asb, foad, StephenFan, lebedev.ri, kerbowa, pengfei, hiraditya, sbc100, jvesely.
Herald added a reviewer: lebedev.ri.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, aheejin, wdng.
Herald added projects: clang, LLVM.
This patch changes InstCombine's SimplifyDemandedVectorElts to use PoisonElts instead of UndefElts. It now treats undef elements as DemandedElts and keeps track of poison elements only.
This fixes some undef related bugs marked with LLVM PR44185 in
https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=a9bc405e427c007f.
Such as:
Transforms/InstCombine/insert-const-shuf.ll
Transforms/InstCombine/sub-of-negatible.ll
Transforms/InstCombine/vec_shuffle.ll
At this point, frontends should not be emitting undef values, so losing the undef optimizations should be OK.
In most cases, it should be OK to go from UndefElts to PoisonElts because PoisonElts is a subset of UndefElts.
The only cases that might be of concern are the ones where target specific intrinsics are optimized based on SimplifyDemandedVectorElts.
After this patch they might be emitting poison where there was previously undef. This might break the semantics of those intrinsics. Requesting reviewers for those cases.
This change also allows for more aggressive optimization because poison is more undefined than undef. For example:
gep(X, poison) -> poison is OK
gep(X, undef) -> undef is NOT OK. (see https://github.com/llvm/llvm-project/issues/44790)
Previously we weren't allowed to do this because there was no way to distinguish between undef and poison elements.
These optimizations can be done in follow-up patches.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152658
Files:
clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
clang/test/CodeGen/aarch64-neon-vcmla.c
clang/test/CodeGen/nofpclass.c
clang/test/Headers/wasm.c
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/AArch64/demandelts.ll
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts-inseltpoison.ll
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts.ll
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-simplify-image-buffer-stores.ll
llvm/test/Transforms/InstCombine/X86/clmulqdq.ll
llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
llvm/test/Transforms/InstCombine/X86/x86-avx2.ll
llvm/test/Transforms/InstCombine/X86/x86-avx512-inseltpoison.ll
llvm/test/Transforms/InstCombine/X86/x86-avx512.ll
llvm/test/Transforms/InstCombine/X86/x86-muldq.ll
llvm/test/Transforms/InstCombine/X86/x86-pack-inseltpoison.ll
llvm/test/Transforms/InstCombine/X86/x86-pack.ll
llvm/test/Transforms/InstCombine/X86/x86-pshufb-inseltpoison.ll
llvm/test/Transforms/InstCombine/X86/x86-pshufb.ll
llvm/test/Transforms/InstCombine/X86/x86-sse4a-inseltpoison.ll
llvm/test/Transforms/InstCombine/X86/x86-sse4a.ll
llvm/test/Transforms/InstCombine/X86/x86-vector-shifts.ll
llvm/test/Transforms/InstCombine/X86/x86-vpermil.ll
llvm/test/Transforms/InstCombine/assume.ll
llvm/test/Transforms/InstCombine/bitcast-vec-canon-inseltpoison.ll
llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
llvm/test/Transforms/InstCombine/bitreverse.ll
llvm/test/Transforms/InstCombine/broadcast.ll
llvm/test/Transforms/InstCombine/bswap.ll
llvm/test/Transforms/InstCombine/extractelement.ll
llvm/test/Transforms/InstCombine/icmp-bc-vec.ll
llvm/test/Transforms/InstCombine/icmp-vec.ll
llvm/test/Transforms/InstCombine/inselt-binop.ll
llvm/test/Transforms/InstCombine/insert-const-shuf.ll
llvm/test/Transforms/InstCombine/insert-extract-shuffle-inseltpoison.ll
llvm/test/Transforms/InstCombine/insert-extract-shuffle.ll
llvm/test/Transforms/InstCombine/logical-select.ll
llvm/test/Transforms/InstCombine/masked_intrinsics-inseltpoison.ll
llvm/test/Transforms/InstCombine/masked_intrinsics.ll
llvm/test/Transforms/InstCombine/matrix-multiplication-negation.ll
llvm/test/Transforms/InstCombine/nsw.ll
llvm/test/Transforms/InstCombine/pr38984.ll
llvm/test/Transforms/InstCombine/select-binop-cmp.ll
llvm/test/Transforms/InstCombine/select-extractelement-inseltpoison.ll
llvm/test/Transforms/InstCombine/select-extractelement.ll
llvm/test/Transforms/InstCombine/shift-add.ll
llvm/test/Transforms/InstCombine/shuffle-cast.ll
llvm/test/Transforms/InstCombine/shuffle-select-narrow.ll
llvm/test/Transforms/InstCombine/shuffle_select.ll
llvm/test/Transforms/InstCombine/shufflevec-bitcast.ll
llvm/test/Transforms/InstCombine/shufflevector-div-rem-inseltpoison.ll
llvm/test/Transforms/InstCombine/shufflevector-div-rem.ll
llvm/test/Transforms/InstCombine/sub-of-negatible.ll
llvm/test/Transforms/InstCombine/trunc-extractelement-inseltpoison.ll
llvm/test/Transforms/InstCombine/trunc-extractelement.ll
llvm/test/Transforms/InstCombine/trunc.ll
llvm/test/Transforms/InstCombine/type_pun.ll
llvm/test/Transforms/InstCombine/vec_demanded_elts-inseltpoison.ll
llvm/test/Transforms/InstCombine/vec_demanded_elts.ll
llvm/test/Transforms/InstCombine/vec_gep_scalar_arg.ll
llvm/test/Transforms/InstCombine/vec_phi_extract-inseltpoison.ll
llvm/test/Transforms/InstCombine/vec_phi_extract.ll
llvm/test/Transforms/InstCombine/vec_shuffle-inseltpoison.ll
llvm/test/Transforms/InstCombine/vec_shuffle.ll
llvm/test/Transforms/InstCombine/vector-casts-inseltpoison.ll
llvm/test/Transforms/InstCombine/vector-casts.ll
llvm/test/Transforms/LoopVectorize/invariant-store-vectorization-2.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-dominance.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-loops.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-multiple-blocks.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused.ll
llvm/test/Transforms/LowerMatrixIntrinsics/multiply-minimal.ll
llvm/test/Transforms/PhaseOrdering/X86/pr61061.ll
llvm/test/Transforms/PhaseOrdering/X86/scalarization.ll
llvm/test/Transforms/PhaseOrdering/X86/shuffle.ll
llvm/test/Transforms/SLPVectorizer/AMDGPU/add_sub_sat.ll
llvm/test/Transforms/SLPVectorizer/X86/alternate-calls.ll
llvm/test/Transforms/SLPVectorizer/X86/alternate-int.ll
llvm/test/Transforms/SLPVectorizer/X86/pr47629.ll
llvm/test/Transforms/SLPVectorizer/X86/pr47642.ll
llvm/test/Transforms/SLPVectorizer/X86/pr49081.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152658.530339.patch
Type: text/x-patch
Size: 445735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230611/973a6bf5/attachment-0001.bin>
More information about the cfe-commits
mailing list