Index: llvm/lib/Analysis/ValueTracking.cpp =================================================================== --- llvm/lib/Analysis/ValueTracking.cpp +++ llvm/lib/Analysis/ValueTracking.cpp @@ -375,11 +375,6 @@ static unsigned ComputeNumSignBits(const Value *V, unsigned Depth, const Query &Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa(V->getType())) - return 1; - auto *FVTy = dyn_cast(V->getType()); APInt DemandedElts = FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); @@ -2449,10 +2444,6 @@ /// Supports values with integer or pointer type and vectors of integers. bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, const Query &Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa(V->getType())) - return false; #ifndef NDEBUG Type *Ty = V->getType(); @@ -2574,14 +2565,18 @@ // Note that we have to take special care to avoid looking through // truncating casts, e.g., int2ptr/ptr2int with appropriate sizes, as well // as casts that can alter the value, e.g., AddrSpaceCasts. - if (Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= + if (!isa(I->getOperand(0)->getType()) && + !isa(I->getType()) && + Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= Q.DL.getTypeSizeInBits(I->getType()).getFixedSize()) return isKnownNonZero(I->getOperand(0), Depth, Q); break; case Instruction::PtrToInt: // Similar to int2ptr above, we can look through ptr2int here if the cast // is a no-op or an extend and not a truncate. - if (Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= + if (!isa(I->getOperand(0)->getType()) && + !isa(I->getType()) && + Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= Q.DL.getTypeSizeInBits(I->getType()).getFixedSize()) return isKnownNonZero(I->getOperand(0), Depth, Q); break; @@ -2740,11 +2735,6 @@ } bool isKnownNonZero(const Value* V, unsigned Depth, const Query& Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa(V->getType())) - return false; - auto *FVTy = dyn_cast(V->getType()); APInt DemandedElts = FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); @@ -3096,12 +3086,6 @@ const APInt &DemandedElts, unsigned Depth, const Query &Q) { Type *Ty = V->getType(); - - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa(Ty)) - return 1; - #ifndef NDEBUG assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth"); Index: llvm/test/Transforms/InstCombine/logical-select.ll =================================================================== --- llvm/test/Transforms/InstCombine/logical-select.ll +++ llvm/test/Transforms/InstCombine/logical-select.ll @@ -742,13 +742,11 @@ define @bitcast_vec_cond_scalable( %cond, %c, %d) { ; CHECK-LABEL: @bitcast_vec_cond_scalable( -; CHECK-NEXT: [[S:%.*]] = sext [[COND:%.*]] to -; CHECK-NEXT: [[T9:%.*]] = bitcast [[S]] to -; CHECK-NEXT: [[NOTT9:%.*]] = xor [[T9]], shufflevector ( insertelement ( poison, i64 -1, i32 0), poison, zeroinitializer) -; CHECK-NEXT: [[T11:%.*]] = and [[NOTT9]], [[C:%.*]] -; CHECK-NEXT: [[T12:%.*]] = and [[T9]], [[D:%.*]] -; CHECK-NEXT: [[R:%.*]] = or [[T11]], [[T12]] -; CHECK-NEXT: ret [[R]] +; CHECK-NEXT: [[TMP1:%.*]] = bitcast [[D:%.*]] to +; CHECK-NEXT: [[TMP2:%.*]] = bitcast [[C:%.*]] to +; CHECK-NEXT: [[TMP3:%.*]] = select [[COND:%.*]], [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = bitcast [[TMP3]] to +; CHECK-NEXT: ret [[TMP4]] ; %s = sext %cond to %t9 = bitcast %s to Index: llvm/test/Transforms/InstCombine/select.ll =================================================================== --- llvm/test/Transforms/InstCombine/select.ll +++ llvm/test/Transforms/InstCombine/select.ll @@ -3409,11 +3409,10 @@ ret %b } -; TODO: shl should be nsw define @scalable_sign_bits( %x) { ; CHECK-LABEL: @scalable_sign_bits( ; CHECK-NEXT: [[A:%.*]] = sext [[X:%.*]] to -; CHECK-NEXT: [[B:%.*]] = shl [[A]], shufflevector ( insertelement ( poison, i32 16, i32 0), poison, zeroinitializer) +; CHECK-NEXT: [[B:%.*]] = shl nsw [[A]], shufflevector ( insertelement ( poison, i32 16, i32 0), poison, zeroinitializer) ; CHECK-NEXT: ret [[B]] ; %a = sext %x to @@ -3421,12 +3420,10 @@ ret %b } -; TODO: can use ult define @scalable_non_zero( %x) { ; CHECK-LABEL: @scalable_non_zero( ; CHECK-NEXT: [[A:%.*]] = or [[X:%.*]], shufflevector ( insertelement ( poison, i32 1, i32 0), poison, zeroinitializer) -; CHECK-NEXT: [[B:%.*]] = add nsw [[A]], shufflevector ( insertelement ( poison, i32 -1, i32 0), poison, zeroinitializer) -; CHECK-NEXT: [[CMP:%.*]] = icmp ult [[B]], shufflevector ( insertelement ( poison, i32 56, i32 0), poison, zeroinitializer) +; CHECK-NEXT: [[CMP:%.*]] = icmp ule [[A]], shufflevector ( insertelement ( poison, i32 56, i32 0), poison, zeroinitializer) ; CHECK-NEXT: ret [[CMP]] ; %a = or %x, shufflevector ( insertelement ( poison, i32 1, i32 0), poison, zeroinitializer)