[llvm] [DirectX] replace byte splitting via vector bitcast with scalar (PR #140167)
Finn Plummer via llvm-commits
llvm-commits at lists.llvm.org
Tue May 27 12:00:54 PDT 2025
================
@@ -419,40 +421,96 @@ static void updateFnegToFsub(Instruction &I,
ToRemove.push_back(&I);
}
+static void
+legalizeGetHighLowi64Bytes(Instruction &I,
+ SmallVectorImpl<Instruction *> &ToRemove,
+ DenseMap<Value *, Value *> &ReplacedValues) {
+ if (auto *BitCast = dyn_cast<BitCastInst>(&I)) {
+ if (BitCast->getDestTy() ==
+ FixedVectorType::get(Type::getInt32Ty(I.getContext()), 2) &&
+ BitCast->getSrcTy()->isIntegerTy(64)) {
+ ToRemove.push_back(BitCast);
+ ReplacedValues[BitCast] = BitCast->getOperand(0);
+ return;
+ }
+ }
+
+ if (auto *Extract = dyn_cast<ExtractElementInst>(&I)) {
+ auto *VecTy = dyn_cast<FixedVectorType>(Extract->getVectorOperandType());
+ if (VecTy && VecTy->getElementType()->isIntegerTy(32) &&
+ VecTy->getNumElements() == 2) {
+ if (auto *Index = dyn_cast<ConstantInt>(Extract->getIndexOperand())) {
+ unsigned Idx = Index->getZExtValue();
+ IRBuilder<> Builder(&I);
+ assert(dyn_cast<BitCastInst>(Extract->getVectorOperand()));
----------------
inbelic wrote:
Should this be an if condition instead? It seems pretty easy to hit outside of this specific scenario
https://github.com/llvm/llvm-project/pull/140167
More information about the llvm-commits
mailing list