This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] Fix v1i8 -> 1x i32 handling in getCopyToPartsVector
AbandonedPublic

Authored by Pierre-vh on Oct 27 2022, 2:40 AM.

Details

Summary

Previously it could generate things like:

t4: i32 = extract_vector_elt t10, Constant:i32<0>

Because the code path for 1 element vectors didn't check if an extension/trunc was needed.

Diff Detail

Event Timeline

Pierre-vh created this revision.Oct 27 2022, 2:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 2:40 AM
Pierre-vh requested review of this revision.Oct 27 2022, 2:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 2:40 AM
arsenm added inline comments.Oct 27 2022, 7:08 AM
llvm/test/CodeGen/AMDGPU/dagcombine-v1i8-extractvecelt-crash.ll
41

Is this store of poison really doing anything here?

Pierre-vh added inline comments.Oct 27 2022, 7:20 AM
llvm/test/CodeGen/AMDGPU/dagcombine-v1i8-extractvecelt-crash.ll
41

Both the stores & the loop are needed somehow, removing either makes the bug disappear - I think it simplifies everything away in those cases

arsenm added inline comments.Oct 27 2022, 7:35 AM
llvm/test/CodeGen/AMDGPU/dagcombine-v1i8-extractvecelt-crash.ll
41

I think some IR code motion is happening before that. What you really need is a value with <1 x i8> live across blocks. The final assembly hoisted the load, and only has one of the stores. Can you pre-make those changes for the original IR? The tests in amdgcn.bitcast have a bit more code to ensure we hit this path

arsenm added inline comments.Oct 27 2022, 7:37 AM
llvm/test/CodeGen/AMDGPU/dagcombine-v1i8-extractvecelt-crash.ll
10

What exactly broke? Technically the return type is allowed to be a wider element than the original source vector (don't think trunc is legal though)

Pierre-vh added inline comments.Oct 27 2022, 7:47 AM
llvm/test/CodeGen/AMDGPU/dagcombine-v1i8-extractvecelt-crash.ll
10

Ah then maybe the right change is to fix that place where trunc is used directly instead of getAnyExtOrTrunc?

Pierre-vh abandoned this revision.Oct 27 2022, 7:53 AM

Not the right fix