[PATCH] D149001: [InstSimplify] sdiv a (1 srem b) --> a
Zhu Siyuan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 23 00:34:23 PDT 2023
floatshadow updated this revision to Diff 516129.
floatshadow edited the summary of this revision.
floatshadow added a comment.
clean diff following what junaire proposes
Depends on D149012 <https://reviews.llvm.org/D149012>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149001/new/
https://reviews.llvm.org/D149001
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1055,9 +1055,11 @@
// If this is a boolean op (single-bit element type), we can't have
// division-by-zero or remainder-by-zero, so assume the divisor is 1.
// Similarly, if we're zero-extending a boolean divisor, then assume it's a 1.
+ // If this is an integer remainder (1 % Y), assume similarly the divisor is 1.
Value *X;
if (match(Op1, m_One()) || Ty->isIntOrIntVectorTy(1) ||
- (match(Op1, m_ZExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)))
+ (match(Op1, m_ZExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)) ||
+ match(Op1, m_IRem(m_One(), m_Value())))
return IsDiv ? Op0 : Constant::getNullValue(Ty);
// If X * Y does not overflow, then:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149001.516129.patch
Type: text/x-patch
Size: 917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230423/945b3b76/attachment.bin>
More information about the llvm-commits
mailing list