AMDGPU: Consistently check for immediates in SIInstrInfo::FoldImmediate
authorNicolai Haehnle <nhaehnle@gmail.com>
Tue, 28 Nov 2017 08:41:50 +0000 (08:41 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Tue, 28 Nov 2017 08:41:50 +0000 (08:41 +0000)
commit39980dac0b1724cea2a64a2ee76ce35df6dbf0b6
tree4198b5d61f222332bbee9588cbd95b22e3ff77d7
parenta46522f369ca9a84127293ed07ca955c1b155782
AMDGPU: Consistently check for immediates in SIInstrInfo::FoldImmediate

Summary:
The PeepholeOptimizer pass calls this function solely based on checking
DefMI->isMoveImmediate(), which only checks the MoveImm bit of the
instruction description. So it's up to FoldImmediate itself to properly
check that DefMI *actually* moves from an immediate.

I don't have a separate test case for this, but the next patch introduces
a test case which happens to crash without this change.

This error is caught by the assertion in MachineOperand::getImm().

Change-Id: I88e7cdbcf54d75e1a296822e6fe5f9a5f095bbf8

Reviewers: arsenm, rampitec

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits

Differential Revision: https://reviews.llvm.org/D40342

llvm-svn: 319155
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp