This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Fix CSE handling of buildConstant
ClosedPublic

Authored by arsenm on Feb 3 2019, 6:56 AM.

Details

Summary

This fixes two problems with CSE done in buildConstant. First, this
would hit an assert when used with a vector result type. Solve this by
allowing CSE on the vector elements, but not on the result vector for
now.

Second, this was also performing the CSE based on the input
ConstantInt pointer. The underlying buildConstant could potentially
convert the constant depending on the result type, giving in a
different ConstantInt*. Stop allowing the APInt and ConstantInt forms
from automatically casting to the result type to avoid any similar
problems in the future.

Diff Detail

Event Timeline

arsenm created this revision.Feb 3 2019, 6:56 AM
arsenm updated this revision to Diff 184951.Feb 3 2019, 6:57 AM
aditya_nandakumar accepted this revision.Feb 4 2019, 7:10 AM

LGTM. Please move the EXPECT_EQ changes to the other commit.

include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
738

Should be Src and not Src0 here.

unittests/CodeGen/GlobalISel/CSETest.cpp
33

Please make the EXPECT_EQ changes along with https://reviews.llvm.org/D57652

This revision is now accepted and ready to land.Feb 4 2019, 7:10 AM
arsenm closed this revision.Feb 4 2019, 11:16 AM
arsenm marked an inline comment as done.

r353077