diff options
author | Alexey Bataev <5361294+alexey-bataev@users.noreply.github.com> | 2024-01-19 09:29:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-19 09:29:01 -0500 |
commit | 4d11f04b20f0bd7488e19e8f178ba028412fa519 (patch) | |
tree | 1bc31b85c84321088eeae57dcde4f51f015999f2 /llvm/lib | |
parent | a2a0089ac3a5781ba74d4d319c87c9e8b46d4eda (diff) | |
download | llvm-4d11f04b20f0bd7488e19e8f178ba028412fa519.zip llvm-4d11f04b20f0bd7488e19e8f178ba028412fa519.tar.gz llvm-4d11f04b20f0bd7488e19e8f178ba028412fa519.tar.bz2 |
[InstCombine] Try to fold trunc(shuffle(zext)) to just a shuffle (#78636)
Tries to remove extra trunc/ext instruction for shufflevector
instructions.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 6629ca8..3470e61 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -103,6 +103,13 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty, } } break; + case Instruction::ShuffleVector: { + Value *Op0 = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned); + Value *Op1 = EvaluateInDifferentType(I->getOperand(1), Ty, isSigned); + Res = new ShuffleVectorInst(Op0, Op1, + cast<ShuffleVectorInst>(I)->getShuffleMask()); + break; + } default: // TODO: Can handle more cases here. llvm_unreachable("Unreachable!"); @@ -363,6 +370,9 @@ static bool canEvaluateTruncated(Value *V, Type *Ty, InstCombinerImpl &IC, I->getOpcode() == Instruction::FPToSI); return Ty->getScalarSizeInBits() >= MinBitWidth; } + case Instruction::ShuffleVector: + return canEvaluateTruncated(I->getOperand(0), Ty, IC, CxtI) && + canEvaluateTruncated(I->getOperand(1), Ty, IC, CxtI); default: // TODO: Can handle more cases here. break; |