Skip to content

Commit 547907c

Browse files
author
git apple-llvm automerger
committed
Merge commit 'eb5280938bf2' from llvm.org/main into next
2 parents e0c8f3b + eb52809 commit 547907c

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,12 +1360,15 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
13601360
// nvvm.{min,max}.{i,ii,ui,ull}
13611361
Expand = Name == "s" || Name == "i" || Name == "ll" || Name == "us" ||
13621362
Name == "ui" || Name == "ull";
1363-
else if (Name.consume_front("atomic.load.add."))
1364-
// nvvm.atomic.load.add.{f32.p,f64.p}
1365-
Expand = Name.starts_with("f32.p") || Name.starts_with("f64.p");
1366-
else if (Name.consume_front("atomic.load.") && Name.consume_back(".32"))
1367-
// nvvm.atomic.load.{inc,dec}.32
1368-
Expand = Name == "inc" || Name == "dec";
1363+
else if (Name.consume_front("atomic.load."))
1364+
// nvvm.atomic.load.add.{f32,f64}.p
1365+
// nvvm.atomic.load.{inc,dec}.32.p
1366+
Expand = StringSwitch<bool>(Name)
1367+
.StartsWith("add.f32.p", true)
1368+
.StartsWith("add.f64.p", true)
1369+
.StartsWith("inc.32.p", true)
1370+
.StartsWith("dec.32.p", true)
1371+
.Default(false);
13691372
else if (Name.consume_front("bitcast."))
13701373
// nvvm.bitcast.{f2i,i2f,ll2d,d2ll}
13711374
Expand =
@@ -2407,10 +2410,12 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
24072410
Value *Val = CI->getArgOperand(1);
24082411
Rep = Builder.CreateAtomicRMW(AtomicRMWInst::FAdd, Ptr, Val, MaybeAlign(),
24092412
AtomicOrdering::SequentiallyConsistent);
2410-
} else if (Name.consume_front("atomic.load.") && Name.consume_back(".32")) {
2413+
} else if (Name.starts_with("atomic.load.inc.32.p") ||
2414+
Name.starts_with("atomic.load.dec.32.p")) {
24112415
Value *Ptr = CI->getArgOperand(0);
24122416
Value *Val = CI->getArgOperand(1);
2413-
auto Op = Name == "inc" ? AtomicRMWInst::UIncWrap : AtomicRMWInst::UDecWrap;
2417+
auto Op = Name.starts_with("atomic.load.inc") ? AtomicRMWInst::UIncWrap
2418+
: AtomicRMWInst::UDecWrap;
24142419
Rep = Builder.CreateAtomicRMW(Op, Ptr, Val, MaybeAlign(),
24152420
AtomicOrdering::SequentiallyConsistent);
24162421
} else if (Name.consume_front("max.") &&

llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ declare i32 @llvm.nvvm.ldg.global.i.i32.p0(ptr, i32)
5858
declare ptr @llvm.nvvm.ldg.global.p.p0(ptr, i32)
5959
declare float @llvm.nvvm.ldg.global.f.f32.p0(ptr, i32)
6060

61-
declare i32 @llvm.nvvm.atomic.load.inc.32(ptr, i32)
62-
declare i32 @llvm.nvvm.atomic.load.dec.32(ptr, i32)
61+
declare i32 @llvm.nvvm.atomic.load.inc.32.p0(ptr, i32)
62+
declare i32 @llvm.nvvm.atomic.load.dec.32.p0(ptr, i32)
63+
declare i32 @llvm.nvvm.atomic.load.add.f32.p0(ptr, float)
64+
declare i32 @llvm.nvvm.atomic.load.add.f64.p0(ptr, double)
6365

6466
declare ptr addrspace(3) @llvm.nvvm.mapa.shared.cluster(ptr addrspace(3), i32)
6567

@@ -267,12 +269,16 @@ define void @ldg(ptr %p0, ptr addrspace(1) %p1) {
267269
}
268270

269271
; CHECK-LABEL: @atomics
270-
define i32 @atomics(ptr %p0, i32 %a) {
272+
define i32 @atomics(ptr %p0, i32 %a, float %b, double %c) {
271273
; CHECK: %1 = atomicrmw uinc_wrap ptr %p0, i32 %a seq_cst
272274
; CHECK: %2 = atomicrmw udec_wrap ptr %p0, i32 %a seq_cst
275+
; CHECK: %3 = atomicrmw fadd ptr %p0, float %b seq_cst
276+
; CHECK: %4 = atomicrmw fadd ptr %p0, double %c seq_cst
273277

274-
%r1 = call i32 @llvm.nvvm.atomic.load.inc.32(ptr %p0, i32 %a)
275-
%r2 = call i32 @llvm.nvvm.atomic.load.dec.32(ptr %p0, i32 %a)
278+
%r1 = call i32 @llvm.nvvm.atomic.load.inc.32.p0(ptr %p0, i32 %a)
279+
%r2 = call i32 @llvm.nvvm.atomic.load.dec.32.p0(ptr %p0, i32 %a)
280+
%r3 = call float @llvm.nvvm.atomic.load.add.f32.p0(ptr %p0, float %b)
281+
%r4 = call double @llvm.nvvm.atomic.load.add.f64.p0(ptr %p0, double %c)
276282
ret i32 %r2
277283
}
278284

0 commit comments

Comments
 (0)