Index: lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp =================================================================== --- lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -1352,7 +1352,8 @@ .add(getLdStRegOp(*I)) .add(getLdStBaseOp(*I)) .addImm(Value) - .setMemRefs(I->memoperands_begin(), I->memoperands_end()); + .setMemRefs(I->memoperands_begin(), I->memoperands_end()) + .setMIFlags(I->getFlags() | Update->getFlags()); } else { // Paired instruction. int Scale = getMemScale(*I); @@ -1362,7 +1363,8 @@ .add(getLdStRegOp(*I, 1)) .add(getLdStBaseOp(*I)) .addImm(Value / Scale) - .setMemRefs(I->memoperands_begin(), I->memoperands_end()); + .setMemRefs(I->memoperands_begin(), I->memoperands_end()) + .setMIFlags(I->getFlags() | Update->getFlags()); } (void)MIB; Index: test/CodeGen/AArch64/ldst-miflags.mir =================================================================== --- /dev/null +++ test/CodeGen/AArch64/ldst-miflags.mir @@ -0,0 +1,14 @@ +# RUN: llc -run-pass=aarch64-ldst-opt -o - -mtriple=aarch64-- %s | FileCheck %s +# +--- +name: foo +# CHECK-LABEL: name: foo +body: | + bb.0: + $x26, $x25 = frame-setup LDPXi $sp, 0 + $sp = frame-destroy ADDXri $sp, 64, 0 + + ; Check that we merge the MIFlags from both the instructions in the final + ; instruction. + ; CHECK: = frame-setup frame-destroy LDPXpost + RET_ReallyLR