[llvm] r354867 - [LegalizeDAG] Use APInt::getSplat helper to create bitreverse masks. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 03:44:23 PST 2019
Author: rksimon
Date: Tue Feb 26 03:44:23 2019
New Revision: 354867
URL: http://llvm.org/viewvc/llvm-project?rev=354867&view=rev
Log:
[LegalizeDAG] Use APInt::getSplat helper to create bitreverse masks. NFCI.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=354867&r1=354866&r2=354867&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Feb 26 03:44:23 2019
@@ -2493,16 +2493,12 @@ SDValue SelectionDAGLegalize::ExpandBITR
// TODO: We can easily support i4/i2 legal types if any target ever does.
if (Sz >= 8 && isPowerOf2_32(Sz)) {
// Create the masks - repeating the pattern every byte.
- APInt MaskHi4(Sz, 0), MaskHi2(Sz, 0), MaskHi1(Sz, 0);
- APInt MaskLo4(Sz, 0), MaskLo2(Sz, 0), MaskLo1(Sz, 0);
- for (unsigned J = 0; J != Sz; J += 8) {
- MaskHi4 = MaskHi4 | (0xF0ull << J);
- MaskLo4 = MaskLo4 | (0x0Full << J);
- MaskHi2 = MaskHi2 | (0xCCull << J);
- MaskLo2 = MaskLo2 | (0x33ull << J);
- MaskHi1 = MaskHi1 | (0xAAull << J);
- MaskLo1 = MaskLo1 | (0x55ull << J);
- }
+ APInt MaskHi4 = APInt::getSplat(Sz, APInt(8, 0xF0));
+ APInt MaskHi2 = APInt::getSplat(Sz, APInt(8, 0xCC));
+ APInt MaskHi1 = APInt::getSplat(Sz, APInt(8, 0xAA));
+ APInt MaskLo4 = APInt::getSplat(Sz, APInt(8, 0x0F));
+ APInt MaskLo2 = APInt::getSplat(Sz, APInt(8, 0x33));
+ APInt MaskLo1 = APInt::getSplat(Sz, APInt(8, 0x55));
// BSWAP if the type is wider than a single byte.
Tmp = (Sz > 8 ? DAG.getNode(ISD::BSWAP, dl, VT, Op) : Op);
More information about the llvm-commits
mailing list