[SelectionDAG] Don't remove unused negated constant immediately
authorQiu Chaofan <qiucofan@cn.ibm.com>
Mon, 5 Oct 2020 16:45:24 +0000 (00:45 +0800)
committerQiu Chaofan <qiucofan@cn.ibm.com>
Mon, 5 Oct 2020 17:16:45 +0000 (01:16 +0800)
commitb326d4ff946d2061a566a3fcce9f33b484759fe0
tree9182490bd8b9bb08d70baa8fbb7f7f5d1ddfbda4
parent4ce61144cb49b48817f0215820173005c8d7d816
[SelectionDAG] Don't remove unused negated constant immediately

This reverts partial of a2fb5446 (actually, 2508ef01) about removing
negated FP constant immediately if it has no uses. However, as discussed
in bug 47517, there're cases when NegX is folded into constant from
other places while NegY is removed by that line of code and NegX is
equal to NegY. In these cases, NegX is deleted before used and crash
happens. So revert the code and add necessary test case.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/pr47517.ll