[PATCH] D69034: [Alignment][NFC] Use Align for TFI.getStackAlignment() in X86ISelLowering
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 07:01:52 PDT 2019
courbet requested changes to this revision.
courbet added inline comments.
This revision now requires changes to proceed.
================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:4186
unsigned
-X86TargetLowering::GetAlignedArgumentStackSize(unsigned StackSize,
- SelectionDAG& DAG) const {
- const X86RegisterInfo *RegInfo = Subtarget.getRegisterInfo();
- const TargetFrameLowering &TFI = *Subtarget.getFrameLowering();
- unsigned StackAlignment = TFI.getStackAlignment();
- uint64_t AlignMask = StackAlignment - 1;
- int64_t Offset = StackSize;
- unsigned SlotSize = RegInfo->getSlotSize();
- if ( (Offset & AlignMask) <= (StackAlignment - SlotSize) ) {
- // Number smaller than 12 so just add the difference.
- Offset += ((StackAlignment - SlotSize) - (Offset & AlignMask));
- } else {
- // Mask out lower bits, add stackalignment once plus the 12 bytes.
- Offset = ((~AlignMask) & Offset) + StackAlignment +
- (StackAlignment-SlotSize);
- }
- return Offset;
+X86TargetLowering::GetAlignedArgumentStackSize(const unsigned StackSize,
+ SelectionDAG &DAG) const {
----------------
This is not the same as the previous code for all values: https://godbolt.org/z/QTxj9U
Could you at least add an assert if you don;t intend to cover the same range of inputs ?
================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:22218
SP = DAG.getNode(ISD::AND, dl, VT, SP.getValue(0),
- DAG.getConstant(-(uint64_t)Align, dl, VT));
+ DAG.getConstant(~(Alignment->value() - 1ULL), dl, VT));
Chain = DAG.getCopyToReg(Chain, dl, SPReg, SP);
----------------
Let's refactor this in `Align` (in a separate patch).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69034/new/
https://reviews.llvm.org/D69034
More information about the llvm-commits
mailing list