Skip to content

Commit 646896a

Browse files
author
Thomas Preud'homme
committed
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
1 parent cf581d7 commit 646896a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16065,6 +16065,9 @@ SDValue DAGCombiner::replaceStoreOfFPConstant(StoreSDNode *ST) {
1606516065
if (Value.getOpcode() == ISD::TargetConstantFP)
1606616066
return SDValue();
1606716067

16068+
if (!ISD::isNormalStore(ST))
16069+
return SDValue();
16070+
1606816071
SDLoc DL(ST);
1606916072

1607016073
SDValue Chain = ST->getChain();

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ SDValue SelectionDAGLegalize::ExpandINSERT_VECTOR_ELT(SDValue Vec, SDValue Val,
421421
}
422422

423423
SDValue SelectionDAGLegalize::OptimizeFloatStore(StoreSDNode* ST) {
424+
if (!ISD::isNormalStore(ST))
425+
return SDValue();
426+
424427
LLVM_DEBUG(dbgs() << "Optimizing float store operations\n");
425428
// Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
426429
// FIXME: We shouldn't do this for TargetConstantFP's.

0 commit comments

Comments
 (0)