OSDN Git Service

[x86] Fix PR22524: the DAG combiner was incorrectly handling illegal
authorChandler Carruth <chandlerc@gmail.com>
Tue, 10 Feb 2015 02:25:56 +0000 (02:25 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 10 Feb 2015 02:25:56 +0000 (02:25 +0000)
commit1c7c2e8650e6b5018f693b82d56028667c6a37e8
treebd4b25f3534d14ccdb4a2ef573500616a0ba8015
parent420047f37fc89fa51ed73f75b30ee13a24be654f
[x86] Fix PR22524: the DAG combiner was incorrectly handling illegal
nodes when folding bitcasts of constants.

We can't fold things and then check after-the-fact whether it was legal.
Once we have formed the DAG node, arbitrary other nodes may have been
collapsed to it. There is no easy way to go back. Instead, we need to
test for the specific folding cases we're interested in and ensure those
are legal first.

This could in theory make this less powerful for bitcasting from an
integer to some vector type, but AFAICT, that can't actually happen in
the SDAG so its fine. Now, we *only* whitelist specific int->fp and
fp->int bitcasts for post-legalization folding. I've added the test case
from the PR.

(Also as a note, this does not appear to be in 3.6, no backport needed)

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