[llvm] [WIP][Assume] Generic assume-based uniformity optimization (PR #160670)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 4 21:33:45 PDT 2025


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 origin/main HEAD --extensions cpp -- llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index aff8516e4..95f5039dd 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3540,14 +3540,15 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
       }
     }
 
-    // Basic assume equality optimization: assume(x == c) -> replace dominated uses of x with c
+    // Basic assume equality optimization: assume(x == c) -> replace dominated
+    // uses of x with c
     if (auto *ICmp = dyn_cast<ICmpInst>(IIOperand)) {
       if (ICmp->getPredicate() == ICmpInst::ICMP_EQ) {
         Value *LHS = ICmp->getOperand(0);
         Value *RHS = ICmp->getOperand(1);
         Value *Variable = nullptr;
         Constant *ConstantVal = nullptr;
-        
+
         if (auto *C = dyn_cast<Constant>(RHS)) {
           Variable = LHS;
           ConstantVal = C;
@@ -3555,7 +3556,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
           Variable = RHS;
           ConstantVal = C;
         }
-        
+
         if (Variable && ConstantVal && Variable->hasUseList()) {
           SmallVector<Use *, 8> DominatedUses;
           for (Use &U : Variable->uses()) {
@@ -3566,12 +3567,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
               }
             }
           }
-          
+
           for (Use *U : DominatedUses) {
             U->set(ConstantVal);
             Worklist.pushValue(U->getUser());
           }
-          
+
           if (!DominatedUses.empty()) {
             Worklist.pushValue(Variable);
           }
@@ -3583,7 +3584,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
     // assume(ballot(cmp) == -1) means cmp is true on all active lanes
     // We can replace uses of cmp with true in dominated contexts
     Value *BallotInst;
-    if (match(IIOperand, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Value(BallotInst), m_AllOnes()))) {
+    if (match(IIOperand, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Value(BallotInst),
+                                        m_AllOnes()))) {
       if (auto *IntrCall = dyn_cast<IntrinsicInst>(BallotInst)) {
         if (IntrCall->getIntrinsicID() == Intrinsic::amdgcn_ballot) {
           Value *BallotArg = IntrCall->getArgOperand(0);
@@ -3598,13 +3600,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
                 }
               }
             }
-            
+
             // Replace dominated uses with true
             for (Use *U : DominatedUses) {
               U->set(ConstantInt::getTrue(BallotArg->getType()));
               Worklist.pushValue(U->getUser());
             }
-            
+
             if (!DominatedUses.empty()) {
               Worklist.pushValue(BallotArg);
             }
@@ -5079,5 +5081,3 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
   Call.setCalledFunction(FTy, NestF);
   return &Call;
 }
-
-

``````````

</details>


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


More information about the llvm-commits mailing list