[PATCH] D95681: [GlobalISel] Fix modifying a G_OR without notifying the observer
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 08:34:44 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5cf6412a2789: [GlobalISel] Fix modifying a G_OR without notifying the observer (authored by foad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95681/new/
https://reviews.llvm.org/D95681
Files:
llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -5479,31 +5479,27 @@
auto NotSignBitMask = MIRBuilder.buildConstant(
Src0Ty, APInt::getLowBitsSet(Src0Size, Src0Size - 1));
- auto And0 = MIRBuilder.buildAnd(Src0Ty, Src0, NotSignBitMask);
- MachineInstr *Or;
-
+ Register And0 = MIRBuilder.buildAnd(Src0Ty, Src0, NotSignBitMask).getReg(0);
+ Register And1;
if (Src0Ty == Src1Ty) {
- auto And1 = MIRBuilder.buildAnd(Src1Ty, Src1, SignBitMask);
- Or = MIRBuilder.buildOr(Dst, And0, And1);
+ And1 = MIRBuilder.buildAnd(Src1Ty, Src1, SignBitMask).getReg(0);
} else if (Src0Size > Src1Size) {
auto ShiftAmt = MIRBuilder.buildConstant(Src0Ty, Src0Size - Src1Size);
auto Zext = MIRBuilder.buildZExt(Src0Ty, Src1);
auto Shift = MIRBuilder.buildShl(Src0Ty, Zext, ShiftAmt);
- auto And1 = MIRBuilder.buildAnd(Src0Ty, Shift, SignBitMask);
- Or = MIRBuilder.buildOr(Dst, And0, And1);
+ And1 = MIRBuilder.buildAnd(Src0Ty, Shift, SignBitMask).getReg(0);
} else {
auto ShiftAmt = MIRBuilder.buildConstant(Src1Ty, Src1Size - Src0Size);
auto Shift = MIRBuilder.buildLShr(Src1Ty, Src1, ShiftAmt);
auto Trunc = MIRBuilder.buildTrunc(Src0Ty, Shift);
- auto And1 = MIRBuilder.buildAnd(Src0Ty, Trunc, SignBitMask);
- Or = MIRBuilder.buildOr(Dst, And0, And1);
+ And1 = MIRBuilder.buildAnd(Src0Ty, Trunc, SignBitMask).getReg(0);
}
// Be careful about setting nsz/nnan/ninf on every instruction, since the
// constants are a nan and -0.0, but the final result should preserve
// everything.
- if (unsigned Flags = MI.getFlags())
- Or->setFlags(Flags);
+ unsigned Flags = MI.getFlags();
+ MIRBuilder.buildOr(Dst, And0, And1, Flags);
MI.eraseFromParent();
return Legalized;
Index: llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
+++ llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
@@ -1507,8 +1507,9 @@
///
/// \return a MachineInstrBuilder for the newly created instruction.
MachineInstrBuilder buildOr(const DstOp &Dst, const SrcOp &Src0,
- const SrcOp &Src1) {
- return buildInstr(TargetOpcode::G_OR, {Dst}, {Src0, Src1});
+ const SrcOp &Src1,
+ Optional<unsigned> Flags = None) {
+ return buildInstr(TargetOpcode::G_OR, {Dst}, {Src0, Src1}, Flags);
}
/// Build and insert \p Res = G_XOR \p Op0, \p Op1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95681.320146.patch
Type: text/x-patch
Size: 2721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210129/bfde6b11/attachment.bin>
More information about the llvm-commits
mailing list