Skip to content

Conversation

@davemgreen
Copy link
Collaborator

@davemgreen davemgreen commented Aug 4, 2025

We want to be able to produce extr instructions post-legalization. They are legal for scalars, acting as a funnel shift with a constant shift amount. Unfortunately I'm not sure if there is a way currently to represent that in the legalization rules, but it might be useful for several operations - to be able to treat and test operands with constant operands as legal or not.

This adds a change to the existing matchOrShiftToFunnelShift so that AArch64 can generate such instructions post-legalization providing that the operation is scalar and the shift amount is constant. It doesn't feel like the best solution - any thoughts on alternatives?

@davemgreen
Copy link
Collaborator Author

This adds a change to the existing matchOrShiftToFunnelShift so that AArch64 can generate such instructions post-legalization providing that the operation is scalar and the shift amount is constant. It doesn't feel like the best solution - any thoughts on alternatives?

@llvmbot
Copy link
Member

llvmbot commented Aug 4, 2025

@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-aarch64

Author: David Green (davemgreen)

Changes

We want to be able to produce extr instructions post-legalization. They are legal for scalars, acting as a funnel shifts with a constant shift amount. Unfortunately I'm not sure if there is a way currently to represent that in the legalization rules, but it might be useful for several operations - to be able to treat and test operands with constant operands as legal or not.

This adds a change to the existing matchOrShiftToFunnelShift so that AArch64 can generate such instructions post-legalization providing that the operation is scalar and the shift amount is constant. It doesn't feel like the best solution - any thoughts on alternatives?


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

