[llvm] [SystemZ] Enable AtomicExpand pass (PR #70398)

Ilya Leoshkevich via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 18:06:50 PDT 2023


https://github.com/iii-i created https://github.com/llvm/llvm-project/pull/70398

The upcoming OpenMP support for SystemZ requires handling of IR insns like `atomicrmw fadd`. Normally atomic float operations are expanded by Clang and such insns do not occur, but OpenMP generates them directly. Other architectures handle this using the AtomicExpand pass, which SystemZ did not need so far. Enable it.

Currently AtomicExpand treats atomic load and stores of floats pessimistically: it casts them to integers, which SystemZ does not need, since the floating point load and store instructions are already atomic. However, the way Clang currently expands them is pessimistic as well, so this change does not make things worse. Optimizing operations on atomic floats can be a separate change in the future.

This change does not create any differences the Linux kernel build.

>From f89107e04008ad6ca897051405520dee9b0bd08f Mon Sep 17 00:00:00 2001
From: Ilya Leoshkevich <iii at linux.ibm.com>
Date: Fri, 27 Oct 2023 02:57:08 +0200
Subject: [PATCH] [SystemZ] Enable AtomicExpand pass

The upcoming OpenMP support for SystemZ requires handling of IR insns
like `atomicrmw fadd`. Normally atomic float operations are expanded
by Clang and such insns do not occur, but OpenMP generates them
directly. Other architectures handle this using the AtomicExpand pass,
which SystemZ did not need so far. Enable it.

Currently AtomicExpand treats atomic load and stores of floats
pessimistically: it casts them to integers, which SystemZ does not
need, since the floating point load and store instructions are already
atomic. However, the way Clang currently expands them is pessimistic
as well, so this change does not make things worse. Optimizing
operations on atomic floats can be a separate change in the future.

This change does not create any differences the Linux kernel build.
---
 llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
index 8235446da65c458..186494ad2ac614c 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -226,6 +226,8 @@ void SystemZPassConfig::addIRPasses() {
     addPass(createLoopDataPrefetchPass());
   }
 
+  addPass(createAtomicExpandPass());
+
   TargetPassConfig::addIRPasses();
 }
 



More information about the llvm-commits mailing list