diff options
| author | Diana Picus <diana.picus@linaro.org> | 2019-03-28 09:09:36 +0000 |
|---|---|---|
| committer | Diana Picus <diana.picus@linaro.org> | 2019-03-28 09:09:36 +0000 |
| commit | 52495c472ff876e58809557bc0baa7ec8490751d (patch) | |
| tree | a778df7eb1447bc822c346948eaadab819f0e4d1 /llvm/lib | |
| parent | 4d512df30035c54a81b2e67d80debbc09b003afb (diff) | |
| download | bcm5719-llvm-52495c472ff876e58809557bc0baa7ec8490751d.tar.gz bcm5719-llvm-52495c472ff876e58809557bc0baa7ec8490751d.zip | |
[ARM GlobalISel] Fix G_STORE with s1
G_STORE for 1-bit values uses a STRBi12, which stores the whole byte.
Zero out the undefined bits before writing.
llvm-svn: 357154
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstructionSelector.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp index d0b63d676da..6df74eca6ea 100644 --- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp +++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp @@ -1048,6 +1048,24 @@ bool ARMInstructionSelector::select(MachineInstr &I, if (NewOpc == G_LOAD || NewOpc == G_STORE) return false; + if (ValSize == 1 && NewOpc == Opcodes.STORE8) { + // Before storing a 1-bit value, make sure to clear out any unneeded bits. + unsigned OriginalValue = I.getOperand(0).getReg(); + + unsigned ValueToStore = MRI.createVirtualRegister(&ARM::GPRRegClass); + I.getOperand(0).setReg(ValueToStore); + + auto InsertBefore = I.getIterator(); + auto AndI = BuildMI(MBB, InsertBefore, I.getDebugLoc(), TII.get(Opcodes.AND)) + .addDef(ValueToStore) + .addUse(OriginalValue) + .addImm(1) + .add(predOps(ARMCC::AL)) + .add(condCodeOp()); + if (!constrainSelectedInstRegOperands(*AndI, TII, TRI, RBI)) + return false; + } + I.setDesc(TII.get(NewOpc)); if (NewOpc == ARM::LDRH || NewOpc == ARM::STRH) |

