Fix llc crash processing S/UREM for -Oz builds caused by rL250825.
authorSteve King <steve@metrokings.com>
Tue, 27 Oct 2015 00:14:06 +0000 (00:14 +0000)
committerSteve King <steve@metrokings.com>
Tue, 27 Oct 2015 00:14:06 +0000 (00:14 +0000)
commit6f257342a1d02b0a8b7a03d5d7c40ad21c20af4f
tree4111f0c33c787f21274e4e0c0f02d070d136acf0
parent145c90b4683c0fa2afdfd57191275e814101605b
Fix llc crash processing S/UREM for -Oz builds caused by rL250825.

When taking the remainder of a value divided by a constant, visitREM()
attempts to convert the REM to a longer but faster sequence of instructions.
This conversion calls combine() on a speculative DIV instruction. Commit
rL250825 may cause this combine() to return a DIVREM, corrupting nearby nodes.
Flow eventually hits unreachable().

This patch adds a test case and a check to prevent visitREM() from trying
to convert the REM instruction in cases where a DIVREM is possible.
See http://reviews.llvm.org/D14035

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251373 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/rem_crash.ll [new file with mode: 0644]