[llvm-branch-commits] [llvm] [SimplifyCFG] Avoid using isNonIntegralPointerType() (PR #159890)

Alexander Richardson via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 19 23:08:56 PDT 2025


https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/159890

>From 318e921e83ca607732637bcfa1994e525928759e Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Fri, 19 Sep 2025 18:42:03 -0700
Subject: [PATCH 1/2] remove todo comment

Created using spr 1.3.8-beta.1
---
 llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll b/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
index 0f50e0a95e8c1..6adde1388d8cd 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -switch-range-to-icmp < %s | FileCheck %s
-target datalayout="p:40:64:64:32"
+target datalayout="p:40:64:64:32-pe200:64:64:64:32"
 
 declare void @foo1()
 
@@ -33,8 +33,6 @@ F:              ; preds = %0
   ret void
 }
 
-; We need to use finer-grained DataLayout properties for non-integral pointers
-; FIXME: Should be using a switch here
 define void @test1_ptr(ptr %V) {
 ; CHECK-LABEL: @test1_ptr(
 ; CHECK-NEXT:    [[MAGICPTR:%.*]] = ptrtoint ptr [[V:%.*]] to i40

>From 67f0cd53bcc901b4bdabcb920e3609183522b48a Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Fri, 19 Sep 2025 18:46:08 -0700
Subject: [PATCH 2/2] add test for as200

Created using spr 1.3.8-beta.1
---
 .../SimplifyCFG/switch_create-custom-dl.ll    | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll b/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
index 6adde1388d8cd..3d11cfe525e45 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
@@ -89,6 +89,34 @@ F:              ; preds = %0
   ret void
 }
 
+; TODO: Should we allow the transformation for pointers with external state?
+define void @test1_ptr_external_state(ptr addrspace(200) %V) {
+; CHECK-LABEL: @test1_ptr_external_state(
+; CHECK-NEXT:    [[C1:%.*]] = icmp eq ptr addrspace(200) [[V:%.*]], inttoptr (i32 4 to ptr addrspace(200))
+; CHECK-NEXT:    [[C2:%.*]] = icmp eq ptr addrspace(200) [[V]], inttoptr (i32 17 to ptr addrspace(200))
+; CHECK-NEXT:    [[CN:%.*]] = or i1 [[C1]], [[C2]]
+; CHECK-NEXT:    br i1 [[CN]], label [[T:%.*]], label [[F:%.*]]
+; CHECK:       common.ret:
+; CHECK-NEXT:    ret void
+; CHECK:       T:
+; CHECK-NEXT:    call void @foo1()
+; CHECK-NEXT:    br label [[COMMON_RET:%.*]]
+; CHECK:       F:
+; CHECK-NEXT:    call void @foo2()
+; CHECK-NEXT:    br label [[COMMON_RET]]
+;
+  %C1 = icmp eq ptr addrspace(200) %V, inttoptr (i32 4 to ptr addrspace(200))
+  %C2 = icmp eq ptr addrspace(200) %V, inttoptr (i32 17 to ptr addrspace(200))
+  %CN = or i1 %C1, %C2            ; <i1> [#uses=1]
+  br i1 %CN, label %T, label %F
+T:              ; preds = %0
+  call void @foo1( )
+  ret void
+F:              ; preds = %0
+  call void @foo2( )
+  ret void
+}
+
 define void @test2(i32 %V) {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    switch i32 [[V:%.*]], label [[T:%.*]] [



More information about the llvm-branch-commits mailing list