From b7c7fe3d0779b6e332fe6db64e87561deba2e56a Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 1 Dec 2022 07:59:48 -0500 Subject: [PATCH] [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. --- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 {