[llvm] r362655 - [InstCombine] simplify code for bitcast of insertelement; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 14:26:53 PDT 2019


Author: spatel
Date: Wed Jun  5 14:26:52 2019
New Revision: 362655

URL: http://llvm.org/viewvc/llvm-project?rev=362655&view=rev
Log:
[InstCombine] simplify code for bitcast of insertelement; NFC

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

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=362655&r1=362654&r2=362655&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Wed Jun  5 14:26:52 2019
@@ -2376,11 +2376,10 @@ Instruction *InstCombiner::visitBitCast(
       }
 
       // Otherwise, see if our source is an insert. If so, then use the scalar
-      // component directly.
-      if (InsertElementInst *IEI =
-            dyn_cast<InsertElementInst>(CI.getOperand(0)))
-        return CastInst::Create(Instruction::BitCast, IEI->getOperand(1),
-                                DestTy);
+      // component directly:
+      // bitcast (inselt <1 x elt> V, X, 0) to <n x m> --> bitcast X to <n x m>
+      if (auto *InsElt = dyn_cast<InsertElementInst>(Src))
+        return new BitCastInst(InsElt->getOperand(1), DestTy);
     }
   }
 




More information about the llvm-commits mailing list