Skip to content

Conversation

@jinhuang1102
Copy link
Contributor

This PR enhance the profile metadata in the ExpandIRinsts pass to ensure accurate profiling information is included for better performance analysis.

The following chagnes were make:

  • Applied createUnlikelyBranchWeights to select instruction Ret0 and
    conditional branches ConBrSpecialCases and ConBrBB1.
  • Replaced Builder.CreateSelect with Builder.CreateSelectWithUnknownProfile
    for RetVal and EarlyRet when ProfcheckDisableMetadataFixes in not set.
  • Used setExplicitlyUnknownBranchWeightsIfProfiled for the ConBrDoWhile
    conditional branch.

@llvmbot
Copy link
Member

llvmbot commented Dec 19, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Jin Huang (jinhuang1102)

Changes

This PR enhance the profile metadata in the ExpandIRinsts pass to ensure accurate profiling information is included for better performance analysis.

The following chagnes were make:

  • Applied createUnlikelyBranchWeights to select instruction Ret0 and
    conditional branches ConBrSpecialCases and ConBrBB1.
  • Replaced Builder.CreateSelect with Builder.CreateSelectWithUnknownProfile
    for RetVal and EarlyRet when ProfcheckDisableMetadataFixes in not set.
  • Used setExplicitlyUnknownBranchWeightsIfProfiled for the ConBrDoWhile
    conditional branch.

Patch is 37.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/173114.diff

6 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/IntegerDivision.cpp (+70-5)
  • (modified) llvm/test/Transforms/ExpandIRInsts/X86/sdiv129.ll (+13-7)
  • (modified) llvm/test/Transforms/ExpandIRInsts/X86/srem129.ll (+13-7)
  • (modified) llvm/test/Transforms/ExpandIRInsts/X86/udiv129.ll (+13-7)
  • (modified) llvm/test/Transforms/ExpandIRInsts/X86/urem129.ll (+13-7)
  • (modified) llvm/test/Transforms/ExpandIRInsts/X86/vector.ll (+39-32)
diff --git a/llvm/lib/Transforms/Utils/IntegerDivision.cpp b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
index e95a7a9ae525a..115c254df251e 100644
--- a/llvm/lib/Transforms/Utils/IntegerDivision.cpp
+++ b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
@@ -16,13 +16,22 @@
 #include "llvm/Transforms/Utils/IntegerDivision.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/MDBuilder.h"
+#include "llvm/IR/ProfDataUtils.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 
 using namespace llvm;
 
 #define DEBUG_TYPE "integer-division"
 
+namespace llvm {
+extern cl::opt<bool> ProfcheckDisableMetadataFixes;
+}
+
 /// Generate code to compute the remainder of two signed integers. Returns the
 /// remainder, which will have the sign of the dividend. Builder's insert point
 /// should be pointing where the caller wants code generated, e.g. at the srem
@@ -235,11 +244,53 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   Value *Tmp1 = Builder.CreateCall(CTLZ, {Dividend, True});
   Value *SR          = Builder.CreateSub(Tmp0, Tmp1);
   Value *Ret0_4      = Builder.CreateICmpUGT(SR, MSB);
+
+  // Add 'unlikely' branch weights to the select instruction ('Ret0') generated
+  // by 'CreateLogicalOr'. We assume the 'true' path, where either the divisor
+  // or dividend is zero ('Ret0_3'), is less likely than the 'false' path,
+  // which corresponds to the |divisor| > |dividend| ('Ret0_4').
   Value *Ret0        = Builder.CreateLogicalOr(Ret0_3, Ret0_4);
+  if (!ProfcheckDisableMetadataFixes) {
+    if (Instruction *Ret0SelectI = dyn_cast<Instruction>(Ret0)) {
+      Ret0SelectI->setMetadata(
+          LLVMContext::MD_prof,
+          MDBuilder(Ret0SelectI->getContext()).createUnlikelyBranchWeights());
+    }
+  }
   Value *RetDividend = Builder.CreateICmpEQ(SR, MSB);
-  Value *RetVal      = Builder.CreateSelect(Ret0, Zero, Dividend);
-  Value *EarlyRet    = Builder.CreateLogicalOr(Ret0, RetDividend);
-  Builder.CreateCondBr(EarlyRet, End, BB1);
+
+  // This select instruction (RetVal) immediately follows the Ret0 check. Since
+  // Ret0_4 determines if the divisor is greater then the dividend so the
+  // unknown (50/50) branch weights are fairly accurate for RetVal.
+  Value *RetVal;
+  if (!ProfcheckDisableMetadataFixes) {
+    RetVal = Builder.CreateSelectWithUnknownProfile(Ret0, Zero, Dividend,
+                                                    DEBUG_TYPE);
+  } else {
+    RetVal = Builder.CreateSelect(Ret0, Zero, Dividend);
+  }
+  // This select instruction (EarlyRet) is used to check another edge case, and
+  // it share the same branch weights as RetVal so the unknown (50/50)branch
+  // weights are also accurate for EarlyRet.
+  Value *EarlyRet;
+  if (!ProfcheckDisableMetadataFixes) {
+    EarlyRet = Builder.CreateSelectWithUnknownProfile(
+        Ret0, ConstantInt::getAllOnesValue(Ret0->getType()), RetDividend,
+        DEBUG_TYPE);
+  } else {
+    EarlyRet = Builder.CreateLogicalOr(Ret0, RetDividend);
+  }
+
+  // The condition of this branch is based on `EarlyRet`. `EarlyRet` is true
+  // only for special cases like dividend or divisor being zero, or the divisor
+  // being greater than the dividend. Thus, the branch to `End` is unlikely,
+  // and we expect to more frequently enter `BB1`.
+  Instruction *ConBrSpecialCases = Builder.CreateCondBr(EarlyRet, End, BB1);
+  if (!ProfcheckDisableMetadataFixes) {
+    ConBrSpecialCases->setMetadata(LLVMContext::MD_prof,
+                                   MDBuilder(ConBrSpecialCases->getContext())
+                                       .createUnlikelyBranchWeights());
+  }
 
   // ; bb1:                                             ; preds = %special-cases
   // ;   %sr_1     = add i32 %sr, 1
