This is an archive of the discontinued LLVM Phabricator instance.

[DAG] replaceStoreOfInsertLoad - don't fold if the inserted element is implicity truncated
ClosedPublic

Authored by RKSimon on Aug 20 2023, 7:49 AM.

Details

Summary

D152276 wasn't handling the case where the inserted element is implicity truncated into the vector - resulting in a i1 element (implictly truncated from i8) overwriting 8 bits instead of 1 bit.

This patch is intended to be merged into 17.x so I've just disallowed any vector element vs inserted element type mismatch - technically we could be more elegant and permit truncated stores (as long as the store is still byte sized), but the use cases for that are so limited I'd prefer to play it safe for now.

Candidate patch for #64655 17.x merge

Diff Detail

Event Timeline

RKSimon created this revision.Aug 20 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2023, 7:49 AM
RKSimon requested review of this revision.Aug 20 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2023, 7:49 AM
RKSimon planned changes to this revision.Aug 20 2023, 7:58 AM
jacobly added inline comments.Aug 20 2023, 8:05 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
20514

EltVT is the scalar type being inserted, but operand 0 is the vector being inserted into, so these types can never be equal. Maybe EltVT != Value.getOperand(0).getValueType().getVectorElementType()?

RKSimon updated this revision to Diff 551839.Aug 20 2023, 8:06 AM

fix dumb typo

RKSimon marked an inline comment as done.Aug 20 2023, 8:16 AM
RKSimon added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
20514

Sorry about that :)

luke accepted this revision.Aug 20 2023, 9:43 AM

LGTM, +1 on being conservative for now

This revision is now accepted and ready to land.Aug 20 2023, 9:43 AM
This revision was automatically updated to reflect the committed changes.
RKSimon marked an inline comment as done.