This is an archive of the discontinued LLVM Phabricator instance.

[X86] Return UNDEF from LowerScalarImmediateShift when the shift amount is out of range.
ClosedPublic

Authored by craig.topper on Jul 13 2019, 6:12 PM.

Details

Summary

I think we only turn out of range shiftss to undef when
all elements are out of range or the shift amount is a splat out
of range. I'm not sure which, I didn't check.

During lowering we can split a shift where some elements
are out of range into multiple shifts. This can create a
new shift with a splat shift amount that is out of range.

This patch returns undef for this case.

Fixes PR42615.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 13 2019, 6:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2019, 6:12 PM
Herald added a subscriber: hiraditya. · View Herald Transcript

This is only ever coming from ISD::SHL/SRL/SRA so returning UNDEF should be fine.

Alternatively if we wanted to match the sse behaviour, then we'd keep the clamp for SRA and return 0 for SHL/SRL cases.

Overall I think I prefer the UNDEF route tbh.

Switch to returning undef

craig.topper retitled this revision from [X86] Use getLimitedValue to clamp and out of range shift amount instead of asserting. to [X86] Return UNDEF from LowerScalarImmediateShift when the shift amount is out of range..Jul 14 2019, 9:51 PM
craig.topper edited the summary of this revision. (Show Details)
RKSimon accepted this revision.Jul 15 2019, 1:10 AM

LGTM

This revision is now accepted and ready to land.Jul 15 2019, 1:10 AM
This revision was automatically updated to reflect the committed changes.