@@ -252,7 +303,15 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   Value *Tmp2     = Builder.CreateSub(MSB, SR);
   Value *Q        = Builder.CreateShl(Dividend, Tmp2);
   Value *SkipLoop = Builder.CreateICmpEQ(SR_1, Zero);
-  Builder.CreateCondBr(SkipLoop, LoopExit, Preheader);
+  // This branch is highly unlikely. SR_1 (SR + 1) is expected to be in [1, 129]
+  // because the case where |divisor| > |dividend| (which would make SR
+  // negative) has alredy been intercepted in the previous SpecialCases BB.
+  Instruction *ConBrBB1 = Builder.CreateCondBr(SkipLoop, LoopExit, Preheader);
+  if (!ProfcheckDisableMetadataFixes) {
+    ConBrBB1->setMetadata(LLVMContext::MD_prof,
+                           MDBuilder(ConBrBB1->getContext())
+                               .createUnlikelyBranchWeights());
+  }
 
   // ; preheader:                                           ; preds = %bb1
   // ;   %tmp3 = lshr i32 %dividend, %sr_1
@@ -298,7 +357,13 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   Value *R     = Builder.CreateSub(Tmp7, Tmp11);
   Value *SR_2  = Builder.CreateAdd(SR_3, NegOne);
   Value *Tmp12 = Builder.CreateICmpEQ(SR_2, Zero);
-  Builder.CreateCondBr(Tmp12, LoopExit, DoWhile);
+  // The loop implements the core bit-by-bit binary long division algorithm.
+  // Since each iteration generates one bit of the quotient until covering all
+  // significant bits so we would label it as unknown (50/50) branch weights.
+  Instruction *ConBrDoWhile = Builder.CreateCondBr(Tmp12, LoopExit, DoWhile);
+  if (!ProfcheckDisableMetadataFixes) {
+    setExplicitlyUnknownBranchWeightsIfProfiled(*ConBrDoWhile, DEBUG_TYPE, F);
+  }
 
   // ; loop-exit:                                      ; preds = %do-while, %bb1
   // ;   %carry_2 = phi i32 [ 0, %bb1 ], [ %carry, %do-while ]
diff --git a/llvm/test/Transforms/ExpandIRInsts/X86/sdiv129.ll b/llvm/test/Transforms/ExpandIRInsts/X86/sdiv129.ll
index fc823cd543144..01b50da066d88 100644
--- a/llvm/test/Transforms/ExpandIRInsts/X86/sdiv129.ll
+++ b/llvm/test/Transforms/ExpandIRInsts/X86/sdiv129.ll
@@ -2,8 +2,9 @@
 ; RUN: opt -S -mtriple=x86_64-- -expand-ir-insts -expand-div-rem-bits 128 < %s | FileCheck %s
 ; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-ir-insts' -expand-div-rem-bits 128 < %s | FileCheck %s
 
-define void @sdiv129(ptr %ptr, ptr %out) nounwind {
+define void @sdiv129(ptr %ptr, ptr %out) nounwind !prof !0 {
 ; CHECK-LABEL: @sdiv129(
+; CHECK: !prof [[PROF_0:![0-9]+]] {
 ; CHECK-NEXT:  _udiv-special-cases:
 ; CHECK-NEXT:    [[A:%.*]] = load i129, ptr [[PTR:%.*]], align 16
 ; CHECK-NEXT:    [[TMP0:%.*]] = freeze i129 [[A]]
@@ -24,11 +25,11 @@ define void @sdiv129(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP15:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP10]], i1 true)
 ; CHECK-NEXT:    [[TMP16:%.*]] = sub i129 [[TMP14]], [[TMP15]]
 ; CHECK-NEXT:    [[TMP17:%.*]] = icmp ugt i129 [[TMP16]], 128
-; CHECK-NEXT:    [[TMP18:%.*]] = select i1 [[TMP13]], i1 true, i1 [[TMP17]]
+; CHECK-NEXT:    [[TMP18:%.*]] = select i1 [[TMP13]], i1 true, i1 [[TMP17]], !prof [[PROF_1:![0-9]+]]
 ; CHECK-NEXT:    [[TMP19:%.*]] = icmp eq i129 [[TMP16]], 128
-; CHECK-NEXT:    [[TMP20:%.*]] = select i1 [[TMP18]], i129 0, i129 [[TMP10]]
-; CHECK-NEXT:    [[TMP21:%.*]] = select i1 [[TMP18]], i1 true, i1 [[TMP19]]
-; CHECK-NEXT:    br i1 [[TMP21]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]]
+; CHECK-NEXT:    [[TMP20:%.*]] = select i1 [[TMP18]], i129 0, i129 [[TMP10]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    [[TMP21:%.*]] = select i1 [[TMP18]], i1 true, i1 [[TMP19]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    br i1 [[TMP21]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-loop-exit:
 ; CHECK-NEXT:    [[TMP22:%.*]] = phi i129 [ 0, [[UDIV_BB1]] ], [ [[TMP37:%.*]], [[UDIV_DO_WHILE:%.*]] ]
 ; CHECK-NEXT:    [[TMP23:%.*]] = phi i129 [ [[TMP46:%.*]], [[UDIV_BB1]] ], [ [[TMP34:%.*]], [[UDIV_DO_WHILE]] ]
@@ -52,7 +53,7 @@ define void @sdiv129(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP39]] = sub i129 [[TMP32]], [[TMP38]]
 ; CHECK-NEXT:    [[TMP40]] = add i129 [[TMP27]], -1
 ; CHECK-NEXT:    [[TMP41:%.*]] = icmp eq i129 [[TMP40]], 0
-; CHECK-NEXT:    br i1 [[TMP41]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]]
+; CHECK-NEXT:    br i1 [[TMP41]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]], !prof [[PROF_2:![0-9]+]]
 ; CHECK:       udiv-preheader:
 ; CHECK-NEXT:    [[TMP42]] = lshr i129 [[TMP10]], [[TMP44]]
 ; CHECK-NEXT:    [[TMP43]] = add i129 [[TMP9]], -1
@@ -62,7 +63,7 @@ define void @sdiv129(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP45:%.*]] = sub i129 128, [[TMP16]]
 ; CHECK-NEXT:    [[TMP46]] = shl i129 [[TMP10]], [[TMP45]]
 ; CHECK-NEXT:    [[TMP47:%.*]] = icmp eq i129 [[TMP44]], 0
