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

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 15:34:55 PDT 2018


aditya_nandakumar accepted this revision.
aditya_nandakumar added inline comments.
This revision is now accepted and ready to land.


================
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));
----------------
rtereshin wrote:
> 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.
Thanks. I hadn't seen the implementation of buildConstant.

Should be good.


Repository:
  rL LLVM

https://reviews.llvm.org/D46414





More information about the llvm-commits mailing list