[X86/Atomics] Correct a few transforms for new atomic lowering

This is a partial fix for the issues described in commit message of 027aa27 (the revert of G24609).  Unfortunately, I can't provide test coverage for it on it's own as the only (known) wrong example is still wrong, but due to a separate issue.

These fixes are cases where when performing unrelated DAG combines, we were dropping the atomicity flags entirely.
This commit is contained in:
Philip Reames 2019-11-05 13:17:01 -08:00
parent ee10d934dd
commit db036ee0a4
1 changed files with 3 additions and 4 deletions

View File

@ -14116,7 +14116,7 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
return V; return V;
// Try to infer better alignment information than the load already has. // Try to infer better alignment information than the load already has.
if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) { if (OptLevel != CodeGenOpt::None && LD->isUnindexed() && !LD->isAtomic()) {
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
if (Align > LD->getAlignment() && LD->getSrcValueOffset() % Align == 0) { if (Align > LD->getAlignment() && LD->getSrcValueOffset() % Align == 0) {
SDValue NewLoad = DAG.getExtLoad( SDValue NewLoad = DAG.getExtLoad(
@ -16164,8 +16164,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
TLI.isStoreBitCastBeneficial(Value.getValueType(), SVT, TLI.isStoreBitCastBeneficial(Value.getValueType(), SVT,
DAG, *ST->getMemOperand())) { DAG, *ST->getMemOperand())) {
return DAG.getStore(Chain, SDLoc(N), Value.getOperand(0), Ptr, return DAG.getStore(Chain, SDLoc(N), Value.getOperand(0), Ptr,
ST->getPointerInfo(), ST->getAlignment(), ST->getMemOperand());
ST->getMemOperand()->getFlags(), ST->getAAInfo());
} }
} }
@ -16174,7 +16173,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
return Chain; return Chain;
// Try to infer better alignment information than the store already has. // Try to infer better alignment information than the store already has.
if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { if (OptLevel != CodeGenOpt::None && ST->isUnindexed() && !ST->isAtomic()) {
if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
if (Align > ST->getAlignment() && ST->getSrcValueOffset() % Align == 0) { if (Align > ST->getAlignment() && ST->getSrcValueOffset() % Align == 0) {
SDValue NewStore = SDValue NewStore =