-; CHECK-NEXT:    br i1 [[TMP47]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]]
+; CHECK-NEXT:    br i1 [[TMP47]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-end:
 ; CHECK-NEXT:    [[TMP48:%.*]] = phi i129 [ [[TMP25]], [[UDIV_LOOP_EXIT]] ], [ [[TMP20]], [[_UDIV_SPECIAL_CASES:%.*]] ]
 ; CHECK-NEXT:    [[TMP49:%.*]] = xor i129 [[TMP48]], [[TMP8]]
@@ -75,3 +76,8 @@ define void @sdiv129(ptr %ptr, ptr %out) nounwind {
   store i129 %res, ptr %out
   ret void
 }
+
+!0 = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_1]] = !{!"branch_weights", i32 1, i32 1048575}
+; CHECK: [[PROF_2]] = !{!"unknown", !"integer-division"}
\ No newline at end of file
diff --git a/llvm/test/Transforms/ExpandIRInsts/X86/srem129.ll b/llvm/test/Transforms/ExpandIRInsts/X86/srem129.ll
index 667152228d258..0485c1ac5607e 100644
--- a/llvm/test/Transforms/ExpandIRInsts/X86/srem129.ll
+++ b/llvm/test/Transforms/ExpandIRInsts/X86/srem129.ll
@@ -2,8 +2,9 @@
 ; RUN: opt -S -mtriple=x86_64-- -expand-ir-insts -expand-div-rem-bits 128 < %s | FileCheck %s
 ; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-ir-insts' -expand-div-rem-bits 128 < %s | FileCheck %s
 
-define void @test(ptr %ptr, ptr %out) nounwind {
+define void @test(ptr %ptr, ptr %out) nounwind !prof !0 {
 ; CHECK-LABEL: @test(
+; CHECK: !prof [[PROF_0:![0-9]+]] {
 ; CHECK-NEXT:  _udiv-special-cases:
 ; CHECK-NEXT:    [[A:%.*]] = load i129, ptr [[PTR:%.*]], align 16
 ; CHECK-NEXT:    [[TMP0:%.*]] = freeze i129 [[A]]
@@ -25,11 +26,11 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP16:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP11]], i1 true)
 ; CHECK-NEXT:    [[TMP17:%.*]] = sub i129 [[TMP15]], [[TMP16]]
 ; CHECK-NEXT:    [[TMP18:%.*]] = icmp ugt i129 [[TMP17]], 128
-; CHECK-NEXT:    [[TMP19:%.*]] = select i1 [[TMP14]], i1 true, i1 [[TMP18]]
+; CHECK-NEXT:    [[TMP19:%.*]] = select i1 [[TMP14]], i1 true, i1 [[TMP18]], !prof [[PROF_1:![0-9]+]]
 ; CHECK-NEXT:    [[TMP20:%.*]] = icmp eq i129 [[TMP17]], 128
-; CHECK-NEXT:    [[TMP21:%.*]] = select i1 [[TMP19]], i129 0, i129 [[TMP11]]
-; CHECK-NEXT:    [[TMP22:%.*]] = select i1 [[TMP19]], i1 true, i1 [[TMP20]]
-; CHECK-NEXT:    br i1 [[TMP22]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]]
+; CHECK-NEXT:    [[TMP21:%.*]] = select i1 [[TMP19]], i129 0, i129 [[TMP11]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    [[TMP22:%.*]] = select i1 [[TMP19]], i1 true, i1 [[TMP20]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    br i1 [[TMP22]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-loop-exit:
 ; CHECK-NEXT:    [[TMP23:%.*]] = phi i129 [ 0, [[UDIV_BB1]] ], [ [[TMP38:%.*]], [[UDIV_DO_WHILE:%.*]] ]
 ; CHECK-NEXT:    [[TMP24:%.*]] = phi i129 [ [[TMP47:%.*]], [[UDIV_BB1]] ], [ [[TMP35:%.*]], [[UDIV_DO_WHILE]] ]
@@ -53,7 +54,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP40]] = sub i129 [[TMP33]], [[TMP39]]
 ; CHECK-NEXT:    [[TMP41]] = add i129 [[TMP28]], -1
 ; CHECK-NEXT:    [[TMP42:%.*]] = icmp eq i129 [[TMP41]], 0
-; CHECK-NEXT:    br i1 [[TMP42]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]]
+; CHECK-NEXT:    br i1 [[TMP42]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]], !prof [[PROF_2:![0-9]+]]
 ; CHECK:       udiv-preheader:
 ; CHECK-NEXT:    [[TMP43]] = lshr i129 [[TMP11]], [[TMP45]]
 ; CHECK-NEXT:    [[TMP44]] = add i129 [[TMP10]], -1
