[PATCH] D134953: [AMDGPU][GISel] Add Identity BUILD_VECTOR Combines
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 05:31:00 PDT 2022
arsenm added inline comments.
================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCombine.td:48-52
+def buildvector_identity_fold : GICombineRule<
+ (defs root:$build_vector, register_matchinfo:$matchinfo),
+ (match (wip_match_opcode G_BUILD_VECTOR_TRUNC, G_BUILD_VECTOR):$build_vector,
+ [{ return PostLegalizerHelper.matchBuildVectorIdentityFold(*${build_vector}, ${matchinfo}); }]),
+ (apply [{ Helper.replaceSingleDefInstWithReg(*${build_vector}, ${matchinfo}); }])>;
----------------
Can move this to the generic combiner
================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp:333
+ m_GBuildVector(m_GTrunc(m_GBitcast(m_Reg(Lo))), m_Reg(Hi)))) {
+ if (getDefIgnoringCopies(Hi, MRI)->getOpcode() == AMDGPU::G_IMPLICIT_DEF) {
+ MatchInfo = Lo;
----------------
Shouldn't need to bother with getDefIgnoringCopies, copy of copy is folded out during combining. We should have an m_Undef or m_ImplicitDef too if there isn't one already
================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.load.1d.d16.ll:947-949
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GFX10: {{.*}}
+; GFX11: {{.*}}
----------------
Should remove this and remove the unused prefixes
================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/postlegalizer-combiner-buildvector-identities.mir:2
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs -o - %s | FileCheck %s
+
----------------
Don't need -global-isel with -run-pass
================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/postlegalizer-combiner-trunc-bitcast-buildvector.mir:2
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs -o - %s | FileCheck %s
+
----------------
Don't need -global-isel with -run-pass
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134953/new/
https://reviews.llvm.org/D134953
More information about the llvm-commits
mailing list