[llvm] r335623 - [InstCombine] simplify code for urem fold; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 26 09:39:30 PDT 2018


Author: spatel
Date: Tue Jun 26 09:39:29 2018
New Revision: 335623

URL: http://llvm.org/viewvc/llvm-project?rev=335623&view=rev
Log:
[InstCombine] simplify code for urem fold; NFCI

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=335623&r1=335622&r2=335623&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Jun 26 09:39:29 2018
@@ -1303,11 +1303,8 @@ Instruction *InstCombiner::visitURem(Bin
   }
 
   // 1 urem X -> zext(X != 1)
-  if (match(Op0, m_One())) {
-    Value *Cmp = Builder.CreateICmpNE(Op1, Op0);
-    Value *Ext = Builder.CreateZExt(Cmp, Ty);
-    return replaceInstUsesWith(I, Ext);
-  }
+  if (match(Op0, m_One()))
+    return CastInst::CreateZExtOrBitCast(Builder.CreateICmpNE(Op1, Op0), Ty);
 
   // X urem C -> X < C ? X : X - C, where C >= signbit.
   if (match(Op1, m_Negative())) {




More information about the llvm-commits mailing list