@@ -63,7 +64,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP46:%.*]] = sub i129 128, [[TMP17]]
 ; CHECK-NEXT:    [[TMP47]] = shl i129 [[TMP11]], [[TMP46]]
 ; CHECK-NEXT:    [[TMP48:%.*]] = icmp eq i129 [[TMP45]], 0
-; CHECK-NEXT:    br i1 [[TMP48]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]]
+; CHECK-NEXT:    br i1 [[TMP48]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-end:
 ; CHECK-NEXT:    [[TMP49:%.*]] = phi i129 [ [[TMP26]], [[UDIV_LOOP_EXIT]] ], [ [[TMP21]], [[_UDIV_SPECIAL_CASES:%.*]] ]
 ; CHECK-NEXT:    [[TMP50:%.*]] = mul i129 [[TMP9]], [[TMP49]]
@@ -78,3 +79,8 @@ define void @test(ptr %ptr, ptr %out) nounwind {
   store i129 %res, ptr %out
   ret void
 }
+
+!0 = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_1]] = !{!"branch_weights", i32 1, i32 1048575}
+; CHECK: [[PROF_2]] = !{!"unknown", !"integer-division"}
diff --git a/llvm/test/Transforms/ExpandIRInsts/X86/udiv129.ll b/llvm/test/Transforms/ExpandIRInsts/X86/udiv129.ll
index b2b83815f79b0..c3a21dbd145d8 100644
--- a/llvm/test/Transforms/ExpandIRInsts/X86/udiv129.ll
+++ b/llvm/test/Transforms/ExpandIRInsts/X86/udiv129.ll
@@ -2,8 +2,9 @@
 ; RUN: opt -S -mtriple=x86_64-- -expand-ir-insts -expand-div-rem-bits 128 < %s | FileCheck %s
 ; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-ir-insts' -expand-div-rem-bits 128 < %s | FileCheck %s
 
-define void @test(ptr %ptr, ptr %out) nounwind {
+define void @test(ptr %ptr, ptr %out) nounwind !prof !0 {
 ; CHECK-LABEL: @test(
+; CHECK: !prof [[PROF_0:![0-9]+]] {
 ; CHECK-NEXT:  _udiv-special-cases:
 ; CHECK-NEXT:    [[A:%.*]] = load i129, ptr [[PTR:%.*]], align 16
 ; CHECK-NEXT:    [[TMP0:%.*]] = freeze i129 3
@@ -15,11 +16,11 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP6:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP1]], i1 true)
 ; CHECK-NEXT:    [[TMP7:%.*]] = sub i129 [[TMP5]], [[TMP6]]
 ; CHECK-NEXT:    [[TMP8:%.*]] = icmp ugt i129 [[TMP7]], 128
-; CHECK-NEXT:    [[TMP9:%.*]] = select i1 [[TMP4]], i1 true, i1 [[TMP8]]
+; CHECK-NEXT:    [[TMP9:%.*]] = select i1 [[TMP4]], i1 true, i1 [[TMP8]], !prof [[PROF_1:![0-9]+]]
 ; CHECK-NEXT:    [[TMP10:%.*]] = icmp eq i129 [[TMP7]], 128
-; CHECK-NEXT:    [[TMP11:%.*]] = select i1 [[TMP9]], i129 0, i129 [[TMP1]]
-; CHECK-NEXT:    [[TMP12:%.*]] = select i1 [[TMP9]], i1 true, i1 [[TMP10]]
-; CHECK-NEXT:    br i1 [[TMP12]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]]
+; CHECK-NEXT:    [[TMP11:%.*]] = select i1 [[TMP9]], i129 0, i129 [[TMP1]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    [[TMP12:%.*]] = select i1 [[TMP9]], i1 true, i1 [[TMP10]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    br i1 [[TMP12]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-loop-exit:
 ; CHECK-NEXT:    [[TMP13:%.*]] = phi i129 [ 0, [[UDIV_BB1]] ], [ [[TMP28:%.*]], [[UDIV_DO_WHILE:%.*]] ]
 ; CHECK-NEXT:    [[TMP14:%.*]] = phi i129 [ [[TMP37:%.*]], [[UDIV_BB1]] ], [ [[TMP25:%.*]], [[UDIV_DO_WHILE]] ]
@@ -43,7 +44,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP30]] = sub i129 [[TMP23]], [[TMP29]]
 ; CHECK-NEXT:    [[TMP31]] = add i129 [[TMP18]], -1
 ; CHECK-NEXT:    [[TMP32:%.*]] = icmp eq i129 [[TMP31]], 0
-; CHECK-NEXT:    br i1 [[TMP32]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]]
+; CHECK-NEXT:    br i1 [[TMP32]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]], !prof [[PROF_2:![0-9]+]]
 ; CHECK:       udiv-preheader:
 ; CHECK-NEXT:    [[TMP33]] = lshr i129 [[TMP1]], [[TMP35]]
 ; CHECK-NEXT:    [[TMP34]] = add i129 [[TMP0]], -1
@@ -53,7 +54,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP36:%.*]] = sub i129 128, [[TMP7]]
 ; CHECK-NEXT:    [[TMP37]] = shl i129 [[TMP1]], [[TMP36]]
 ; CHECK-NEXT:    [[TMP38:%.*]] = icmp eq i129 [[TMP35]], 0
