GlobalISel: Fix CSE handling of buildConstant
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 4 Feb 2019 19:15:50 +0000 (19:15 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 4 Feb 2019 19:15:50 +0000 (19:15 +0000)
commit8121ec26c0be6fbcdbd30e35dacefe4f5d7c1e65
treef393c6c8ca48095b6331f9b4da6f0ddf8b51db1e
parenta1cc4ea7bb1a527917f4be87475e5931d034a4ca
GlobalISel: Fix CSE handling of buildConstant

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.

llvm-svn: 353077
llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
llvm/unittests/CodeGen/GlobalISel/CSETest.cpp
llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp