[PATCH] D46414: [GlobalISel][Legalizer] More concise and faster widenScalar, NFC

Roman Tereshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 14:31:23 PDT 2018


rtereshin marked an inline comment as done.
rtereshin added inline comments.


================
Comment at: lib/CodeGen/GlobalISel/LegalizerHelper.cpp:730
+    LLVMContext &Ctx = MIRBuilder.getMF().getFunction().getContext();
+    const APInt &Val = SrcMO.getCImm()->getValue().sext(WideTy.getSizeInBits());
+    SrcMO.setCImm(ConstantInt::get(Ctx, Val));
----------------
aditya_nandakumar wrote:
> This bit looks like it's not NFC (but seems more correct). If it's indeed not NFC, then please push this in a separate commit.
I believe it is an NFC, take a look at the `MachineIRBuilder::buildConstant` that was here before: https://github.com/llvm-mirror/llvm/blob/0cb4ac08f0b0388854df5ff419fc56c5e63361dc/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp#L243

`sextOrTrunc` will always resolve to `sext` there as the new type is always larger, it's a `widenScalar` after all.

Also, I have recently committed a `MachineVerifier` patch that checks that we don't have extends down or truncates up: https://reviews.llvm.org/rL331718 Hopefully that helps a bit.


Repository:
  rL LLVM

https://reviews.llvm.org/D46414





More information about the llvm-commits mailing list