8 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h (+2-1)
  • (modified) llvm/include/llvm/Target/GlobalISel/Combine.td (+9-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+4-5)
  • (modified) llvm/lib/Target/AArch64/AArch64Combine.td (+2-1)
  • (modified) llvm/test/CodeGen/AArch64/adc.ll (+2-4)
  • (modified) llvm/test/CodeGen/AArch64/fsh.ll (+212-261)
  • (modified) llvm/test/CodeGen/AArch64/funnel-shift.ll (+27-28)
  • (modified) llvm/test/CodeGen/AArch64/rem-by-const.ll (+82-91)
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index da829046cc421..9051fd0e4474c 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -627,7 +627,8 @@ class CombinerHelper {
   /// This variant does not erase \p MI after calling the build function.
   void applyBuildFnNoErase(MachineInstr &MI, BuildFnTy &MatchInfo) const;
 
-  bool matchOrShiftToFunnelShift(MachineInstr &MI, BuildFnTy &MatchInfo) const;
+  bool matchOrShiftToFunnelShift(MachineInstr &MI, bool ScalarConstantsAreLegal,
+                                 BuildFnTy &MatchInfo) const;
   bool matchFunnelShiftToRotate(MachineInstr &MI) const;
   void applyFunnelShiftToRotate(MachineInstr &MI) const;
   bool matchRotateOutOfRange(MachineInstr &MI) const;
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td b/llvm/include/llvm/Target/GlobalISel/Combine.td
index b619de39a8c75..c417da7c8b88f 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -1000,10 +1000,18 @@ def extract_vec_elt_combines : GICombineGroup<[
 def funnel_shift_from_or_shift : GICombineRule<
   (defs root:$root, build_fn_matchinfo:$info),
   (match (wip_match_opcode G_OR):$root,
-    [{ return Helper.matchOrShiftToFunnelShift(*${root}, ${info}); }]),
+    [{ return Helper.matchOrShiftToFunnelShift(*${root}, false, ${info}); }]),
   (apply [{ Helper.applyBuildFn(*${root}, ${info}); }])
 >;
 
+def funnel_shift_from_or_shift_constants_are_legal : GICombineRule<
+  (defs root:$root, build_fn_matchinfo:$info),
+  (match (wip_match_opcode G_OR):$root,
+    [{ return Helper.matchOrShiftToFunnelShift(*${root}, true, ${info}); }]),
+  (apply [{ Helper.applyBuildFn(*${root}, ${info}); }])
+>;
+
+
 def funnel_shift_to_rotate : GICombineRule<
   (defs root:$root),
   (match (wip_match_opcode G_FSHL, G_FSHR):$root,
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index e84ba91c47c8b..80a58b0bf2858 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -4390,6 +4390,7 @@ void CombinerHelper::applyBuildFnNoErase(
 }
 
 bool CombinerHelper::matchOrShiftToFunnelShift(MachineInstr &MI,
+                                               bool ScalarConstantsAreLegal,
                                                BuildFnTy &MatchInfo) const {
   assert(MI.getOpcode() == TargetOpcode::G_OR);
 
@@ -4409,31 +4410,29 @@ bool CombinerHelper::matchOrShiftToFunnelShift(MachineInstr &MI,
 
   // Given constants C0 and C1 such that C0 + C1 is bit-width:
   // (or (shl x, C0), (lshr y, C1)) -> (fshl x, y, C0) or (fshr x, y, C1)
-  int64_t CstShlAmt, CstLShrAmt;
+  int64_t CstShlAmt = 0, CstLShrAmt;
   if (mi_match(ShlAmt, MRI, m_ICstOrSplat(CstShlAmt)) &&
       mi_match(LShrAmt, MRI, m_ICstOrSplat(CstLShrAmt)) &&
       CstShlAmt + CstLShrAmt == BitWidth) {
     FshOpc = TargetOpcode::G_FSHR;
     Amt = LShrAmt;
-
   } else if (mi_match(LShrAmt, MRI,
                       m_GSub(m_SpecificICstOrSplat(BitWidth), m_Reg(Amt))) &&
              ShlAmt == Amt) {
     // (or (shl x, amt), (lshr y, (sub bw, amt))) -> (fshl x, y, amt)
     FshOpc = TargetOpcode::G_FSHL;
-
   } else if (mi_match(ShlAmt, MRI,
                       m_GSub(m_SpecificICstOrSplat(BitWidth), m_Reg(Amt))) &&
              LShrAmt == Amt) {
     // (or (shl x, (sub bw, amt)), (lshr y, amt)) -> (fshr x, y, amt)
     FshOpc = TargetOpcode::G_FSHR;
-
   } else {
     return false;
   }
 
   LLT AmtTy = MRI.getType(Amt);
-  if (!isLegalOrBeforeLegalizer({FshOpc, {Ty, AmtTy}}))
+  if (!isLegalOrBeforeLegalizer({FshOpc, {Ty, AmtTy}}) &&
+      (!ScalarConstantsAreLegal || CstShlAmt == 0 || !Ty.isScalar()))
     return false;
 
   MatchInfo = [=](MachineIRBuilder &B) {
diff --git a/llvm/lib/Target/AArch64/AArch64Combine.td b/llvm/lib/Target/AArch64/AArch64Combine.td
index 99f0af5f6a3f8..81de366c32e72 100644
--- a/llvm/lib/Target/AArch64/AArch64Combine.td
+++ b/llvm/lib/Target/AArch64/AArch64Combine.td
@@ -367,5 +367,6 @@ def AArch64PostLegalizerCombiner
                         select_to_minmax, or_to_bsp, combine_concat_vector,
                         commute_constant_to_rhs, extract_vec_elt_combines,
                         push_freeze_to_prevent_poison_from_propagating,
-                        combine_mul_cmlt, combine_use_vector_truncate, extmultomull]> {
+                        combine_mul_cmlt, combine_use_vector_truncate, extmultomull,
+                        funnel_shift_from_or_shift_constants_are_legal]> {
 }
diff --git a/llvm/test/CodeGen/AArch64/adc.ll b/llvm/test/CodeGen/AArch64/adc.ll
index 12e8bf26c9eac..03f3cf192102d 100644
--- a/llvm/test/CodeGen/AArch64/adc.ll
+++ b/llvm/test/CodeGen/AArch64/adc.ll
@@ -71,9 +71,8 @@ define i128 @test_shifted(i128 %a, i128 %b) {
 ;
 ; CHECK-GI-LABEL: test_shifted:
 ; CHECK-GI:       ; %bb.0:
-; CHECK-GI-NEXT:    lsr x8, x2, #19
+; CHECK-GI-NEXT:    extr x8, x3, x2, #19
 ; CHECK-GI-NEXT:    adds x0, x0, x2, lsl #45
-; CHECK-GI-NEXT:    orr x8, x8, x3, lsl #45
 ; CHECK-GI-NEXT:    adc x1, x1, x8
 ; CHECK-GI-NEXT:    ret
   %rhs = shl i128 %b, 45
@@ -108,8 +107,7 @@ define i128 @test_extended(i128 %a, i16 %b) {
 ; CHECK-GI-NEXT:    sxth x8, w2
 ; CHECK-GI-NEXT:    adds x0, x0, w2, sxth #3
 ; CHECK-GI-NEXT:    asr x9, x8, #63
-; CHECK-GI-NEXT:    lsr x8, x8, #61
-; CHECK-GI-NEXT:    orr x8, x8, x9, lsl #3
+; CHECK-GI-NEXT:    extr x8, x9, x8, #61
 ; CHECK-GI-NEXT:    adc x1, x1, x8
 ; CHECK-GI-NEXT:    ret
   %ext = sext i16 %b to i128
diff --git a/llvm/test/CodeGen/AArch64/fsh.ll b/llvm/test/CodeGen/AArch64/fsh.ll
index 4c28c90824028..9eb2e3de2b2b6 100644
--- a/llvm/test/CodeGen/AArch64/fsh.ll
+++ b/llvm/test/CodeGen/AArch64/fsh.ll
@@ -510,41 +510,40 @@ define i128 @fshl_i128(i128 %a, i128 %b, i128 %c) {
 ;
 ; CHECK-GI-LABEL: fshl_i128:
 ; CHECK-GI:       // %bb.0: // %entry
+; CHECK-GI-NEXT:    mov w8, #64 // =0x40
 ; CHECK-GI-NEXT:    and x9, x4, #0x7f
-; CHECK-GI-NEXT:    mov w10, #64 // =0x40
-; CHECK-GI-NEXT:    lsl x14, x3, #63
-; CHECK-GI-NEXT:    sub x12, x10, x9
+; CHECK-GI-NEXT:    mov w10, #127 // =0x7f
+; CHECK-GI-NEXT:    sub x12, x8, x9
 ; CHECK-GI-NEXT:    lsl x13, x1, x9
-; CHECK-GI-NEXT:    mov w8, #127 // =0x7f
+; CHECK-GI-NEXT:    bic x10, x10, x4
 ; CHECK-GI-NEXT:    lsr x12, x0, x12
-; CHECK-GI-NEXT:    bic x8, x8, x4
-; CHECK-GI-NEXT:    sub x15, x9, #64
+; CHECK-GI-NEXT:    sub x14, x9, #64
+; CHECK-GI-NEXT:    lsl x15, x0, x9
+; CHECK-GI-NEXT:    extr x16, x3, x2, #1
 ; CHECK-GI-NEXT:    cmp x9, #64
-; CHECK-GI-NEXT:    lsl x9, x0, x9
-; CHECK-GI-NEXT:    lsl x15, x0, x15
-; CHECK-GI-NEXT:    orr x12, x12, x13
-; CHECK-GI-NEXT:    orr x13, x14, x2, lsr #1
-; CHECK-GI-NEXT:    lsr x14, x3, #1
-; CHECK-GI-NEXT:    sub x10, x10, x8
-; CHECK-GI-NEXT:    sub x16, x8, #64
-; CHECK-GI-NEXT:    csel x9, x9, xzr, lo
-; CHECK-GI-NEXT:    lsr x17, x13, x8
-; CHECK-GI-NEXT:    lsl x10, x14, x10
-; CHECK-GI-NEXT:    csel x12, x12, x15, lo
+; CHECK-GI-NEXT:    sub x8, x8, x10
+; CHECK-GI-NEXT:    orr x9, x12, x13
+; CHECK-GI-NEXT:    lsr x12, x3, #1
+; CHECK-GI-NEXT:    lsl x13, x0, x14
+; CHECK-GI-NEXT:    csel x14, x15, xzr, lo
+; CHECK-GI-NEXT:    sub x15, x10, #64
+; CHECK-GI-NEXT:    lsr x17, x16, x10
+; CHECK-GI-NEXT:    lsl x8, x12, x8
+; CHECK-GI-NEXT:    csel x9, x9, x13, lo
 ; CHECK-GI-NEXT:    tst x4, #0x7f
-; CHECK-GI-NEXT:    lsr x15, x14, x16
+; CHECK-GI-NEXT:    lsr x13, x12, x15
 ; CHECK-GI-NEXT:    mvn x11, x4
-; CHECK-GI-NEXT:    csel x12, x1, x12, eq
-; CHECK-GI-NEXT:    orr x10, x17, x10
-; CHECK-GI-NEXT:    cmp x8, #64
-; CHECK-GI-NEXT:    lsr x14, x14, x8
-; CHECK-GI-NEXT:    csel x10, x10, x15, lo
+; CHECK-GI-NEXT:    csel x9, x1, x9, eq
+; CHECK-GI-NEXT:    orr x8, x17, x8
+; CHECK-GI-NEXT:    cmp x10, #64
+; CHECK-GI-NEXT:    lsr x12, x12, x10
+; CHECK-GI-NEXT:    csel x8, x8, x13, lo
 ; CHECK-GI-NEXT:    tst x11, #0x7f
-; CHECK-GI-NEXT:    csel x10, x13, x10, eq
-; CHECK-GI-NEXT:    cmp x8, #64
-; CHECK-GI-NEXT:    csel x8, x14, xzr, lo
-; CHECK-GI-NEXT:    orr x0, x9, x10
-; CHECK-GI-NEXT:    orr x1, x12, x8
+; CHECK-GI-NEXT:    csel x8, x16, x8, eq
+; CHECK-GI-NEXT:    cmp x10, #64
+; CHECK-GI-NEXT:    csel x10, x12, xzr, lo
+; CHECK-GI-NEXT:    orr x0, x14, x8
+; CHECK-GI-NEXT:    orr x1, x9, x10
 ; CHECK-GI-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshl(i128 %a, i128 %b, i128 %c)
@@ -571,41 +570,40 @@ define i128 @fshr_i128(i128 %a, i128 %b, i128 %c) {
 ;
 ; CHECK-GI-LABEL: fshr_i128:
 ; CHECK-GI:       // %bb.0: // %entry
-; CHECK-GI-NEXT:    lsr x8, x0, #63
-; CHECK-GI-NEXT:    mov w9, #127 // =0x7f
-; CHECK-GI-NEXT:    mov w10, #64 // =0x40
-; CHECK-GI-NEXT:    bic x9, x9, x4
-; CHECK-GI-NEXT:    lsl x11, x0, #1
-; CHECK-GI-NEXT:    and x12, x4, #0x7f
-; CHECK-GI-NEXT:    orr x8, x8, x1, lsl #1
-; CHECK-GI-NEXT:    sub x14, x10, x9
-; CHECK-GI-NEXT:    sub x17, x9, #64
-; CHECK-GI-NEXT:    lsl x15, x11, x9
-; CHECK-GI-NEXT:    lsr x14, x11, x14
-; CHECK-GI-NEXT:    cmp x9, #64
-; CHECK-GI-NEXT:    lsl x16, x8, x9
-; CHECK-GI-NEXT:    sub x9, x10, x12
-; CHECK-GI-NEXT:    lsl x10, x11, x17
-; CHECK-GI-NEXT:    mvn x13, x4
-; CHECK-GI-NEXT:    csel x11, x15, xzr, lo
-; CHECK-GI-NEXT:    sub x15, x12, #64
-; CHECK-GI-NEXT:    orr x14, x14, x16
-; CHECK-GI-NEXT:    lsr x16, x2, x12
-; CHECK-GI-NEXT:    lsl x9, x3, x9
-; CHECK-GI-NEXT:    csel x10, x14, x10, lo
-; CHECK-GI-NEXT:    tst x13, #0x7f
-; CHECK-GI-NEXT:    lsr x13, x3, x15
-; CHECK-GI-NEXT:    csel x8, x8, x10, eq
-; CHECK-GI-NEXT:    orr x9, x16, x9
-; CHECK-GI-NEXT:    cmp x12, #64
-; CHECK-GI-NEXT:    lsr x10, x3, x12
-; CHECK-GI-NEXT:    csel x9, x9, x13, lo
+; CHECK-GI-NEXT:    mov w8, #127 // =0x7f
+; CHECK-GI-NEXT:    lsl x9, x0, #1
+; CHECK-GI-NEXT:    extr x10, x1, x0, #63
+; CHECK-GI-NEXT:    bic x8, x8, x4
+; CHECK-GI-NEXT:    mov w11, #64 // =0x40
+; CHECK-GI-NEXT:    and x14, x4, #0x7f
+; CHECK-GI-NEXT:    sub x12, x11, x8
+; CHECK-GI-NEXT:    lsl x13, x10, x8
+; CHECK-GI-NEXT:    lsl x16, x9, x8
+; CHECK-GI-NEXT:    lsr x12, x9, x12
+; CHECK-GI-NEXT:    sub x17, x8, #64
+; CHECK-GI-NEXT:    cmp x8, #64
+; CHECK-GI-NEXT:    lsl x8, x9, x17
+; CHECK-GI-NEXT:    sub x11, x11, x14
+; CHECK-GI-NEXT:    mvn x15, x4
+; CHECK-GI-NEXT:    orr x12, x12, x13
+; CHECK-GI-NEXT:    csel x9, x16, xzr, lo
+; CHECK-GI-NEXT:    sub x13, x14, #64
+; CHECK-GI-NEXT:    lsr x16, x2, x14
+; CHECK-GI-NEXT:    lsl x11, x3, x11
+; CHECK-GI-NEXT:    csel x8, x12, x8, lo
+; CHECK-GI-NEXT:    tst x15, #0x7f
+; CHECK-GI-NEXT:    lsr x12, x3, x13
+; CHECK-GI-NEXT:    csel x8, x10, x8, eq
+; CHECK-GI-NEXT:    orr x10, x16, x11
+; CHECK-GI-NEXT:    cmp x14, #64
+; CHECK-GI-NEXT:    lsr x11, x3, x14
+; CHECK-GI-NEXT:    csel x10, x10, x12, lo
 ; CHECK-GI-NEXT:    tst x4, #0x7f
-; CHECK-GI-NEXT:    csel x9, x2, x9, eq
-; CHECK-GI-NEXT:    cmp x12, #64
-; CHECK-GI-NEXT:    csel x10, x10, xzr, lo
-; CHECK-GI-NEXT:    orr x0, x11, x9
-; CHECK-GI-NEXT:    orr x1, x8, x10
+; CHECK-GI-NEXT:    csel x10, x2, x10, eq
+; CHECK-GI-NEXT:    cmp x14, #64
+; CHECK-GI-NEXT:    csel x11, x11, xzr, lo
+; CHECK-GI-NEXT:    orr x0, x9, x10
+; CHECK-GI-NEXT:    orr x1, x8, x11
 ; CHECK-GI-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshr(i128 %a, i128 %b, i128 %c)
@@ -720,10 +718,9 @@ define i128 @rotl_i128_c(i128 %a) {
 ;
 ; CHECK-GI-LABEL: rotl_i128_c:
 ; CHECK-GI:       // %bb.0: // %entry
-; CHECK-GI-NEXT:    lsr x8, x0, #61
-; CHECK-GI-NEXT:    lsr x9, x1, #61
-; CHECK-GI-NEXT:    orr x1, x8, x1, lsl #3
-; CHECK-GI-NEXT:    orr x0, x9, x0, lsl #3
+; CHECK-GI-NEXT:    extr x8, x1, x0, #61
+; CHECK-GI-NEXT:    extr x0, x0, x1, #61
+; CHECK-GI-NEXT:    mov x1, x8
 ; CHECK-GI-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshl(i128 %a, i128 %a, i128 3)
@@ -731,20 +728,12 @@ entry:
 }
 
 define i128 @rotr_i128_c(i128 %a) {
-; CHECK-SD-LABEL: rotr_i128_c:
-; CHECK-SD:       // %bb.0: // %entry
-; CHECK-SD-NEXT:    extr x8, x1, x0, #3
-; CHECK-SD-NEXT:    extr x1, x0, x1, #3
-; CHECK-SD-NEXT:    mov x0, x8
-; CHECK-SD-NEXT:    ret
-;
-; CHECK-GI-LABEL: rotr_i128_c:
-; CHECK-GI:       // %bb.0: // %entry
-; CHECK-GI-NEXT:    lsl x8, x1, #61
-; CHECK-GI-NEXT:    lsl x9, x0, #61
-; CHECK-GI-NEXT:    orr x0, x8, x0, lsr #3
-; CHECK-GI-NEXT:    orr x1, x9, x1, lsr #3
-; CHECK-GI-NEXT:    ret
+; CHECK-LABEL: rotr_i128_c:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    extr x8, x1, x0, #3
+; CHECK-NEXT:    extr x1, x0, x1, #3
+; CHECK-NEXT:    mov x0, x8
+; CHECK-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshr(i128 %a, i128 %a, i128 3)
   ret i128 %d
@@ -868,10 +857,8 @@ define i128 @fshl_i128_c(i128 %a, i128 %b) {
 ;
 ; CHECK-GI-LABEL: fshl_i128_c:
 ; CHECK-GI:       // %bb.0: // %entry
-; CHECK-GI-NEXT:    lsr x8, x0, #61
-; CHECK-GI-NEXT:    lsr x9, x3, #61
-; CHECK-GI-NEXT:    orr x1, x8, x1, lsl #3
-; CHECK-GI-NEXT:    orr x0, x9, x0, lsl #3
+; CHECK-GI-NEXT:    extr x1, x1, x0, #61
+; CHECK-GI-NEXT:    extr x0, x0, x3, #61
 ; CHECK-GI-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshl(i128 %a, i128 %b, i128 3)
@@ -879,21 +866,12 @@ entry:
 }
 
 define i128 @fshr_i128_c(i128 %a, i128 %b) {
-; CHECK-SD-LABEL: fshr_i128_c:
-; CHECK-SD:       // %bb.0: // %entry
-; CHECK-SD-NEXT:    extr x8, x3, x2, #3
-; CHECK-SD-NEXT:    extr x1, x0, x3, #3
-; CHECK-SD-NEXT:    mov x0, x8
-; CHECK-SD-NEXT:    ret
-;
-; CHECK-GI-LABEL: fshr_i128_c:
-; CHECK-GI:       // %bb.0: // %entry
-; CHECK-GI-NEXT:    lsl x8, x3, #61
-; CHECK-GI-NEXT:    lsr x9, x3, #3
-; CHECK-GI-NEXT:    orr x8, x8, x2, lsr #3
-; CHECK-GI-NEXT:    orr x1, x9, x0, lsl #61
-; CHECK-GI-NEXT:    mov x0, x8
-; CHECK-GI-NEXT:    ret
+; CHECK-LABEL: fshr_i128_c:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    extr x8, x3, x2, #3
+; CHECK-NEXT:    extr x1, x0, x3, #3
+; CHECK-NEXT:    mov x0, x8
+; CHECK-NEXT:    ret
 entry:
   %d = call i128 @llvm.fshr(i128 %a, i128 %b, i128 3)
   ret i128 %d
@@ -3012,75 +2990,73 @@ define <2 x i128> @fshl_v2i128(<2 x i128> %a, <2 x i128> %b, <2 x i128> %c) {
 ; CHECK-GI-NEXT:    .cfi_def_cfa_offset 16
 ; CHECK-GI-NEXT:    .cfi_offset w19, -16
 ; CHECK-GI-NEXT:    ldr x11, [sp, #16]
-; CHECK-GI-NEXT:    mov w10, #64 // =0x40
+; CHECK-GI-NEXT:    mov w9, #64 // =0x40
 ; CHECK-GI-NEXT:    ldr x12, [sp, #32]
 ; CHECK-GI-NEXT:    mov w13, #127 // =0x7f
-; CHECK-GI-NEXT:    and x9, x11, #0x7f
+; CHECK-GI-NEXT:    and x8, x11, #0x7f
 ; CHECK-GI-NEXT:    and x14, x12, #0x7f
-; CHECK-GI-NEXT:    mvn x15, x11
-; CHECK-GI-NEXT:    sub x8, x10, x9
-; CHECK-GI-NEXT:    sub x16, x9, #64
-; CHECK-GI-NEXT:    lsl x19, x1, x9
-; CHECK-GI-NEXT:    lsr x18, x0, x8
-; CHECK-GI-NEXT:    lsl x17, x0, x9
-; CHECK-GI-NEXT:    lsl x16, x0, x16
-; CHECK-GI-NEXT:    cmp x9, #64
-; CHECK-GI-NEXT:    bic x0, x13, x11
-; CHECK-GI-NEXT:    mvn x8, x12
-; CHECK-GI-NEXT:    orr x18, x18, x19
-; CHECK-GI-NEXT:    csel x9, x17, xzr, lo
+; CHECK-GI-NEXT:    mvn x18, x11
+; CHECK-GI-NEXT:    sub x10, x9, x8
+; CHECK-GI-NEXT:    sub x15, x8, #64
+; CHECK-GI-NEXT:    lsl x17, x1, x8
+; CHECK-GI-NEXT:    lsr x16, x0, x10
+; CHECK-GI-NEXT:    lsl x15, x0, x15
+; CHECK-GI-NEXT:    cmp x8, #64
+; CHECK-GI-NEXT:    lsl x19, x0, x8
+; CHECK-GI-NEXT:    lsl x0, x3, x14
+; CHECK-GI-NEXT:    mvn x10, x12
+; CHECK-GI-NEXT:    orr x16, x16, x17
 ; CHECK-GI-NEXT:    sub x17, x14, #64
-; CHECK-GI-NEXT:    csel x16, x18, x16, lo
+; CHECK-GI-NEXT:    csel x15, x16, x15, lo
+; CHECK-GI-NEXT:    sub x16, x9, x14
+; CHECK-GI-NEXT:    csel x8, x19, xzr, lo
+; CHECK-GI-NEXT:    lsr x16, x2, x16
 ; CHECK-GI-NEXT:    tst x11, #0x7f
-; CHECK-GI-NEXT:    sub x11, x10, x14
-; CHECK-GI-NEXT:    lsr x11, x2, x11
-; CHECK-GI-NEXT:    lsl x18, x3, x14
-; CHECK-GI-NEXT:    csel x16, x1, x16, eq
-; CHECK-GI-NEXT:    lsl x1, x2, x14
+; CHECK-GI-NEXT:    lsl x19, x2, x14
 ; CHECK-GI-NEXT:    lsl x17, x2, x17
+; CHECK-GI-NEXT:    csel x15, x1, x15, eq
 ; CHECK-GI-NEXT:    cmp x14, #64
-; CHECK-GI-NEXT:    lsl x14, x5, #63
-; CHECK-GI-NEXT:    orr x11, x11, x18
-; CHECK-GI-NEXT:    bic x13, x13, x12
-; CHECK-GI-NEXT:    csel x18, x1, xzr, lo
-; CHECK-GI-NEXT:    csel x11, x11, x17, lo
+; CHECK-GI-NEXT:    orr x16, x16, x0
+; CHECK-GI-NEXT:    bic x11, x13, x11
+; CHECK-GI-NEXT:    csel x14, x19, xzr, lo
+; CHECK-GI-NEXT:    csel x16, x16, x17, lo
 ; CHECK-GI-NEXT:    tst x12, #0x7f
-; CHECK-GI-NEXT:    lsr x12, x5, #1
-; CHECK-GI-NEXT:    orr x14, x14, x4, lsr #1
-; CHECK-GI-NEXT:    lsl x17, x7, #63
-; CHECK-GI-NEXT:    sub x1, x10, x0
-; CHECK-GI-NEXT:    csel x11, x3, x11, eq
-; CHECK-GI-NEXT:    sub x2, x0, #64
-; CHECK-GI-NEXT:    lsr x3, x14, x0
-; CHECK-GI-NEXT:    lsl x1, x12, x1
-; CHECK-GI-NEXT:    lsr x4, x7, #1
-; CHECK-GI-NEXT:    orr x17, x17, x6, lsr #1
-; CHECK-GI-NEXT:    lsr x2, x12, x2
-; CHECK-GI-NEXT:    cmp x0, #64
-; CHECK-GI-NEXT:    orr x1, x3, x1
-; CHECK-GI-NEXT:    sub x10, x10, x13
-; CHECK-GI-NEXT:    lsr x12, x12, x0
-; CHECK-GI-NEXT:    csel x1, x1, x2, lo
-; CHECK-GI-NEXT:    tst x15, #0x7f
-; CHECK-GI-NEXT:    sub x15, x13, #64
-; CHECK-GI-NEXT:    lsr x2, x17, x13
-; CHECK-GI-NEXT:    lsl x10, x4, x10
-; CHECK-GI-NEXT:    csel x14, x14, x1, eq
-; CHECK-GI-NEXT:    cmp x0, #64
-; CHECK-GI-NEXT:    lsr x15, x4, x15
-; CHECK-GI-NEXT:    lsr x0, x4, x13
-; CHECK-GI-NEXT:    csel x12, x12, xzr, lo
-; CHECK-GI-NEXT:    orr x10, x2, x10
-; CHECK-GI-NEXT:    cmp x13, #64
-; CHECK-GI-NEXT:    csel x10, x10, x15, lo
-; CHECK-GI-NEXT:    tst x8, #0x7f
-; CHECK-GI-NEXT:    orr x1, x16, x12
-; CHECK-GI-NEXT:    csel x8, x17, x10, eq
-; CHECK-GI-NEXT:    cmp x13, #64
-; CHECK-GI-NEXT:    csel x10, x0, xzr, lo
-; CHECK-GI-NEXT:    orr x0, x9, x14
-; CHECK-GI-NEXT:    orr x2, x18, x8
-; CHECK-GI-NEXT:    orr x3, x11, x10
+; CHECK-GI-NEXT:    lsr x17, x5, #1
+; CHECK-GI-NEXT:    extr x0, x5, x4, #1
+; CHECK-GI-NEXT:    bic x12, x13, x12
+; CHECK-GI-NEXT:    csel x13, x3, x16, eq
+; CHECK-GI-NEXT:    sub x16, x9, x11
+; CHECK-GI-NEXT:    sub x1, x11, #64
+; CHECK-GI-NEXT:    lsr x3, x7, #1
+; CHECK-GI-NEXT:    lsr x2, x0, x11
+; CHECK-GI-NEXT:    lsl x16, x17, x16
+; CHECK-GI-NEXT:    extr x4, x7, x6, #1
+; CHECK-GI-NEXT:    lsr x1, x17, x1
+; CHECK-GI-NEXT:    cmp x11, #64
+; CHECK-GI-NEXT:    sub x9, x9, x12
+; CHECK-GI-NEXT:    orr x16, x2, x16
+; CHECK-GI-NEXT:    lsr x17, x17, x11
+; CHECK-GI-NEXT:    lsl x9, x3, x9
+; CHECK-GI-NEXT:    csel x16, x16, x1, lo
+; CHECK-GI-NEXT:    tst x18, #0x7f
+; CHECK-GI-NEXT:    sub x18, x12, #64
+; CHECK-GI-NEXT:    lsr x1, x4, x12
+; CHECK-GI-NEXT:    csel x16, x0, x16, eq
+; CHECK-GI-NEXT:    cmp x11, #64
+; CHECK-GI-NEXT:    lsr x11, x3, x18
+; CHECK-GI-NEXT:    csel x17, x17, xzr, lo
+; CHECK-GI-NEXT:    cmp x12, #64
+; CHECK-GI-NEXT:    orr x9, x1, x9
+; CHECK-GI-NEXT:    lsr x18, x3, x12
+; CHECK-GI-NEXT:    orr x0, x8, x16
+; CHECK-GI-NEXT:    csel x9, x9, x11, lo
+; CHECK-GI-NEXT:    tst x10, #0x7f
+; CHECK-GI-NEXT:    orr x1, x15, x17
+; CHECK-GI-NEXT:    csel x9, x4, x9, eq
+; CHECK-GI-NEXT:    cmp x12, #64
+; CHECK-GI-NEXT:    csel x10, x18, xzr, lo
+; CHECK-GI-NEXT:    orr x2, x14, x9
+; CHECK-GI-NEXT:    orr x3, x13, x10
 ; CHECK-GI-NEXT:    ldr x19, [sp], #16 // 8-byte Folded Reload
 ; CHECK-GI-NEXT:    ret
 entry:
@@ -3124,75 +3100,73 @@ define <2 x i128> @fshr_v2i128(<2 x i128> %a, <2 x i128> %b, <2 x i128> %c) {
 ; CHECK-GI-LABEL: fshr_v2i128:
 ; CHECK-GI:       // %bb.0: // %entry
 ; CHECK-GI-NEXT:    ldr x9, [sp]
-; CHECK-GI-NEXT:    lsl x12, x1, #1
-; CHECK-GI-NEXT:    mov w11, #127 // =0x7f
-; CHECK-GI-NEXT:    mov w14, #64 // =0x40
-; CHECK-GI-NEXT:    lsl x15, x0, #1
+; CHECK-GI-NEXT:    mov w10, #127 // =0x7f
+; CHECK-GI-NEXT:    mov w12, #64 // =0x40
+; CHECK-GI-NEXT:    lsl x13, x0, #1
+; CHECK-GI-NEXT:    extr x14, x1, x0, #63
 ; CHECK-GI-NEXT:    ldr x8, [sp, #16]
-; CHECK-GI-NEXT:    bic x13, x11, x9
-; CHECK-GI-NEXT:    orr x12, x12, x0, lsr #63
-; CHECK-GI-NEXT:    lsl x1, x3, #1
-; CHECK-GI-NEXT:    sub x17, x14, x13
-; CHECK-GI-NEXT:    sub x18, x13, #64
-; CHECK-GI-NEXT:    lsl x3, x15, x13
-; CHECK-GI-NEXT:    lsr x17, x15, x17
-; CHECK-GI-NEXT:    lsl x0, x12, x13
-; CHECK-GI-NEXT:    lsl x15, x15, x18
-; CHECK-GI-NEXT:    bic x11, x11, x8
+; CHECK-GI-NEXT:    bic x11, x10, x9
+; CHECK-GI-NEXT:    mvn x16, x9
+; CHECK-GI-NEXT:    and x15, x9, #0x7f
+; CHECK-GI-NEXT:    sub x17, x12, x11
+; CHECK-GI-NEXT:    sub x18, x11, #64
+; CHECK-GI-NEXT:    lsl x0, x14, x11
+; ...
[truncated]

@aemerson
Copy link
Contributor

I looked at this last week but felt uneasy about the legality issue. Having had some time to think about it, I don't have a better suggestion for the implementation. However, what do you think about calling this something other than "legal". Instead something like AllowScalarConstants so we don't confuse the GlobalISel definition of legality with what we're doing here.

…ine.

We want to be able to produce extr instructions post-legalization. They are
legal for scalars, acting as a funnel shifts with a constant shift amount.
Unfortunately I'm not sure if there is a way currently to represent that in the
legalization rules, but it might be useful for several operations - to be able
to treat and test operands with constant operands as legal or not.

This adds a change to the existing matchOrShiftToFunnelShift so that AArch64
can generate such instructions post-legalization providing that the operation
is scalar and the shift amount is constant. It doesn't feel like the best
solution - any thoughts on alternatives?
@davemgreen
Copy link
Collaborator Author

I was wondering whether it would be useful to extend the concept of legality in a few cases beyond just type info to include things like whether an operand is constant and what the constant is. I think this would be more useful to us for shift-like-operations, which might be legal for certain constants, but not in general. It would allow us to write generic post-legalizer combines that we know kept operations legal. The shifts are:
G_SHL, G_ASHR, G_LSHR, G_FSHL, G_FSHR, G_ROTR, G_ROTL
There are also:
G_EXTRACT_VECTOR_ELT/G_INSERT_VECTOR_ELT whether the index is constant.
LOAD/STORE mem operand types.
G_SBFX, G_UBFX?
G_SHUFFLE_VECTOR based on shuffle masks?
G_EXTRACT_SUBVECTOR based on index?
G_SEXT_INREG based on the extend typesize.
G_FPTOSI_SAT, G_FPTOUI_SAT if it needed a separate saturate vs result type (we don't have that in gisel at the moment).
G_CONSTANT, G_FCONSTANT possibly dependant immediate operand value (we can just handle all constants late, which can be a better approach).
G_MEMSET/G_MEMCPY/G_MEMMOVE could be legal if we have MOPS and the size is small enough.
G_VSCALE should be dependant on the scale operand.

So not the most opcodes and some of them might not be useful, but maybe worth considering.

@davemgreen davemgreen force-pushed the gh-gi-extrpostlegalize branch from b5c4524 to f7b34e7 Compare October 24, 2025 08:35
@aemerson
Copy link
Contributor

That would be a nice capability to have. We should probably have this discussion on an RFC, but my main concern right now is that we'd need to be resilient if the constant was obscured somehow; and that the resiliency would add complexity that nets us little benefit in the end.

There's maybe some other alternatives, like having specialized opcodes that encode the constant as an operand instead of a reg.

@davemgreen davemgreen merged commit da15b8f into llvm:main Oct 29, 2025
10 checks passed
@davemgreen davemgreen deleted the gh-gi-extrpostlegalize branch October 29, 2025 07:47
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 29, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux running on systemz-1 while building llvm at step 4 "build stage 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/42/builds/6743

Here is the relevant piece of the build log for the reference
Step 4 (build stage 1) failure: 'ninja -j4' (failure)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 29, 2025

LLVM Buildbot has detected a new failure on builder clang-x64-windows-msvc running on windows-gcebot2 while building llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/63/builds/11560

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/clang-windows.py ...' (failure)
...
[36/268] Linking CXX executable bin\llvm-offload-wrapper.exe
[37/268] Building CXX object tools\lld\Common\CMakeFiles\lldCommon.dir\Version.cpp.obj
[38/268] Linking CXX static library lib\lldCommon.lib
[39/268] Linking CXX executable bin\clang-offload-bundler.exe
[40/268] Linking CXX static library lib\clangTidy.lib
[41/268] Generating ../../bin/clang-offload-packager.exe
[42/268] Building CXX object tools\clang\tools\extra\clang-tidy\tool\CMakeFiles\obj.clangTidyMain.dir\ClangTidyMain.cpp.obj
[43/268] Linking CXX executable bin\clang-apply-replacements.exe
[44/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperArtifacts.cpp.obj
[45/268] Building CXX object lib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\GISel\RISCVPreLegalizerCombiner.cpp.obj
FAILED: lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\RISCV -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\GISel\RISCVPreLegalizerCombiner.cpp.obj /Fdlib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\LLVMRISCVCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\RISCV\GISel\RISCVPreLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): note: Expressions of type void cannot be converted to other types
[46/268] Building AArch64GenDAGISel.inc...
[47/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperVectorOps.cpp.obj
[48/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperCasts.cpp.obj
[49/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperCompares.cpp.obj
[50/268] Building CXX object tools\clang\tools\extra\clang-tidy\utils\CMakeFiles\obj.clangTidyUtils.dir\FixItHintUtils.cpp.obj
[51/268] Building CXX object lib\Target\Mips\CMakeFiles\LLVMMipsCodeGen.dir\MipsPreLegalizerCombiner.cpp.obj
[52/268] Linking CXX executable bin\diagtool.exe
[53/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPreLegalizerCombiner.cpp.obj
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPreLegalizerCombiner.cpp.obj /Fdlib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\LLVMAMDGPUCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU\AMDGPUPreLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): note: Expressions of type void cannot be converted to other types
[54/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPostLegalizerCombiner.cpp.obj
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPostLegalizerCombiner.cpp.obj /Fdlib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\LLVMAMDGPUCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU\AMDGPUPostLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): note: Expressions of type void cannot be converted to other types
[55/268] Linking CXX executable bin\clang-diff.exe
[56/268] Linking CXX executable bin\modularize.exe
[57/268] Linking CXX executable bin\clang-installapi.exe
[58/268] Linking CXX executable bin\clang-reorder-fields.exe
[59/268] Linking CXX executable bin\clang-refactor.exe
[60/268] Linking CXX executable bin\clang-include-cleaner.exe
[61/268] Linking CXX executable bin\clang-doc.exe
[62/268] Linking CXX executable bin\clang-change-namespace.exe
[63/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUCombinerHelper.cpp.obj
Step 7 (stage 1 build) failure: stage 1 build (failure)
...
[36/268] Linking CXX executable bin\llvm-offload-wrapper.exe
[37/268] Building CXX object tools\lld\Common\CMakeFiles\lldCommon.dir\Version.cpp.obj
[38/268] Linking CXX static library lib\lldCommon.lib
[39/268] Linking CXX executable bin\clang-offload-bundler.exe
[40/268] Linking CXX static library lib\clangTidy.lib
[41/268] Generating ../../bin/clang-offload-packager.exe
[42/268] Building CXX object tools\clang\tools\extra\clang-tidy\tool\CMakeFiles\obj.clangTidyMain.dir\ClangTidyMain.cpp.obj
[43/268] Linking CXX executable bin\clang-apply-replacements.exe
[44/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperArtifacts.cpp.obj
[45/268] Building CXX object lib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\GISel\RISCVPreLegalizerCombiner.cpp.obj
FAILED: lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\RISCV -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\GISel\RISCVPreLegalizerCombiner.cpp.obj /Fdlib\Target\RISCV\CMakeFiles\LLVMRISCVCodeGen.dir\LLVMRISCVCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\RISCV\GISel\RISCVPreLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\RISCV\RISCVGenPreLegalizeGICombiner.inc(3027): note: Expressions of type void cannot be converted to other types
[46/268] Building AArch64GenDAGISel.inc...
[47/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperVectorOps.cpp.obj
[48/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperCasts.cpp.obj
[49/268] Building CXX object lib\CodeGen\GlobalISel\CMakeFiles\LLVMGlobalISel.dir\CombinerHelperCompares.cpp.obj
[50/268] Building CXX object tools\clang\tools\extra\clang-tidy\utils\CMakeFiles\obj.clangTidyUtils.dir\FixItHintUtils.cpp.obj
[51/268] Building CXX object lib\Target\Mips\CMakeFiles\LLVMMipsCodeGen.dir\MipsPreLegalizerCombiner.cpp.obj
[52/268] Linking CXX executable bin\diagtool.exe
[53/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPreLegalizerCombiner.cpp.obj
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPreLegalizerCombiner.cpp.obj /Fdlib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\LLVMAMDGPUCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU\AMDGPUPreLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPreLegalizeGICombiner.inc(3090): note: Expressions of type void cannot be converted to other types
[54/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPostLegalizerCombiner.cpp.obj
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.obj 
C:\PROGRA~2\MICROS~3\2019\PROFES~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU -IC:\b\slave\clang-x64-windows-msvc\build\stage1\include -IC:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -std:c++17 -MD  /EHs-c- /GR- /showIncludes /Folib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUPostLegalizerCombiner.cpp.obj /Fdlib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\LLVMAMDGPUCodeGen.pdb /FS -c C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\lib\Target\AMDGPU\AMDGPUPostLegalizerCombiner.cpp
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2660: 'llvm::CombinerHelper::matchOrShiftToFunnelShift': function does not take 2 arguments
C:\b\slave\clang-x64-windows-msvc\llvm-project\llvm\include\llvm/CodeGen/GlobalISel/CombinerHelper.h(643): note: see declaration of 'llvm::CombinerHelper::matchOrShiftToFunnelShift'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2171: '!': illegal on operands of type 'void'
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): error C2451: a conditional expression of type 'void' is not valid
C:\b\slave\clang-x64-windows-msvc\build\stage1\lib\Target\AMDGPU\AMDGPUGenPostLegalizeGICombiner.inc(3159): note: Expressions of type void cannot be converted to other types
[55/268] Linking CXX executable bin\clang-diff.exe
[56/268] Linking CXX executable bin\modularize.exe
[57/268] Linking CXX executable bin\clang-installapi.exe
[58/268] Linking CXX executable bin\clang-reorder-fields.exe
[59/268] Linking CXX executable bin\clang-refactor.exe
[60/268] Linking CXX executable bin\clang-include-cleaner.exe
[61/268] Linking CXX executable bin\clang-doc.exe
[62/268] Linking CXX executable bin\clang-change-namespace.exe
[63/268] Building CXX object lib\Target\AMDGPU\CMakeFiles\LLVMAMDGPUCodeGen.dir\AMDGPUCombinerHelper.cpp.obj

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 29, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building llvm at step 6 "build stage 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/5769

Here is the relevant piece of the build log for the reference
Step 6 (build stage 1) failure: 'ninja -j4' (failure)
...
[28/273] Building AArch64GenPostLegalizeGILowering.inc...
[29/273] Building AArch64GenSDNodeInfo.inc...
[30/273] Building AArch64GenPreLegalizeGICombiner.inc...
[31/273] Building AArch64GenRegisterBank.inc...
[32/273] Building AArch64GenRegisterInfo.inc...
[33/273] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
[34/273] Linking CXX static library lib/libLLVMLTO.a
[35/273] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUCombinerHelper.cpp.o
[36/273] Building AArch64GenSubtargetInfo.inc...
[37/194] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.o
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/include -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPostLegalizerCombiner.cpp.o -c /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp
In file included from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp:126:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc: In lambda function:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc:3159: error: no matching function for call to ‘llvm::AMDGPUCombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, std::function<void(llvm::MachineIRBuilder&)>&)’
 3159 |     if(![&](){return Helper.matchOrShiftToFunnelShift(*State.MIs[0], GIMatchData_info);}()) {
      | 
In file included from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h:20,
                 from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp:15:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note: candidate: ‘bool llvm::CombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, bool, llvm::BuildFnTy&) const’
  643 |   bool matchOrShiftToFunnelShift(MachineInstr &MI, bool AllowScalarConstants,
      | 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note:   candidate expects 3 arguments, 2 provided
[38/194] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.o
FAILED: lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/include -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.o -MF lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.o.d -o lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPUPreLegalizerCombiner.cpp.o -c /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp
In file included from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp:86:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc: In lambda function:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc:3090: error: no matching function for call to ‘llvm::AMDGPUCombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, std::function<void(llvm::MachineIRBuilder&)>&) const’
 3090 |     if(![&](){return Helper.matchOrShiftToFunnelShift(*State.MIs[0], GIMatchData_info);}()) {
      | 
In file included from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h:20,
                 from /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp:15:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note: candidate: ‘bool llvm::CombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, bool, llvm::BuildFnTy&) const’
  643 |   bool matchOrShiftToFunnelShift(MachineInstr &MI, bool AllowScalarConstants,
      | 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note:   candidate expects 3 arguments, 2 provided
[39/194] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/GISel/AArch64O0PreLegalizerCombiner.cpp.o
[40/194] Building CXX object lib/Target/AMDGPU/CMakeFiles/LLVMAMDGPUCodeGen.dir/AMDGPURegBankCombiner.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 29, 2025

LLVM Buildbot has detected a new failure on builder bolt-x86_64-ubuntu-nfc running on bolt-worker while building llvm at step 7 "build-bolt".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/92/builds/26461

Here is the relevant piece of the build log for the reference
Step 7 (build-bolt) failure: build (failure)
...
3.596 [89/13/23] Building AArch64GenRegisterInfo.inc...
3.853 [89/12/24] Building AArch64GenGlobalISel.inc...
4.399 [89/11/25] Building AArch64GenDAGISel.inc...
5.867 [89/10/26] Building CXX object lib/CodeGen/GlobalISel/CMakeFiles/LLVMGlobalISel.dir/CombinerHelperArtifacts.cpp.o
6.006 [89/9/27] Building CXX object lib/CodeGen/GlobalISel/CMakeFiles/LLVMGlobalISel.dir/CombinerHelperCompares.cpp.o
6.098 [89/8/28] Building CXX object lib/CodeGen/GlobalISel/CMakeFiles/LLVMGlobalISel.dir/CombinerHelperVectorOps.cpp.o
6.166 [89/7/29] Building CXX object lib/CodeGen/GlobalISel/CMakeFiles/LLVMGlobalISel.dir/CombinerHelperCasts.cpp.o
8.383 [89/6/30] Building AArch64GenSubtargetInfo.inc...
8.738 [89/5/31] Building AArch64GenInstrInfo.inc...
10.956 [6/8/32] Building CXX object lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.o
FAILED: lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.o 
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/lib/Target/RISCV -I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Target/RISCV -I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/include -I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.o -MF lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.o.d -o lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPreLegalizerCombiner.cpp.o -c /home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Target/RISCV/GISel/RISCVPreLegalizerCombiner.cpp
In file included from /home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Target/RISCV/GISel/RISCVPreLegalizerCombiner.cpp:66:
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/lib/Target/RISCV/RISCVGenPreLegalizeGICombiner.inc: In lambda function:
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/lib/Target/RISCV/RISCVGenPreLegalizeGICombiner.inc:3027: error: no matching function for call to ‘llvm::CombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, std::function<void(llvm::MachineIRBuilder&)>&) const’
 3027 |     if(![&](){return Helper.matchOrShiftToFunnelShift(*State.MIs[0], GIMatchData_info);}()) {
      | 
In file included from /home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Target/RISCV/GISel/RISCVPreLegalizerCombiner.cpp:17:
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note: candidate: ‘bool llvm::CombinerHelper::matchOrShiftToFunnelShift(llvm::MachineInstr&, bool, llvm::BuildFnTy&) const’
  643 |   bool matchOrShiftToFunnelShift(MachineInstr &MI, bool AllowScalarConstants,
      | 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h:643: note:   candidate expects 3 arguments, 2 provided
12.315 [6/7/33] Building CXX object lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVPostLegalizerCombiner.cpp.o
12.697 [6/6/34] Building CXX object lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVO0PreLegalizerCombiner.cpp.o
14.613 [6/5/35] Building CXX object lib/CodeGen/GlobalISel/CMakeFiles/LLVMGlobalISel.dir/CombinerHelper.cpp.o
16.364 [6/4/36] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/GISel/AArch64O0PreLegalizerCombiner.cpp.o
17.042 [6/3/37] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/GISel/AArch64PostLegalizerLowering.cpp.o
17.879 [6/2/38] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/GISel/AArch64PostLegalizerCombiner.cpp.o
17.936 [6/1/39] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/GISel/AArch64PreLegalizerCombiner.cpp.o
ninja: build stopped: subcommand failed.

aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
…ine. (llvm#151912)

We want to be able to produce extr instructions post-legalization. They
are legal for scalars, acting as a funnel shift with a constant shift
amount. Unfortunately I'm not sure if there is a way currently to
represent that in the legalization rules, but it might be useful for
several operations - to be able to treat and test operands with constant
operands as legal or not.

This adds a change to the existing matchOrShiftToFunnelShift so that
AArch64 can generate such instructions post-legalization providing that
the operation is scalar and the shift amount is constant.
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
…ine. (llvm#151912)

We want to be able to produce extr instructions post-legalization. They
are legal for scalars, acting as a funnel shift with a constant shift
amount. Unfortunately I'm not sure if there is a way currently to
represent that in the legalization rules, but it might be useful for
several operations - to be able to treat and test operands with constant
operands as legal or not.

This adds a change to the existing matchOrShiftToFunnelShift so that
AArch64 can generate such instructions post-legalization providing that
the operation is scalar and the shift amount is constant.
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.

4 participants