[llvm] [Attributor] Don't replace `AddrSpaceCast` with `ConstantPointerNull` (PR #126779)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 10:59:51 PST 2025


================
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=attributor $s -o - | FileCheck %s
+
+define i32 @bar(ptr %p0, ptr addrspace(5) %p5) {
+; CHECK-LABEL: define i32 @bar(
+; CHECK-SAME: ptr nofree readonly captures(none) [[P0:%.*]], ptr addrspace(5) nofree readonly [[P5:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp eq ptr addrspace(5) [[P5]], addrspacecast (ptr null to ptr addrspace(5))
+; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[TMP0]], ptr [[P0]], ptr null
+; CHECK-NEXT:    switch i8 0, label %[[BB_2:.*]] [
+; CHECK-NEXT:      i8 0, label %[[BB_0:.*]]
+; CHECK-NEXT:      i8 1, label %[[BB_1:.*]]
+; CHECK-NEXT:    ]
+; CHECK:       [[BB_0]]:
+; CHECK-NEXT:    [[TMP2:%.*]] = load i32, ptr [[TMP1]], align 4
+; CHECK-NEXT:    ret i32 [[TMP2]]
+; CHECK:       [[BB_1]]:
+; CHECK-NEXT:    unreachable
+; CHECK:       [[BB_2]]:
+; CHECK-NEXT:    unreachable
+;
+entry:
+  %0 = icmp eq ptr addrspace(5) %p5, addrspacecast (ptr null to ptr addrspace(5))
----------------
arsenm wrote:

Use named values in tests

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


More information about the llvm-commits mailing list