Revert "[InstCombine] improve efficiency of bool logic; NFC"
authorSanjay Patel <spatel@rotateright.com>
Thu, 8 Dec 2022 15:46:49 +0000 (10:46 -0500)
committerSanjay Patel <spatel@rotateright.com>
Thu, 8 Dec 2022 19:16:46 +0000 (14:16 -0500)
This reverts commit b7c7fe3d0779b6e332fe6db64e87561deba2e56a.

As discussed in the planned follow-on to this patch (D138874),
this and the previous patch in this set can cause trouble for
the backend, and there's probably no quick fix. We may even
want to canonicalize in the opposite direction (towards insertelt).

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

index ab5c8d4..d45b465 100644 (file)
@@ -1541,7 +1541,8 @@ static Instruction *foldTruncInsElt(InsertElementInst &InsElt, bool IsBigEndian,
 
   unsigned NumEltsInScalar = ScalarWidth / VecEltWidth;
   Value *X = T;
-  if (IndexC == (IsBigEndian ? NumEltsInScalar - 1 : 0)) {
+  if ((IsBigEndian && IndexC == NumEltsInScalar - 1) ||
+      (!IsBigEndian && IndexC == 0)) {
     // The insert is to the LSB end of the vector (depends on endian).
     // That's all we need.
   } else {