diff options
author | Nikita Popov <npopov@redhat.com> | 2024-07-08 16:08:16 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2024-07-08 16:10:58 +0200 |
commit | 12d6832d86156904aecc10e8612bd77b66aeef51 (patch) | |
tree | ad738609e43f45ffc35b1e09e87e55819f7f0233 | |
parent | d3a5589684baed14e82e57ca31fd4e988cb1436d (diff) | |
download | llvm-12d6832d86156904aecc10e8612bd77b66aeef51.zip llvm-12d6832d86156904aecc10e8612bd77b66aeef51.tar.gz llvm-12d6832d86156904aecc10e8612bd77b66aeef51.tar.bz2 |
[SCCP] Skip bitcasts entirely
The only bitcasts the existing code might be able to handle are
bitcasts between iN and <1 x iN>. Don't bother.
-rw-r--r-- | llvm/lib/Transforms/Utils/SCCPSolver.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp index 4f36bac..db0d40b 100644 --- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -1295,24 +1295,16 @@ void SCCPInstVisitor::visitCastInst(CastInst &I) { return (void)markConstant(&I, C); } - if (I.getDestTy()->isIntegerTy() && I.getSrcTy()->isIntOrIntVectorTy()) { + // Ignore bitcasts, as they may change the number of vector elements. + if (I.getDestTy()->isIntegerTy() && I.getSrcTy()->isIntOrIntVectorTy() && + I.getOpcode() != Instruction::BitCast) { auto &LV = getValueState(&I); ConstantRange OpRange = getConstantRange(OpSt, I.getSrcTy(), /*UndefAllowed=*/false); Type *DestTy = I.getDestTy(); - // Vectors where all elements have the same known constant range are treated - // as a single constant range in the lattice. When bitcasting such vectors, - // there is a mis-match between the width of the lattice value (single - // constant range) and the original operands (vector). Go to overdefined in - // that case. - if (I.getOpcode() == Instruction::BitCast && - I.getOperand(0)->getType()->isVectorTy() && - OpRange.getBitWidth() < DL.getTypeSizeInBits(DestTy)) - return (void)markOverdefined(&I); - ConstantRange Res = - OpRange.castOp(I.getOpcode(), DL.getTypeSizeInBits(DestTy)); + OpRange.castOp(I.getOpcode(), DestTy->getScalarSizeInBits()); mergeInValue(LV, &I, ValueLatticeElement::getRange(Res)); } else markOverdefined(&I); |