This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Remove assertion/range check for i16 values during immediate selection
ClosedPublic

Authored by mnadeem on Aug 10 2021, 11:11 PM.

Details

Summary

This assertion fails when an i16 constant is promoted to i32.
Example: https://godbolt.org/z/rxo649jEo

The value i16 -32768 is within the range of i16 but is promoted to
positive i32 32768 by an earlier call to DAG.getConstant().

Another option would be to modify the assert to:

assert((ImmVal >= -32768) && (ImmVal <= 65535));

not sure if this is any better.

Diff Detail

Event Timeline

mnadeem created this revision.Aug 10 2021, 11:11 PM
mnadeem requested review of this revision.Aug 10 2021, 11:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2021, 11:11 PM
Matt added a subscriber: Matt.Aug 11 2021, 9:05 AM
mnadeem updated this revision to Diff 365842.Aug 11 2021, 1:39 PM

Added a test.

efriedma accepted this revision.Aug 11 2021, 1:57 PM

LGTM with one minor change.

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
3154–3155

I think the way lowering currently works, we currently don't have any guarantee at all about what the high bits of ImmVal contain; this follows from the definition of SPLAT_VECTOR. So probably we should be explicitly masking off the high bits. I doubt that has any practical effect here, though; just deleting the assertion is probably good enough.

llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll
806

Please stick this next to the other tests in llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll .

This revision is now accepted and ready to land.Aug 11 2021, 1:57 PM
mnadeem added inline comments.Aug 11 2021, 2:14 PM
llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll
806

Looks like tests in that file explicitly call the sve intrinsics while this test does not.
There are similar min/max tests above so I think it will be okay here, or should I move it?

efriedma added inline comments.Aug 11 2021, 2:41 PM
llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll
806

Oh, hmm....

I guess it's fine here, then.