[llvm] [AMDGPU] Enable atomic optimizer for divergent i64 and double values (PR #96934)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 01:14:45 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff b037d0f0e5f6c7ab528fe3ed9d855f0d770c6709 43f4b9e7457a8a277d04bafbd4d2fc6e026fd46c --extensions h,c,cpp -- bolt/include/bolt/Core/MCPlusBuilder.h bolt/include/bolt/Utils/CommandLineOpts.h bolt/lib/Profile/Heatmap.cpp bolt/lib/Target/X86/X86MCPlusBuilder.cpp bolt/lib/Utils/CommandLineOpts.cpp clang/include/clang/Sema/Sema.h clang/lib/AST/Interp/Interp.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/CodeGenTypes.h clang/lib/Sema/SemaTemplate.cpp clang/test/AST/Interp/literals.cpp clang/test/CodeGen/aarch64-byval-temp.c clang/test/CodeGen/attr-noundef.cpp clang/test/CodeGen/builtins-bitint.c clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/builtins-overflow.c clang/test/CodeGen/ext-int-cc.c clang/test/CodeGen/ext-int-sanitizer.cpp clang/test/CodeGen/ext-int.c clang/test/CodeGen/extend-arg-64.c clang/test/CodeGen/ubsan-shift-bitint.c clang/test/CodeGenCXX/ext-int.cpp clang/test/CodeGenHIP/printf_nonhostcall.cpp clang/test/Frontend/fixed_point_comparisons.c clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp clang/test/OpenMP/target_teams_generic_loop_if_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_if_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp clang/test/OpenMP/teams_distribute_simd_codegen.cpp flang/include/flang/Optimizer/Builder/IntrinsicCall.h flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h flang/include/flang/Runtime/misc-intrinsic.h flang/lib/Evaluate/intrinsics.cpp flang/lib/Optimizer/Builder/IntrinsicCall.cpp flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp flang/runtime/misc-intrinsic.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Passes/CodeGenPassBuilder.h llvm/lib/Analysis/ConstantFolding.cpp llvm/lib/Analysis/InstructionSimplify.cpp llvm/lib/CodeGen/CodeGen.cpp llvm/lib/CodeGen/TwoAddressInstructionPass.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Target/AArch64/AArch64FrameLowering.cpp llvm/lib/Target/AArch64/AArch64InstrInfo.cpp llvm/lib/Target/AArch64/AArch64InstrInfo.h llvm/lib/Target/AArch64/AArch64PBQPRegAlloc.cpp llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/lib/Target/AMDGPU/SIFrameLowering.cpp llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a38484941b..d465eff101 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3862,8 +3862,8 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
       Address ArgAddr(&*AI, ConvertType(RetTy), Alignment);
       LValue ArgVal =
           LValue::MakeAddr(ArgAddr, RetTy, getContext(), BaseInfo, TBAAInfo);
-      EmitStoreOfScalar(
-          Builder.CreateLoad(ReturnValue), ArgVal, /*isInit*/ true);
+      EmitStoreOfScalar(Builder.CreateLoad(ReturnValue), ArgVal,
+                        /*isInit*/ true);
       break;
     }
     }
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 00a5a7e689..b54543bf1c 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -609,9 +609,10 @@ bool ConstStructBuilder::AppendBytes(CharUnits FieldOffsetInChars,
   return Builder.add(InitCst, StartOffset + FieldOffsetInChars, AllowOverwrite);
 }
 
