================ @@ -6411,6 +6411,41 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, return Constant::getNullValue(ReturnType); break; } + case Intrinsic::ptrmask: { + if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1)) + return PoisonValue::get(Op0->getType()); + + // NOTE: We can't apply this simplifications based on the value of Op1 + // because we need to preserve provenance. + if (Q.isUndefValue(Op0) || match(Op0, m_Zero())) + return Constant::getNullValue(Op0->getType()); + + if (Op1->getType()->getScalarSizeInBits() == + Q.DL.getPointerTypeSizeInBits(Op0->getType())) { + if (match(Op1, m_PtrToInt(m_Specific(Op0)))) + return Op0; + + // NOTE: We may have attributes associated with the return value of the + // llvm.ptrmask intrinsic that will be lost when we just return the + // operand. We should try to preserve them. + if (match(Op1, m_AllOnes()) || Q.isUndefValue(Op1)) + return Op0; + + Constant *C; + if (match(Op1, m_ImmConstant(C))) { + KnownBits PtrKnown = + computeKnownBits(Op0, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT); ---------------- dtcxzyw wrote:
```suggestion KnownBits PtrKnown = computeKnownBits(Op0, /*Depth=*/0, Q); ``` See also new ValueTracking helper functions introduced by be57381a4a08b0b6a89d5b5fdec0880b202e99f4. https://github.com/llvm/llvm-project/pull/67166 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits