[llvm] [VPlan] Improve cast code in VPlanRecipes (NFC) (PR #141240)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 02:21:36 PDT 2025


================
@@ -85,8 +85,8 @@ bool VPRecipeBase::mayWriteToMemory() const {
   case VPWidenPHISC:
   case VPWidenSC:
   case VPWidenSelectSC: {
-    const Instruction *I =
-        dyn_cast_or_null<Instruction>(getVPSingleValue()->getUnderlyingValue());
+    const Instruction *I = dyn_cast_if_present<Instruction>(
----------------
fhahn wrote:

IIUC from https://discourse.llvm.org/t/psa-swapping-out-or-null-with-if-present/65018/13m https://reviews.llvm.org/D133089?id=457169, https://github.com/llvm/llvm-project/pull/75733  there wasn't consensus to use `dyn_cast_if_present` over `dyn_cast_or_null` for pointer types, with the latter being shorter and more specific for pointers. 

https://github.com/llvm/llvm-project/pull/141240


More information about the llvm-commits mailing list