This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Support vectors in SimplifyAddWithRemainder.
ClosedPublic

Authored by fhahn on Mar 10 2020, 4:27 AM.

Details

Summary

SimplifyAddWithRemainder currently also matches for vector types, but
tries to create an integer constant, which causes a crash.

By using Constant::getIntegerValue() we can support both the scalar and
vector cases.

The 2 added test cases crash without the fix.

Diff Detail

Event Timeline

fhahn created this revision.Mar 10 2020, 4:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2020, 4:27 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
lebedev.ri added inline comments.Mar 10 2020, 4:37 AM
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
1047

I think you want ConstantInt::get(X->getType(), C0 * C1)

fhahn updated this revision to Diff 249341.Mar 10 2020, 5:53 AM

Fix clang-format error

fhahn updated this revision to Diff 249343.Mar 10 2020, 5:57 AM

use ConstantInt::get().

fhahn marked an inline comment as done.Mar 10 2020, 5:58 AM
fhahn added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
1047

I think they should do the same thing. ConstantInt::get() is a bit shorter though, I've updated the code.

This revision is now accepted and ready to land.Mar 10 2020, 6:30 AM
spatel accepted this revision.Mar 10 2020, 7:02 AM

LGTM, but you'll need to rebase the test diffs because I regenerated the test file to avoid a bug in utils/update_test_checks.py:
rG6e60e1025f32

This revision was automatically updated to reflect the committed changes.