[PATCH] D32240: InstCombineCast AShr transformation
David Majnemer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 12:49:21 PDT 2017
majnemer added a comment.
This needs a testcase.
================
Comment at: InstCombineCasts.cpp:1258-1262
+ // %shr26 = lshr i32 %0, 16 ; [#uses=1 type=i32]
+ // %conv4 = trunc i32 %shr26 to i16 ; [#uses=1 type=i16]
+ // %3 = sext i16 %conv4 to i32 ; [#uses=N type=i32]
+ // To:
+ // %3 = ashr i32 %0, 16
----------------
Please use more regular register names and elide the commends.
================
Comment at: InstCombineCasts.cpp:1263
+ // %3 = ashr i32 %0, 16
+ if (match(Src, m_OneUse(m_Trunc( m_OneUse(m_LShr(m_Value(A), m_ConstantInt(BA)))))) &&
+ A->getType() == CI.getType()) {
----------------
I'd recommend using m_APInt so that it will match against vectors.
================
Comment at: InstCombineCasts.cpp:1267
+ unsigned TruncSize = Src->getType()->getScalarSizeInBits();
+ if (BA->getZExtValue() == SextSize - TruncSize)
+ return BinaryOperator::CreateAShr(A, BA);
----------------
This will explode if the ConstantInt is bigger than an i64
Repository:
rL LLVM
https://reviews.llvm.org/D32240
More information about the llvm-commits
mailing list