[llvm] b7c7fe3 - [InstCombine] improve efficiency of bool logic; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 11:47:46 PST 2022


Author: Sanjay Patel
Date: 2022-12-01T14:47:37-05:00
New Revision: b7c7fe3d0779b6e332fe6db64e87561deba2e56a

URL: https://github.com/llvm/llvm-project/commit/b7c7fe3d0779b6e332fe6db64e87561deba2e56a
DIFF: https://github.com/llvm/llvm-project/commit/b7c7fe3d0779b6e332fe6db64e87561deba2e56a.diff

LOG: [InstCombine] improve efficiency of bool logic; NFC

As noted in issue #59266, the logic reduction could be
beyond the capabilities of an optimizing compiler, and
the code with ternary op is easier to read either way.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 3320bf5f74a8e..8b353abb94923 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -1540,8 +1540,7 @@ static Instruction *foldTruncInsElt(InsertElementInst &InsElt, bool IsBigEndian,
 
   unsigned NumEltsInScalar = ScalarWidth / VecEltWidth;
   Value *X = T;
-  if ((IsBigEndian && IndexC == NumEltsInScalar - 1) ||
-      (!IsBigEndian && IndexC == 0)) {
+  if (IndexC == (IsBigEndian ? NumEltsInScalar - 1 : 0)) {
     // The insert is to the LSB end of the vector (depends on endian).
     // That's all we need.
   } else {


        


More information about the llvm-commits mailing list