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 <[email protected]> Date: Fri, 19 Sep 2025 18:42:03 -0700 Subject: [PATCH 1/3] 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 <[email protected]> Date: Fri, 19 Sep 2025 18:46:08 -0700 Subject: [PATCH 2/3] 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:%.*]] [ >From 636de5001165bcfad13e4c62c190331fc967d81e Mon Sep 17 00:00:00 2001 From: Alex Richardson <[email protected]> Date: Fri, 19 Sep 2025 23:10:33 -0700 Subject: [PATCH 3/3] clarify comment Created using spr 1.3.8-beta.1 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 3699c18966016..68480dc571cf3 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -541,8 +541,8 @@ static ConstantInt *getConstantInt(Value *V, const DataLayout &DL) { if (isa<ConstantPointerNull>(V)) return ConstantInt::get(IntPtrTy, 0); - // IntToPtr const int, we can look through this unless the semantics of - // inttoptr for this address space aren't a simple (truncating) bitcast. + // IntToPtr const int, we can look through this if the semantics of + // inttoptr for this address space are a simple (truncating) bitcast. if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) if (CE->getOpcode() == Instruction::IntToPtr) if (ConstantInt *CI = dyn_cast<ConstantInt>(CE->getOperand(0))) { _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
