[llvm] [NVPTX] instcombine known pointer AS checks. (PR #112964)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 14:39:19 PDT 2024
================
@@ -413,11 +416,65 @@ static Instruction *simplifyNvvmIntrinsic(IntrinsicInst *II, InstCombiner &IC) {
llvm_unreachable("All SpecialCase enumerators should be handled in switch.");
}
+// Returns an instruction pointer (may be nullptr if we do not know the answer).
+// Returns nullopt if `II` is not one of the `isspacep` intrinsics.
+static std::optional<Instruction *>
----------------
Artem-B wrote:
We have three outcomes here and the code is structured to convey that via the use of optional.
- not an isspacep intrinsic, and hence we have no answer -> nullopt.
- if's an isspacep intrinsic, we do produce an answer, and it may be:
- we've changed something, return non-null pointer
- the answer is "we don't know", in which case we return nullptr
While we could return `nullptr` we'd continue checking for other intrinsics. It would happen to work, because nothing else handles the isspacep intrinsics, but I'd prefer the code to match the intent, and we do not intend to fall through into the code that deals with FP intrinsics.
https://github.com/llvm/llvm-project/pull/112964
More information about the llvm-commits
mailing list