[PATCH] D40320: [NFC] CodeGen: Handle shift amount type in DAGTypeLegalizer::SplitInteger

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 19:31:00 PST 2017


yaxunl added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp:1175
   Lo = DAG.getNode(ISD::TRUNCATE, dl, LoVT, Op);
-  Hi =
-      DAG.getNode(ISD::SRL, dl, Op.getValueType(), Op,
-                  DAG.getConstant(LoVT.getSizeInBits(), dl,
-                                  TLI.getScalarShiftAmountTy(
-                                      DAG.getDataLayout(), Op.getValueType())));
+  unsigned ReqShiftAmountInBits = Log2_32(LoVT.getSizeInBits()) + 1;
+  MVT ShiftAmountTy =
----------------
efriedma wrote:
> yaxunl wrote:
> > efriedma wrote:
> > > Log2_32_Ceil?
> > It is different. E.g, the number 32 requires 6 bits to hold, but Log2_32_Ceil(32) == 5.
> Sure, but "32" isn't a legal shift amount for an i32.
> 
> Oh, wait, I see, you're not using the type I expected.  I was expecting something like `Log2_32_Ceil(Op.getValueType().getSizeInBits())`. (I guess that's equivalent to what you wrote, but it's a bit more intuitive since `Op.getValueType()` is the type of the shift.)
Revised. Thanks.


https://reviews.llvm.org/D40320





More information about the llvm-commits mailing list