This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Check if ShiftAmt is greater then size of operand
ClosedPublic

Authored by Acim-Maravic on May 22 2023, 10:09 AM.

Details

Summary

matchCombineShlOfExtend did not check if the size of new shift would be
wider then a size of operand. Current condition did not work if the value
being shifted was zero. Updated to support vector splat.

Diff Detail

Event Timeline

Acim-Maravic created this revision.May 22 2023, 10:09 AM
Acim-Maravic requested review of this revision.May 22 2023, 10:09 AM
arsenm added inline comments.May 22 2023, 1:16 PM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
1747–1748

Broken for vectors, getScalarSizeInBits

llvm/test/CodeGen/AMDGPU/GlobalISel/combine-shl-from-extend-narrow.postlegal.mir
332

Add a vector version. Also would be good to have one that couldn't be trivially constant folded

Acim-Maravic edited the summary of this revision. (Show Details)
  • added new tests with vector types
  • updated to support vector splat
arsenm accepted this revision.Jun 6 2023, 1:58 PM
arsenm added inline comments.
llvm/test/CodeGen/AMDGPU/GlobalISel/sext_inreg.ll
968–971 ↗(On Diff #525220)

This looks like it was broken before but is differently broken now

1001 ↗(On Diff #525220)

Ah, this test should be using ashr not shl

This revision is now accepted and ready to land.Jun 6 2023, 1:58 PM
arsenm added inline comments.Jun 6 2023, 2:07 PM
llvm/test/CodeGen/AMDGPU/GlobalISel/sext_inreg.ll
1001 ↗(On Diff #525220)

I've fixed the test so you may need to regenerate this