-bool ConstStructBuilder::AppendBitField(
-    const FieldDecl *Field, uint64_t FieldOffset, llvm::ConstantInt *CI,
-    bool AllowOverwrite) {
+bool ConstStructBuilder::AppendBitField(const FieldDecl *Field,
+                                        uint64_t FieldOffset,
+                                        llvm::ConstantInt *CI,
+                                        bool AllowOverwrite) {
   const CGRecordLayout &RL =
       CGM.getTypes().getCGRecordLayout(Field->getParent());
   const CGBitFieldInfo &Info = RL.getBitFieldInfo(Field);
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index f40f3c2732..8159f8c80b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -436,9 +436,9 @@ public:
 
     if (Value *Result = ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
       if (E->isGLValue())
-        return CGF.Builder.CreateLoad(Address(
-            Result, CGF.ConvertTypeForMem(E->getType()),
-            CGF.getContext().getTypeAlignInChars(E->getType())));
+        return CGF.Builder.CreateLoad(
+            Address(Result, CGF.ConvertTypeForMem(E->getType()),
+                    CGF.getContext().getTypeAlignInChars(E->getType())));
       return Result;
     }
     return Visit(E->getSubExpr());
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9296cc66d6..f5610b080d 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2171,7 +2171,7 @@ namespace {
 /// Tree transform to "extract" a transformed type from a class template's
 /// constructor to a deduction guide.
 class ExtractTypeForDeductionGuide
-  : public TreeTransform<ExtractTypeForDeductionGuide> {
+    : public TreeTransform<ExtractTypeForDeductionGuide> {
   llvm::SmallVectorImpl<TypedefNameDecl *> &MaterializedTypedefs;
   ClassTemplateDecl *NestedPattern;
   const MultiLevelTemplateArgumentList *OuterInstantiationArgs;
@@ -2456,8 +2456,8 @@ struct ConvertConstructorToDeductionGuideTransform {
       SmallVector<NamedDecl *, 16> AllParams;
       SmallVector<TemplateArgument, 16> Depth1Args;
       AllParams.reserve(TemplateParams->size() + InnerParams->size());
-      AllParams.insert(AllParams.begin(),
-                       TemplateParams->begin(), TemplateParams->end());
+      AllParams.insert(AllParams.begin(), TemplateParams->begin(),
+                       TemplateParams->end());
       SubstArgs.reserve(InnerParams->size());
       Depth1Args.reserve(InnerParams->size());
 
@@ -2526,15 +2526,16 @@ struct ConvertConstructorToDeductionGuideTransform {
       Args.addOuterRetainedLevel();
     }
 
-    FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()->getTypeLoc()
-                                   .getAsAdjusted<FunctionProtoTypeLoc>();
+    FunctionProtoTypeLoc FPTL = CD->getTypeSourceInfo()
+                                    ->getTypeLoc()
+                                    .getAsAdjusted<FunctionProtoTypeLoc>();
     assert(FPTL && "no prototype for constructor declaration");
 
     // Transform the type of the function, adjusting the return type and
     // replacing references to the old parameters with references to the
     // new ones.
     TypeLocBuilder TLB;
-    SmallVector<ParmVarDecl*, 8> Params;
+    SmallVector<ParmVarDecl *, 8> Params;
     SmallVector<TypedefNameDecl *, 4> MaterializedTypedefs;
     QualType NewType = transformFunctionProtoType(TLB, FPTL, Params, Args,
                                                   MaterializedTypedefs);
@@ -2569,7 +2570,7 @@ struct ConvertConstructorToDeductionGuideTransform {
         TSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
 
     // Build the parameters, needed during deduction / substitution.
-    SmallVector<ParmVarDecl*, 4> Params;
+    SmallVector<ParmVarDecl *, 4> Params;
     for (auto T : ParamTypes) {
       auto *TSI = SemaRef.Context.getTrivialTypeSourceInfo(T, Loc);
       if (NestedPattern)
@@ -2697,7 +2698,8 @@ private:
       NewDI =
           SemaRef.SubstType(PackTL.getPatternLoc(), Args,
                             OldParam->getLocation(), OldParam->getDeclName());
-      if (!NewDI) return nullptr;
+      if (!NewDI)
+        return nullptr;
       NewDI =
           SemaRef.CheckPackExpansion(NewDI, PackTL.getEllipsisLoc(),
                                      PackTL.getTypePtr()->getNumExpansions());
@@ -3460,7 +3462,8 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl *Template,
   }
   if (CXXRecordDecl *DefRecord =
           cast<CXXRecordDecl>(Template->getTemplatedDecl())->getDefinition()) {
-    if (TemplateDecl *DescribedTemplate = DefRecord->getDescribedClassTemplate())
+    if (TemplateDecl *DescribedTemplate =
+            DefRecord->getDescribedClassTemplate())
       Template = DescribedTemplate;
   }
 
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index c9dc8ac2e5..378e529464 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -298,7 +298,7 @@ void initializeTargetLibraryInfoWrapperPassPass(PassRegistry&);
 void initializeTargetPassConfigPass(PassRegistry&);
 void initializeTargetTransformInfoWrapperPassPass(PassRegistry&);
 void initializeTLSVariableHoistLegacyPassPass(PassRegistry &);
-void initializeTwoAddressInstructionPassPass(PassRegistry&);
+void initializeTwoAddressInstructionPassPass(PassRegistry &);
 void initializeTypeBasedAAWrapperPassPass(PassRegistry&);
 void initializeTypePromotionLegacyPass(PassRegistry&);
 void initializeInitUndefPass(PassRegistry &);
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 73385fee01..6f988a6577 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -205,7 +205,7 @@ public:
   }
 
   /// Pass entry point.
-  bool runOnMachineFunction(MachineFunction&) override;
+  bool runOnMachineFunction(MachineFunction &) override;
 };
 
 } // end anonymous namespace
@@ -215,10 +215,10 @@ char TwoAddressInstructionPass::ID = 0;
 char &llvm::TwoAddressInstructionPassID = TwoAddressInstructionPass::ID;
 
 INITIALIZE_PASS_BEGIN(TwoAddressInstructionPass, DEBUG_TYPE,
-                "Two-Address instruction pass", false, false)
+                      "Two-Address instruction pass", false, false)
 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
 INITIALIZE_PASS_END(TwoAddressInstructionPass, DEBUG_TYPE,
-                "Two-Address instruction pass", false, false)
+                    "Two-Address instruction pass", false, false)
 
 /// Return the MachineInstr* if it is the single def of the Reg in current BB.
 MachineInstr *
@@ -1236,11 +1236,9 @@ bool TwoAddressInstructionPass::tryInstructionCommute(MachineInstr *MI,
 /// (either because they were untied, or because mi was rescheduled, and will
 /// be visited again later). If the shouldOnlyCommute flag is true, only
 /// instruction commutation is attempted.
-bool TwoAddressInstructionPass::
-tryInstructionTransform(MachineBasicBlock::iterator &mi,
-                        MachineBasicBlock::iterator &nmi,
-                        unsigned SrcIdx, unsigned DstIdx,
-                        unsigned &Dist, bool shouldOnlyCommute) {
+bool TwoAddressInstructionPass::tryInstructionTransform(
+    MachineBasicBlock::iterator &mi, MachineBasicBlock::iterator &nmi,
+    unsigned SrcIdx, unsigned DstIdx, unsigned &Dist, bool shouldOnlyCommute) {
   if (OptLevel == CodeGenOptLevel::None)
     return false;
 
@@ -1440,8 +1438,8 @@ tryInstructionTransform(MachineBasicBlock::iterator &mi,
 // Collect tied operands of MI that need to be handled.
 // Rewrite trivial cases immediately.
 // Return true if any tied operands where found, including the trivial ones.
-bool TwoAddressInstructionPass::
-collectTiedOperands(MachineInstr *MI, TiedOperandMap &TiedOperands) {
+bool TwoAddressInstructionPass::collectTiedOperands(
+    MachineInstr *MI, TiedOperandMap &TiedOperands) {
   bool AnyOps = false;
   unsigned NumOps = MI->getNumOperands();
 
@@ -1479,10 +1477,9 @@ collectTiedOperands(MachineInstr *MI, TiedOperandMap &TiedOperands) {
 
 // Process a list of tied MI operands that all use the same source register.
 // The tied pairs are of the form (SrcIdx, DstIdx).
-void
-TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
-                                            TiedPairList &TiedPairs,
-                                            unsigned &Dist) {
+void TwoAddressInstructionPass::processTiedPairs(MachineInstr *MI,
+                                                 TiedPairList &TiedPairs,
+                                                 unsigned &Dist) {
   bool IsEarlyClobber = llvm::any_of(TiedPairs, [MI](auto const &TP) {
     return MI->getOperand(TP.second).isEarlyClobber();
   });
@@ -1930,8 +1927,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &Func) {
 ///
 ///   undef %dst:ssub0 = COPY %v1
 ///   %dst:ssub1 = COPY %v2
-void TwoAddressInstructionPass::
-eliminateRegSequence(MachineBasicBlock::iterator &MBBI) {
+void TwoAddressInstructionPass::eliminateRegSequence(
+    MachineBasicBlock::iterator &MBBI) {
   MachineInstr &MI = *MBBI;
   Register DstReg = MI.getOperand(0).getReg();
 

``````````

</details>


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


More information about the llvm-commits mailing list