OSDN Git Service

[InstCombine] simplify code for urem fold; NFCI
authorSanjay Patel <spatel@rotateright.com>
Tue, 26 Jun 2018 16:39:29 +0000 (16:39 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 26 Jun 2018 16:39:29 +0000 (16:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335623 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

index 9833bbc..65046f2 100644 (file)
@@ -1303,11 +1303,8 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) {
   }
 
   // 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())) {