This is an archive of the discontinued LLVM Phabricator instance.

Fix signedness in vector bitcast evaluation
ClosedPublic

Authored by svenvh on Jan 21 2021, 7:14 AM.

Details

Summary

The included test case triggered a sign assertion on the result in
Success(). This was caused by the APSInt created for a bitcast
having its signedness bit inverted. The second APSInt constructor
argument is isUnsigned, so invert the result of
isSignedIntegerType.

Diff Detail

Event Timeline

svenvh requested review of this revision.Jan 21 2021, 7:14 AM
svenvh created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2021, 7:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Anastasia accepted this revision.Jan 21 2021, 7:35 AM

LGTM, great! Thanks! Perhaps the test can be simplified before committing...

clang/test/CodeGenOpenCL/vector_literals.cl
71

I wonder if both (int2) are needed i.e. the cast one could be ommitted?

This revision is now accepted and ready to land.Jan 21 2021, 7:35 AM
svenvh added inline comments.Jan 21 2021, 7:40 AM
clang/test/CodeGenOpenCL/vector_literals.cl
71

The cast is actually necessary, because the fix is in the code that handles the cast (case CK_BitCast if you expand the code above my change).

This revision was automatically updated to reflect the committed changes.