1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 13:11:39 +01:00

Fix PR40644: miscompile indexed FP constant store

Summary:
Functions replaceStoreOfFPConstant() and OptimizeFloatStore() both
replace store of float by a store of an integer unconditionally. However
this generates wrong code when the store that is replaced is an indexed
or truncating store. This commit solves this issue by adding an early
return in these functions when the store being considered is not a
normal store.

Bug was only observed on out of tree targets, hence the lack of testcase
in this commit.

Reviewers: efriedma

Subscribers: hiraditya, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68420
This commit is contained in:
Thomas Preud'homme 2019-10-03 17:00:37 +01:00
parent eebf5e9394
commit 857bdbdda2
2 changed files with 6 additions and 0 deletions

View File

@ -16065,6 +16065,9 @@ SDValue DAGCombiner::replaceStoreOfFPConstant(StoreSDNode *ST) {
if (Value.getOpcode() == ISD::TargetConstantFP) if (Value.getOpcode() == ISD::TargetConstantFP)
return SDValue(); return SDValue();
if (!ISD::isNormalStore(ST))
return SDValue();
SDLoc DL(ST); SDLoc DL(ST);
SDValue Chain = ST->getChain(); SDValue Chain = ST->getChain();

View File

@ -421,6 +421,9 @@ SDValue SelectionDAGLegalize::ExpandINSERT_VECTOR_ELT(SDValue Vec, SDValue Val,
} }
SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) { SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
if (!ISD::isNormalStore(ST))
return SDValue();
LLVM_DEBUG(dbgs() << "Optimizing float store operations\n"); LLVM_DEBUG(dbgs() << "Optimizing float store operations\n");
// Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr' // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
// FIXME: We shouldn't do this for TargetConstantFP's. // FIXME: We shouldn't do this for TargetConstantFP's.