-; CHECK-NEXT:    br i1 [[TMP38]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]]
+; CHECK-NEXT:    br i1 [[TMP38]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-end:
 ; CHECK-NEXT:    [[TMP39:%.*]] = phi i129 [ [[TMP16]], [[UDIV_LOOP_EXIT]] ], [ [[TMP11]], [[_UDIV_SPECIAL_CASES:%.*]] ]
 ; CHECK-NEXT:    store i129 [[TMP39]], ptr [[OUT:%.*]], align 16
@@ -64,3 +65,8 @@ define void @test(ptr %ptr, ptr %out) nounwind {
   store i129 %res, ptr %out
   ret void
 }
+
+!0 = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000}
+; CHECK: [[PROF_1]] = !{!"branch_weights", i32 1, i32 1048575}
+; CHECK: [[PROF_2]] = !{!"unknown", !"integer-division"}
diff --git a/llvm/test/Transforms/ExpandIRInsts/X86/urem129.ll b/llvm/test/Transforms/ExpandIRInsts/X86/urem129.ll
index 46e72001b2c2d..0809b70b55a42 100644
--- a/llvm/test/Transforms/ExpandIRInsts/X86/urem129.ll
+++ b/llvm/test/Transforms/ExpandIRInsts/X86/urem129.ll
@@ -2,8 +2,9 @@
 ; RUN: opt -S -mtriple=x86_64-- -expand-ir-insts -expand-div-rem-bits 128 < %s | FileCheck %s
 ; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-ir-insts' -expand-div-rem-bits 128 < %s | FileCheck %s
 
