Skip to content

Commit

Permalink
[InstCombine] improve efficiency of bool logic; NFC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rotateright committed Dec 1, 2022
1 parent 2191137 commit b7c7fe3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Expand Up @@ -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 {
Expand Down

0 comments on commit b7c7fe3

Please sign in to comment.