This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Correct constant type in matchReassocConstantInnerLHS
ClosedPublic

Authored by bcl5980 on Nov 10 2022, 3:33 AM.

Details

Summary

When we match a pattern from m_GCst, the register type could be different from original op. So we can't replace the original op to vreg direct.
This code create a new constant with original op type then replace the original op.

Fix #58906

Diff Detail

Event Timeline

bcl5980 created this revision.Nov 10 2022, 3:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2022, 3:33 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bcl5980 requested review of this revision.Nov 10 2022, 3:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2022, 3:33 AM
arsenm added inline comments.Nov 10 2022, 8:56 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
4552–4561

If you're going to potentially create a new constant anyway, can you just create the constant and get rid of all this moveBefore stuff?

arsenm added inline comments.Nov 10 2022, 9:03 AM
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-ptradd-chain.mir
16

Should precommit the tests changes that change all the CHECK to CHECK-NEXT so the diff is readable

arsenm added inline comments.Nov 10 2022, 9:06 AM
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-ptradd-chain.mir
16
bcl5980 updated this revision to Diff 474585.Nov 10 2022, 12:03 PM

Address comments.

arsenm accepted this revision.Nov 10 2022, 1:35 PM
This revision is now accepted and ready to land.Nov 10 2022, 1:35 PM
arsenm added inline comments.Nov 10 2022, 1:36 PM
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-ptradd-chain.mir
109

Can you add a reference to the issue number here

bcl5980 updated this revision to Diff 474651.Nov 10 2022, 8:06 PM
arsenm accepted this revision.Nov 10 2022, 8:06 PM
bcl5980 added inline comments.Nov 10 2022, 8:07 PM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
4552–4561

It looks we can't remove the moveBefore. Test failed on CodeGen/AMDGPU/GlobalISel/mubuf-global.ll.

arsenm added inline comments.Nov 10 2022, 8:34 PM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
4552–4561

By failed do you mean actually broken, or just needs updating?

bcl5980 marked an inline comment as done.Nov 10 2022, 8:36 PM
bcl5980 added inline comments.
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
4552–4561

Actually broken.

Use of %10 does not have a corresponding definition on every path:
64r %31:vgpr_32, %33:sreg_64_xexec = V_ADD_CO_U32_e64 %3:vgpr_32, %10.sub0:vreg_64, 0, implicit $exec
LLVM ERROR: Use not jointly dominated by defs.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: build\\bin\\llc -global-isel -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti

  1. Running pass 'CallGraph Pass Manager' on module '<stdin>'.
  2. Running pass 'Live Interval Analysis' on function '@mubuf_store_vgpr_ptr_sgpr_offset256_offset'

@arsenm How about this patch now ?

aemerson accepted this revision.Nov 12 2022, 11:29 PM

LGTM, thanks!

This revision was landed with ongoing or failed builds.Nov 13 2022, 3:20 AM
This revision was automatically updated to reflect the committed changes.