-define void @test(ptr %ptr, ptr %out) nounwind {
+define void @test(ptr %ptr, ptr %out) nounwind !prof !0 {
 ; CHECK-LABEL: @test(
+; CHECK: !prof [[PROF_0:![0-9]+]] {
 ; CHECK-NEXT:  _udiv-special-cases:
 ; CHECK-NEXT:    [[A:%.*]] = load i129, ptr [[PTR:%.*]], align 16
 ; CHECK-NEXT:    [[TMP0:%.*]] = freeze i129 [[A]]
@@ -17,11 +18,11 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP8:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
 ; CHECK-NEXT:    [[TMP9:%.*]] = sub i129 [[TMP7]], [[TMP8]]
 ; CHECK-NEXT:    [[TMP10:%.*]] = icmp ugt i129 [[TMP9]], 128
-; CHECK-NEXT:    [[TMP11:%.*]] = select i1 [[TMP6]], i1 true, i1 [[TMP10]]
+; CHECK-NEXT:    [[TMP11:%.*]] = select i1 [[TMP6]], i1 true, i1 [[TMP10]], !prof [[PROF_1:![0-9]+]]
 ; CHECK-NEXT:    [[TMP12:%.*]] = icmp eq i129 [[TMP9]], 128
-; CHECK-NEXT:    [[TMP13:%.*]] = select i1 [[TMP11]], i129 0, i129 [[TMP3]]
-; CHECK-NEXT:    [[TMP14:%.*]] = select i1 [[TMP11]], i1 true, i1 [[TMP12]]
-; CHECK-NEXT:    br i1 [[TMP14]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]]
+; CHECK-NEXT:    [[TMP13:%.*]] = select i1 [[TMP11]], i129 0, i129 [[TMP3]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    [[TMP14:%.*]] = select i1 [[TMP11]], i1 true, i1 [[TMP12]], !prof [[PROF_2:![0-9]+]]
+; CHECK-NEXT:    br i1 [[TMP14]], label [[UDIV_END:%.*]], label [[UDIV_BB1:%.*]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-loop-exit:
 ; CHECK-NEXT:    [[TMP15:%.*]] = phi i129 [ 0, [[UDIV_BB1]] ], [ [[TMP30:%.*]], [[UDIV_DO_WHILE:%.*]] ]
 ; CHECK-NEXT:    [[TMP16:%.*]] = phi i129 [ [[TMP39:%.*]], [[UDIV_BB1]] ], [ [[TMP27:%.*]], [[UDIV_DO_WHILE]] ]
@@ -45,7 +46,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP32]] = sub i129 [[TMP25]], [[TMP31]]
 ; CHECK-NEXT:    [[TMP33]] = add i129 [[TMP20]], -1
 ; CHECK-NEXT:    [[TMP34:%.*]] = icmp eq i129 [[TMP33]], 0
-; CHECK-NEXT:    br i1 [[TMP34]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]]
+; CHECK-NEXT:    br i1 [[TMP34]], label [[UDIV_LOOP_EXIT:%.*]], label [[UDIV_DO_WHILE]], !prof [[PROF_2:![0-9]+]]
 ; CHECK:       udiv-preheader:
 ; CHECK-NEXT:    [[TMP35]] = lshr i129 [[TMP3]], [[TMP37]]
 ; CHECK-NEXT:    [[TMP36]] = add i129 [[TMP2]], -1
@@ -55,7 +56,7 @@ define void @test(ptr %ptr, ptr %out) nounwind {
 ; CHECK-NEXT:    [[TMP38:%.*]] = sub i129 128, [[TMP9]]
 ; CHECK-NEXT:    [[TMP39]] = shl i129 [[TMP3]], [[TMP38]]
 ; CHECK-NEXT:    [[TMP40:%.*]] = icmp eq i129 [[TMP37]], 0
-; CHECK-NEXT:    br i1 [[TMP40]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]]
+; CHECK-NEXT:    br i1 [[TMP40]], label [[UDIV_LOOP_EXIT]], label [[UDIV_PREHEADER]], !prof [[PROF_1:![0-9]+]]
 ; CHECK:       udiv-end:
 ; CHECK-NEXT:    [[TMP41:%.*]] = phi i129 [ [[TMP18]], [[UDIV_LOOP_EXIT]] ], [ [[TMP13]], [[_UDIV_SPECIAL_CASES:%.*]] ]
 ; CHECK-NEXT:    [[TMP42:%.*]] = mul i129 [[TMP1]], [[TMP41]]
@@ -68,3 +69,8 @@ define void @test(ptr %ptr, ptr %out) nou...
[truncated]

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Transforms/Utils/IntegerDivision.cpp --diff_from_common_commit

⚠️
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.
⚠️

View the diff from clang-format here.
diff --git a/llvm/lib/Transforms/Utils/IntegerDivision.cpp b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
index 115c254df..b747d6a15 100644
--- a/llvm/lib/Transforms/Utils/IntegerDivision.cpp
+++ b/llvm/lib/Transforms/Utils/IntegerDivision.cpp
@@ -308,9 +308,9 @@ static Value *generateUnsignedDivisionCode(Value *Dividend, Value *Divisor,
   // negative) has alredy been intercepted in the previous SpecialCases BB.
   Instruction *ConBrBB1 = Builder.CreateCondBr(SkipLoop, LoopExit, Preheader);
   if (!ProfcheckDisableMetadataFixes) {
-    ConBrBB1->setMetadata(LLVMContext::MD_prof,
-                           MDBuilder(ConBrBB1->getContext())
-                               .createUnlikelyBranchWeights());
+    ConBrBB1->setMetadata(
+        LLVMContext::MD_prof,
+        MDBuilder(ConBrBB1->getContext()).createUnlikelyBranchWeights());
   }
 
   // ; preheader:                                           ; preds = %bb1

@jinhuang1102 jinhuang1102 force-pushed the fixup/prof-missing-ExpandLargeDivRem branch from 115a17a to 99fcfbd Compare December 19, 2025 23:05
@jinhuang1102 jinhuang1102 requested a review from tmsri December 19, 2025 23:11
!0 = !{!"function_entry_count", i64 1000}
; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000}
; CHECK: [[PROF_1]] = !{!"branch_weights", i32 1, i32 1048575}
; CHECK: [[PROF_2]] = !{!"unknown", !"integer-division"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing a newline here

@github-actions
Copy link

🪟 Windows x64 Test Results

  • 128822 tests passed
  • 2836 tests skipped
  • 4 tests failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.CodeGen/RISCV/idiv_large.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe -mtriple=riscv32 < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll --check-prefix=RV32
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=riscv32
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll' --check-prefix=RV32
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll:474:14: error: RV32-NEXT: expected string not found in input
# | ; RV32-NEXT: mv a4, a0
# |              ^
# | <stdin>:462:38: note: scanning from here
# |  sw s11, 92(sp) # 4-byte Folded Spill
# |                                      ^
# | <stdin>:463:2: note: possible intended match here
# |  mv a3, a0
# |  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll:1035:14: error: RV32-NEXT: expected string not found in input
# | ; RV32-NEXT: mv s8, a0
# |              ^
# | <stdin>:1015:39: note: scanning from here
# |  sw s11, 188(sp) # 4-byte Folded Spill
# |                                       ^
# | <stdin>:1226:2: note: possible intended match here
# |  mv s1, a0
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\RISCV\idiv_large.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |            457:  sw s6, 112(sp) # 4-byte Folded Spill 
# |            458:  sw s7, 108(sp) # 4-byte Folded Spill 
# |            459:  sw s8, 104(sp) # 4-byte Folded Spill 
# |            460:  sw s9, 100(sp) # 4-byte Folded Spill 
# |            461:  sw s10, 96(sp) # 4-byte Folded Spill 
# |            462:  sw s11, 92(sp) # 4-byte Folded Spill 
# | next:474'0                                           X error: no match found
# |            463:  mv a3, a0 
# | next:474'0      ~~~~~~~~~~~
# | next:474'1       ?          possible intended match
# |            464:  lw ra, 0(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            465:  lw a5, 4(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            466:  lw s9, 8(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            467:  lw s10, 12(a2) 
# | next:474'0      ~~~~~~~~~~~~~~~~
# |            468:  lui t4, 349525 
# | next:474'0      ~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |           1010:  sw s6, 208(sp) # 4-byte Folded Spill 
# |           1011:  sw s7, 204(sp) # 4-byte Folded Spill 
# |           1012:  sw s8, 200(sp) # 4-byte Folded Spill 
# |           1013:  sw s9, 196(sp) # 4-byte Folded Spill 
# |           1014:  sw s10, 192(sp) # 4-byte Folded Spill 
# |           1015:  sw s11, 188(sp) # 4-byte Folded Spill 
# | next:1035'0                                           X error: no match found
# |           1016:  sw a0, 8(sp) # 4-byte Folded Spill 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1017:  lw t2, 16(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1018:  lw a4, 0(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1019:  lw a5, 4(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1020:  lw a6, 8(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |           1221:  lw a7, 0(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1222:  lw t0, 4(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1223:  lw a6, 8(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1224:  bnez s3, .LBB3_16 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~
# |           1225: # %bb.15: # %_udiv-special-cases 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1226:  mv s1, a0 
# | next:1035'0     ~~~~~~~~~~~
# | next:1035'1      ?          possible intended match
# |           1227: .LBB3_16: # %_udiv-special-cases 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1228:  lw t1, 12(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1229:  lw a1, 16(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1230:  slli a0, a6, 31 
# | next:1035'0     ~~~~~~~~~~~~~~~~~
# |           1231:  srli a2, t0, 1 
# | next:1035'0     ~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/div-rem-pair-recomposition-signed.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-signed.ll -mtriple=i686-unknown-unknown   -mattr=+sse,+sse2 | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-signed.ll --check-prefix=X86
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=i686-unknown-unknown -mattr=+sse,+sse2
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-signed.ll' --check-prefix=X86
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-signed.ll:155:13: error: X86-NEXT: expected string not found in input
# | ; X86-NEXT: movl 32(%ebp), %ecx
# |             ^
# | <stdin>:99:17: note: scanning from here
# |  subl $176, %esp
# |                 ^
# | <stdin>:100:2: note: possible intended match here
# |  movl 32(%ebp), %eax
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-signed.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            94:  movl %esp, %ebp 
# |            95:  pushl %ebx 
# |            96:  pushl %edi 
# |            97:  pushl %esi 
# |            98:  andl $-16, %esp 
# |            99:  subl $176, %esp 
# | next:155'0                     X error: no match found
# |           100:  movl 32(%ebp), %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# | next:155'1      ?                    possible intended match
# |           101:  movl 36(%ebp), %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           102:  movl %ecx, %edx 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |           103:  sarl $31, %edx 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |           104:  xorl %edx, %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |           105:  movl %ecx, %edi 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/div-rem-pair-recomposition-unsigned.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-unsigned.ll -mtriple=i686-unknown-unknown   -mattr=+sse,+sse2 | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-unsigned.ll --check-prefix=X86
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=i686-unknown-unknown -mattr=+sse,+sse2
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-unsigned.ll' --check-prefix=X86
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-unsigned.ll:155:13: error: X86-NEXT: expected string not found in input
# | ; X86-NEXT: movl 48(%ebp), %esi
# |             ^
# | <stdin>:99:17: note: scanning from here
# |  subl $160, %esp
# |                 ^
# | <stdin>:100:2: note: possible intended match here
# |  movl 48(%ebp), %ebx
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\div-rem-pair-recomposition-unsigned.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            94:  movl %esp, %ebp 
# |            95:  pushl %ebx 
# |            96:  pushl %edi 
# |            97:  pushl %esi 
# |            98:  andl $-16, %esp 
# |            99:  subl $160, %esp 
# | next:155'0                     X error: no match found
# |           100:  movl 48(%ebp), %ebx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# | next:155'1      ?                    possible intended match
# |           101:  movl 40(%ebp), %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           102:  movl 52(%ebp), %esi 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           103:  movl 44(%ebp), %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           104:  orl %esi, %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |           105:  orl %ebx, %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/pr38539.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll -mtriple=x86_64-unknown -verify-machineinstrs | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll --check-prefix=X64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=x86_64-unknown -verify-machineinstrs
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll' --check-prefix=X64
# note: command had no output on stdout or stderr
# RUN: at line 3
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll -mtriple=i686-unknown -verify-machineinstrs | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll --check-prefix=X86
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=i686-unknown -verify-machineinstrs
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll' --check-prefix=X86
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll:26:13: error: X86-NEXT: is not on the line after the previous match
# | ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
# |             ^
# | <stdin>:183:2: note: 'next' match was here
# |  movl 8(%esp), %edi # 4-byte Reload
# |  ^
# | <stdin>:14:17: note: previous match ended here
# |  subl $160, %esp
# |                 ^
# | <stdin>:15:1: note: non-matching line after previous match is here
# |  movl 136(%esp), %esi
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\pr38539.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |          .
# |          .
# |          .
# |        178:  movl %edi, 60(%esp) # 4-byte Spill 
# |        179:  movl %ebx, %esi 
# |        180:  shldl $1, %ebx, %ecx 
# |        181:  movl 36(%esp), %ebx # 4-byte Reload 
# |        182:  shldl $1, %ebx, %esi 
# |        183:  movl 8(%esp), %edi # 4-byte Reload 
# | next:26      !~~~~~~~~~~~~~~~~~                  error: match on wrong line
# |        184:  movl %edi, %edx 
# |        185:  andl $2, %edx 
# |        186:  shrl %edx 
# |        187:  leal (%edx,%ebx,2), %ebx 
# |        188:  movl 40(%esp), %edx # 4-byte Reload 
# |          .
# |          .
# |          .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 167346 tests passed
  • 2964 tests skipped
  • 4 tests failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.CodeGen/RISCV/idiv_large.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=riscv32 < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll --check-prefix=RV32
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=riscv32
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll --check-prefix=RV32
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll:474:14: error: RV32-NEXT: expected string not found in input
# | ; RV32-NEXT: mv a4, a0
# |              ^
# | <stdin>:462:38: note: scanning from here
# |  sw s11, 92(sp) # 4-byte Folded Spill
# |                                      ^
# | <stdin>:463:2: note: possible intended match here
# |  mv a3, a0
# |  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll:1035:14: error: RV32-NEXT: expected string not found in input
# | ; RV32-NEXT: mv s8, a0
# |              ^
# | <stdin>:1015:39: note: scanning from here
# |  sw s11, 188(sp) # 4-byte Folded Spill
# |                                       ^
# | <stdin>:1226:2: note: possible intended match here
# |  mv s1, a0
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/RISCV/idiv_large.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |            457:  sw s6, 112(sp) # 4-byte Folded Spill 
# |            458:  sw s7, 108(sp) # 4-byte Folded Spill 
# |            459:  sw s8, 104(sp) # 4-byte Folded Spill 
# |            460:  sw s9, 100(sp) # 4-byte Folded Spill 
# |            461:  sw s10, 96(sp) # 4-byte Folded Spill 
# |            462:  sw s11, 92(sp) # 4-byte Folded Spill 
# | next:474'0                                           X error: no match found
# |            463:  mv a3, a0 
# | next:474'0      ~~~~~~~~~~~
# | next:474'1       ?          possible intended match
# |            464:  lw ra, 0(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            465:  lw a5, 4(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            466:  lw s9, 8(a2) 
# | next:474'0      ~~~~~~~~~~~~~~
# |            467:  lw s10, 12(a2) 
# | next:474'0      ~~~~~~~~~~~~~~~~
# |            468:  lui t4, 349525 
# | next:474'0      ~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |           1010:  sw s6, 208(sp) # 4-byte Folded Spill 
# |           1011:  sw s7, 204(sp) # 4-byte Folded Spill 
# |           1012:  sw s8, 200(sp) # 4-byte Folded Spill 
# |           1013:  sw s9, 196(sp) # 4-byte Folded Spill 
# |           1014:  sw s10, 192(sp) # 4-byte Folded Spill 
# |           1015:  sw s11, 188(sp) # 4-byte Folded Spill 
# | next:1035'0                                           X error: no match found
# |           1016:  sw a0, 8(sp) # 4-byte Folded Spill 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1017:  lw t2, 16(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1018:  lw a4, 0(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1019:  lw a5, 4(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1020:  lw a6, 8(a2) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# |           1221:  lw a7, 0(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1222:  lw t0, 4(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1223:  lw a6, 8(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~
# |           1224:  bnez s3, .LBB3_16 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~
# |           1225: # %bb.15: # %_udiv-special-cases 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1226:  mv s1, a0 
# | next:1035'0     ~~~~~~~~~~~
# | next:1035'1      ?          possible intended match
# |           1227: .LBB3_16: # %_udiv-special-cases 
# | next:1035'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           1228:  lw t1, 12(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1229:  lw a1, 16(a1) 
# | next:1035'0     ~~~~~~~~~~~~~~~
# |           1230:  slli a0, a6, 31 
# | next:1035'0     ~~~~~~~~~~~~~~~~~
# |           1231:  srli a2, t0, 1 
# | next:1035'0     ~~~~~~~~~~~~~~~~
# |              .
# |              .
# |              .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/div-rem-pair-recomposition-signed.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll -mtriple=i686-unknown-unknown   -mattr=+sse,+sse2 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll --check-prefix=X86
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=i686-unknown-unknown -mattr=+sse,+sse2
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll --check-prefix=X86
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll:155:13: error: X86-NEXT: expected string not found in input
# | ; X86-NEXT: movl 32(%ebp), %ecx
# |             ^
# | <stdin>:99:17: note: scanning from here
# |  subl $176, %esp
# |                 ^
# | <stdin>:100:2: note: possible intended match here
# |  movl 32(%ebp), %eax
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-signed.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            94:  movl %esp, %ebp 
# |            95:  pushl %ebx 
# |            96:  pushl %edi 
# |            97:  pushl %esi 
# |            98:  andl $-16, %esp 
# |            99:  subl $176, %esp 
# | next:155'0                     X error: no match found
# |           100:  movl 32(%ebp), %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# | next:155'1      ?                    possible intended match
# |           101:  movl 36(%ebp), %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           102:  movl %ecx, %edx 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |           103:  sarl $31, %edx 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |           104:  xorl %edx, %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |           105:  movl %ecx, %edi 
# | next:155'0     ~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/div-rem-pair-recomposition-unsigned.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll -mtriple=i686-unknown-unknown   -mattr=+sse,+sse2 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll --check-prefix=X86
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=i686-unknown-unknown -mattr=+sse,+sse2
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll --check-prefix=X86
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll:155:13: error: X86-NEXT: expected string not found in input
# | ; X86-NEXT: movl 48(%ebp), %esi
# |             ^
# | <stdin>:99:17: note: scanning from here
# |  subl $160, %esp
# |                 ^
# | <stdin>:100:2: note: possible intended match here
# |  movl 48(%ebp), %ebx
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/div-rem-pair-recomposition-unsigned.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            94:  movl %esp, %ebp 
# |            95:  pushl %ebx 
# |            96:  pushl %edi 
# |            97:  pushl %esi 
# |            98:  andl $-16, %esp 
# |            99:  subl $160, %esp 
# | next:155'0                     X error: no match found
# |           100:  movl 48(%ebp), %ebx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# | next:155'1      ?                    possible intended match
# |           101:  movl 40(%ebp), %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           102:  movl 52(%ebp), %esi 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           103:  movl 44(%ebp), %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~~~~~~
# |           104:  orl %esi, %eax 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |           105:  orl %ebx, %ecx 
# | next:155'0     ~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

LLVM.CodeGen/X86/pr38539.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll -mtriple=x86_64-unknown -verify-machineinstrs | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll --check-prefix=X64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=x86_64-unknown -verify-machineinstrs
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll --check-prefix=X64
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll -mtriple=i686-unknown -verify-machineinstrs | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll --check-prefix=X86
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llc -mtriple=i686-unknown -verify-machineinstrs
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll --check-prefix=X86
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll:26:13: error: X86-NEXT: is not on the line after the previous match
# | ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
# |             ^
# | <stdin>:183:2: note: 'next' match was here
# |  movl 8(%esp), %edi # 4-byte Reload
# |  ^
# | <stdin>:14:17: note: previous match ended here
# |  subl $160, %esp
# |                 ^
# | <stdin>:15:1: note: non-matching line after previous match is here
# |  movl 136(%esp), %esi
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/CodeGen/X86/pr38539.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |          .
# |          .
# |          .
# |        178:  movl %edi, 60(%esp) # 4-byte Spill 
# |        179:  movl %ebx, %esi 
# |        180:  shldl $1, %ebx, %ecx 
# |        181:  movl 36(%esp), %ebx # 4-byte Reload 
# |        182:  shldl $1, %ebx, %esi 
# |        183:  movl 8(%esp), %edi # 4-byte Reload 
# | next:26      !~~~~~~~~~~~~~~~~~                  error: match on wrong line
# |        184:  movl %edi, %edx 
# |        185:  andl $2, %edx 
# |        186:  shrl %edx 
# |        187:  leal (%edx,%ebx,2), %ebx 
# |        188:  movl 40(%esp), %edx # 4-byte Reload 
# |          .
# |          .
# |          .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants