[PATCH] D32240: InstCombineCast AShr transformation
Mark Schimmel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 14:54:32 PDT 2017
marksl updated this revision to Diff 95826.
Repository:
rL LLVM
https://reviews.llvm.org/D32240
Files:
InstCombineCasts.cpp
Index: InstCombineCasts.cpp
===================================================================
--- InstCombineCasts.cpp
+++ InstCombineCasts.cpp
@@ -1254,6 +1254,21 @@
return BinaryOperator::CreateAShr(A, ShAmtV);
}
+ // Transform:
+ // %a = lshr i32 %i, 16
+ // %b = trunc i32 %a to i16
+ // %c = sext i16 %b to i32
+ // To:
+ // %c = ashr i32 %i, 16
+ const APInt *SA = nullptr;
+ if (match(Src, m_OneUse(m_Trunc( m_OneUse(m_LShr(m_Value(A), m_APInt(SA)))))) &&
+ A->getType() == CI.getType()) {
+ unsigned SextSize = CI.getType()->getScalarSizeInBits();
+ unsigned TruncSize = Src->getType()->getScalarSizeInBits();
+ if (*SA == SextSize - TruncSize)
+ return BinaryOperator::CreateAShr(A, ConstantInt::get(CI.getContext(), *SA));
+ }
+
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32240.95826.patch
Type: text/x-patch
Size: 811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170419/e11fe52c/attachment.bin>
More information about the llvm-commits
mailing list