[llvm] [SDAG] Fix CSE for ADDRSPACECAST nodes (PR #122912)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 10:51:40 PST 2025
================
@@ -0,0 +1,19 @@
+; RUN: llc < %s -mcpu=sm_80 -mattr=+ptx73 -debug-only=isel -o /dev/null 2>&1 | FileCheck %s
+
+; REQUIRES: asserts
+
+target triple = "nvptx64-nvidia-cuda"
+
+;; Selection DAG CSE is hard to test since we run CSE/GVN on the IR before and
+;; after selection DAG ISel so most cases will be handled by one of these.
+define void @foo(ptr %p) {
+; CHECK-LABEL: Optimized legalized selection DAG: %bb.0 'foo:'
+; CHECK: addrspacecast[0 -> 5]
+; CHECK-NOT: addrspacecast[0 -> 5]
----------------
Artem-B wrote:
Yup.
For the negative checks, the best compromise I've found is to run them as a separate test "RUN". At least that way it's possible to correctly set the bounds on the areas where the negative checks should apply. Mixing them with the regular checks is hard to implement correctly in general.
That said, in this particular case the intent appears to be to verify that there's only one instance of addrspacecast, and this combination of check and check-not is reasonable. We could use `CHECK-COUNT-1` to make it more obvious what we're doing here.
An alternative would be to autogenerate the checks and just match the exact output, but that's probably not going to work all that well with matching unstable debug printouts.
TL;DR; if we have to verify that there's only one addrrspacecast in debug printout, this is OK.
If you figure out the way to test non-debug output, I'd suggest switching to autogenerated checks.
https://github.com/llvm/llvm-project/pull/122912
More information about the llvm-commits
mailing list