Fixes a nasty dag combiner bug that causes a bunch of tests to fail at -O0.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 16 Jan 2008 23:11:54 +0000 (23:11 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 16 Jan 2008 23:11:54 +0000 (23:11 +0000)
commit02c42856431562376ac8280b57ad744ba83f1e38
tree977321e4365b1af4e1e9bbecb15b1ee4ee8dc468
parent339e14fbdc9560cb58091d214c7d628f6dcf7c7d
Fixes a nasty dag combiner bug that causes a bunch of tests to fail at -O0.

It's not safe to use the two value CombineTo variant to combine away a dead load.
e.g.
v1, chain2 = load chain1, loc
v2, chain3 = load chain2, loc
v3         = add v2, c
Now we replace use of v1 with undef, use of chain2 with chain1.
ReplaceAllUsesWith() will iterate through uses of the first load and update operands:
v1, chain2 = load chain1, loc
v2, chain3 = load chain1, loc
v3         = add v2, c
Now the second load is the same as the first load, SelectionDAG cse will ensure
the use of second load is replaced with the first load.
v1, chain2 = load chain1, loc
v3         = add v1, c
Then v1 is replaced with undef and bad things happen.

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