Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[VectorCombine] Add initial nodes to the Worklist in VectorCombine#149047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
davemgreen wants to merge1 commit intollvm:main
base:main
Choose a base branch
Loading
fromdavemgreen:gh-vc-worklistorder

Conversation

davemgreen
Copy link
Collaborator

This tries to mirror how InstructionWorklist is used in InstCombine, adding the nodes initially to a list that is added in reverse order to the Worklist. The general order should be the same, the main advantage of this is that as node are initially processed, when altered the New and Old instructions are visited immediately, helping remove Old instructions as they are replaced, helping other combines work without hitting OneUse checks.

This tries to mirror how InstructionWorklist is used in InstCombine, adding thenodes initially to a list that is added in reverse order to the Worklist.  Thegeneral order should be the same, the main advantage of this is that as nodeare initially processed, when altered the New and Old instructions are visitedimmediately, helping remove Old instructions as they are replaced, helpingother combines work without hitting OneUse checks.
@llvmbot
Copy link
Member

llvmbot commentedJul 16, 2025
edited
Loading

@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-risc-v

Author: David Green (davemgreen)

Changes

This tries to mirror how InstructionWorklist is used in InstCombine, adding the nodes initially to a list that is added in reverse order to the Worklist. The general order should be the same, the main advantage of this is that as node are initially processed, when altered the New and Old instructions are visited immediately, helping remove Old instructions as they are replaced, helping other combines work without hitting OneUse checks.


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

13 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+7-3)
  • (modified) llvm/test/Transforms/PhaseOrdering/X86/hadd.ll (+11-11)
  • (modified) llvm/test/Transforms/PhaseOrdering/X86/hsub.ll (+11-11)
  • (modified) llvm/test/Transforms/VectorCombine/AArch64/ext-extract.ll (+69-32)
  • (modified) llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll (+8-8)
  • (modified) llvm/test/Transforms/VectorCombine/AArch64/select-shuffle.ll (+15-31)
  • (modified) llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll (+4-4)
  • (modified) llvm/test/Transforms/VectorCombine/X86/concat-boolmasks.ll (+15-49)
  • (modified) llvm/test/Transforms/VectorCombine/X86/extract-binop-inseltpoison.ll (+1-3)
  • (modified) llvm/test/Transforms/VectorCombine/X86/extract-binop.ll (+2-3)
  • (modified) llvm/test/Transforms/VectorCombine/X86/reduction-two-vecs-combine.ll (+8-8)
  • (modified) llvm/test/Transforms/VectorCombine/X86/select-shuffle.ll (+3-4)
  • (modified) llvm/test/Transforms/VectorCombine/pr88796.ll (+4-4)
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cppindex fe8d74c43dfdc..3c7101c9f3c0d 100644--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp@@ -3803,18 +3803,22 @@ bool VectorCombine::run() {     }   };+  SmallVector<Instruction*, 128> InstrsForInstructionWorklist;   for (BasicBlock &BB : F) {     // Ignore unreachable basic blocks.     if (!DT.isReachableFromEntry(&BB))       continue;-    // Use early increment range so that we can erase instructions in loop.-    for (Instruction &I : make_early_inc_range(BB)) {+    for (Instruction &I : BB) {       if (I.isDebugOrPseudoInst())         continue;-      FoldInst(I);+      InstrsForInstructionWorklist.push_back(&I);     }   }+  Worklist.reserve(InstrsForInstructionWorklist.size());+  for (auto I : reverse(InstrsForInstructionWorklist))+    Worklist.push(I);+   while (!Worklist.isEmpty()) {     Instruction *I = Worklist.removeOne();     if (!I)diff --git a/llvm/test/Transforms/PhaseOrdering/X86/hadd.ll b/llvm/test/Transforms/PhaseOrdering/X86/hadd.llindex 798df4cd4ff54..f85d46689ccb0 100644--- a/llvm/test/Transforms/PhaseOrdering/X86/hadd.ll+++ b/llvm/test/Transforms/PhaseOrdering/X86/hadd.ll@@ -121,12 +121,12 @@ define <8 x i16> @add_v8i16_u1234567(<8 x i16> %a, <8 x i16> %b) {  define <8 x i16> @add_v8i16_76u43210(<8 x i16> %a, <8 x i16> %b) { ; SSE2-LABEL: @add_v8i16_76u43210(-; SSE2-NEXT:    [[SHIFT:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE2-NEXT:    [[TMP1:%.*]] = add <8 x i16> [[A]], [[SHIFT]] ; SSE2-NEXT:    [[SHIFT2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 5, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP2:%.*]] = add <8 x i16> [[B]], [[SHIFT2]] ; SSE2-NEXT:    [[SHIFT3:%.*]] = shufflevector <8 x i16> [[B]], <8 x i16> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 6> ; SSE2-NEXT:    [[TMP3:%.*]] = add <8 x i16> [[SHIFT3]], [[B]]+; SSE2-NEXT:    [[TMP7:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE2-NEXT:    [[TMP1:%.*]] = add <8 x i16> [[A]], [[TMP7]] ; SSE2-NEXT:    [[TMP4:%.*]] = shufflevector <8 x i16> [[A]], <8 x i16> [[B]], <8 x i32> <i32 2, i32 4, i32 6, i32 8, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP5:%.*]] = shufflevector <8 x i16> [[A]], <8 x i16> [[B]], <8 x i32> <i32 3, i32 5, i32 7, i32 9, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP6:%.*]] = add <8 x i16> [[TMP4]], [[TMP5]]@@ -404,13 +404,13 @@ define <16 x i16> @add_v16i16_FEuCBA98765432u0(<16 x i16> %a, <16 x i16> %b) { ; SSE4-LABEL: @add_v16i16_FEuCBA98765432u0( ; SSE4-NEXT:    [[TMP2:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 1, i32 poison, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP10:%.*]] = shufflevector <16 x i16> [[TMP2]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 25, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 0, i32 poison, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 poison, i32 11, i32 12, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP10]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 poison, i32 26, i32 29, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 0, i32 poison, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 11, i32 12, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP10]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 26, i32 29, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP6:%.*]] = add <16 x i16> [[TMP4]], [[TMP5]]-; SSE4-NEXT:    [[TMP7:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 14, i32 24, i32 28, i32 30, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP8:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 15, i32 25, i32 29, i32 31, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP7:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 14, i32 24, i32 poison, i32 28, i32 30, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP8:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 15, i32 25, i32 poison, i32 29, i32 31, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP9:%.*]] = add <16 x i16> [[TMP7]], [[TMP8]]-; SSE4-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i16> [[TMP9]], <16 x i16> [[TMP6]], <16 x i32> <i32 3, i32 2, i32 poison, i32 1, i32 0, i32 27, i32 26, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 poison, i32 16>+; SSE4-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i16> [[TMP9]], <16 x i16> [[TMP6]], <16 x i32> <i32 4, i32 3, i32 poison, i32 1, i32 0, i32 26, i32 25, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 poison, i32 16> ; SSE4-NEXT:    ret <16 x i16> [[RESULT]] ; ; AVX2-LABEL: @add_v16i16_FEuCBA98765432u0(@@ -1183,14 +1183,14 @@ define <8 x float> @add_v8f32_76u43210(<8 x float> %a, <8 x float> %b) { ; SSE2-NEXT:    ret <8 x float> [[RESULT]] ; ; SSE4-LABEL: @add_v8f32_76u43210(-; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <8 x float> [[B:%.*]], <8 x float> [[A:%.*]], <8 x i32> <i32 6, i32 5, i32 poison, i32 0, i32 14, i32 12, i32 10, i32 8>-; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <8 x float> [[B]], <8 x float> [[A]], <8 x i32> <i32 7, i32 4, i32 poison, i32 1, i32 15, i32 13, i32 11, i32 9>+; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> [[B:%.*]], <8 x i32> <i32 14, i32 13, i32 poison, i32 8, i32 6, i32 4, i32 2, i32 0>+; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <8 x float> [[A]], <8 x float> [[B]], <8 x i32> <i32 15, i32 12, i32 poison, i32 9, i32 7, i32 5, i32 3, i32 1> ; SSE4-NEXT:    [[TMP6:%.*]] = fadd <8 x float> [[TMP4]], [[TMP5]] ; SSE4-NEXT:    ret <8 x float> [[TMP6]] ; ; AVX-LABEL: @add_v8f32_76u43210(-; AVX-NEXT:    [[TMP1:%.*]] = shufflevector <8 x float> [[B:%.*]], <8 x float> [[A:%.*]], <8 x i32> <i32 6, i32 5, i32 poison, i32 0, i32 14, i32 12, i32 10, i32 8>-; AVX-NEXT:    [[TMP2:%.*]] = shufflevector <8 x float> [[B]], <8 x float> [[A]], <8 x i32> <i32 7, i32 4, i32 poison, i32 1, i32 15, i32 13, i32 11, i32 9>+; AVX-NEXT:    [[TMP1:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> [[B:%.*]], <8 x i32> <i32 14, i32 13, i32 poison, i32 8, i32 6, i32 4, i32 2, i32 0>+; AVX-NEXT:    [[TMP2:%.*]] = shufflevector <8 x float> [[A]], <8 x float> [[B]], <8 x i32> <i32 15, i32 12, i32 poison, i32 9, i32 7, i32 5, i32 3, i32 1> ; AVX-NEXT:    [[RESULT:%.*]] = fadd <8 x float> [[TMP1]], [[TMP2]] ; AVX-NEXT:    ret <8 x float> [[RESULT]] ;diff --git a/llvm/test/Transforms/PhaseOrdering/X86/hsub.ll b/llvm/test/Transforms/PhaseOrdering/X86/hsub.llindex fd160b7c57024..98d35f862d418 100644--- a/llvm/test/Transforms/PhaseOrdering/X86/hsub.ll+++ b/llvm/test/Transforms/PhaseOrdering/X86/hsub.ll@@ -121,12 +121,12 @@ define <8 x i16> @sub_v8i16_u1234567(<8 x i16> %a, <8 x i16> %b) {  define <8 x i16> @sub_v8i16_76u43210(<8 x i16> %a, <8 x i16> %b) { ; SSE2-LABEL: @sub_v8i16_76u43210(-; SSE2-NEXT:    [[SHIFT:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE2-NEXT:    [[TMP1:%.*]] = sub <8 x i16> [[A]], [[SHIFT]] ; SSE2-NEXT:    [[SHIFT2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 5, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP2:%.*]] = sub <8 x i16> [[B]], [[SHIFT2]] ; SSE2-NEXT:    [[SHIFT3:%.*]] = shufflevector <8 x i16> [[B]], <8 x i16> poison, <8 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 6> ; SSE2-NEXT:    [[TMP3:%.*]] = sub <8 x i16> [[SHIFT3]], [[B]]+; SSE2-NEXT:    [[TMP7:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE2-NEXT:    [[TMP1:%.*]] = sub <8 x i16> [[A]], [[TMP7]] ; SSE2-NEXT:    [[TMP4:%.*]] = shufflevector <8 x i16> [[A]], <8 x i16> [[B]], <8 x i32> <i32 2, i32 4, i32 6, i32 8, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP5:%.*]] = shufflevector <8 x i16> [[A]], <8 x i16> [[B]], <8 x i32> <i32 3, i32 5, i32 7, i32 9, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE2-NEXT:    [[TMP6:%.*]] = sub <8 x i16> [[TMP4]], [[TMP5]]@@ -398,13 +398,13 @@ define <16 x i16> @sub_v16i16_FEuCBA98765432u0(<16 x i16> %a, <16 x i16> %b) { ; SSE4-LABEL: @sub_v16i16_FEuCBA98765432u0( ; SSE4-NEXT:    [[TMP2:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 1, i32 poison, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP10:%.*]] = shufflevector <16 x i16> [[TMP2]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 25, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 0, i32 poison, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 poison, i32 10, i32 12, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP10]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 poison, i32 27, i32 29, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 0, i32 poison, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 10, i32 12, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP10]], <16 x i16> [[A]], <16 x i32> <i32 0, i32 poison, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 27, i32 29, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP6:%.*]] = sub <16 x i16> [[TMP4]], [[TMP5]]-; SSE4-NEXT:    [[TMP7:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 14, i32 24, i32 28, i32 30, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>-; SSE4-NEXT:    [[TMP8:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 15, i32 25, i32 29, i32 31, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP7:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 14, i32 24, i32 poison, i32 28, i32 30, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>+; SSE4-NEXT:    [[TMP8:%.*]] = shufflevector <16 x i16> [[A]], <16 x i16> [[B]], <16 x i32> <i32 15, i32 25, i32 poison, i32 29, i32 31, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> ; SSE4-NEXT:    [[TMP9:%.*]] = sub <16 x i16> [[TMP7]], [[TMP8]]-; SSE4-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i16> [[TMP9]], <16 x i16> [[TMP6]], <16 x i32> <i32 3, i32 2, i32 poison, i32 1, i32 0, i32 27, i32 26, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 poison, i32 16>+; SSE4-NEXT:    [[RESULT:%.*]] = shufflevector <16 x i16> [[TMP9]], <16 x i16> [[TMP6]], <16 x i32> <i32 4, i32 3, i32 poison, i32 1, i32 0, i32 26, i32 25, i32 24, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 poison, i32 16> ; SSE4-NEXT:    ret <16 x i16> [[RESULT]] ; ; AVX2-LABEL: @sub_v16i16_FEuCBA98765432u0(@@ -1177,14 +1177,14 @@ define <8 x float> @sub_v8f32_76u43210(<8 x float> %a, <8 x float> %b) { ; SSE2-NEXT:    ret <8 x float> [[RESULT]] ; ; SSE4-LABEL: @sub_v8f32_76u43210(-; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <8 x float> [[B:%.*]], <8 x float> [[A:%.*]], <8 x i32> <i32 6, i32 4, i32 poison, i32 0, i32 14, i32 12, i32 10, i32 8>-; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <8 x float> [[B]], <8 x float> [[A]], <8 x i32> <i32 7, i32 5, i32 poison, i32 1, i32 15, i32 13, i32 11, i32 9>+; SSE4-NEXT:    [[TMP4:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> [[B:%.*]], <8 x i32> <i32 14, i32 12, i32 poison, i32 8, i32 6, i32 4, i32 2, i32 0>+; SSE4-NEXT:    [[TMP5:%.*]] = shufflevector <8 x float> [[A]], <8 x float> [[B]], <8 x i32> <i32 15, i32 13, i32 poison, i32 9, i32 7, i32 5, i32 3, i32 1> ; SSE4-NEXT:    [[TMP6:%.*]] = fsub <8 x float> [[TMP4]], [[TMP5]] ; SSE4-NEXT:    ret <8 x float> [[TMP6]] ; ; AVX-LABEL: @sub_v8f32_76u43210(-; AVX-NEXT:    [[TMP1:%.*]] = shufflevector <8 x float> [[B:%.*]], <8 x float> [[A:%.*]], <8 x i32> <i32 6, i32 4, i32 poison, i32 0, i32 14, i32 12, i32 10, i32 8>-; AVX-NEXT:    [[TMP2:%.*]] = shufflevector <8 x float> [[B]], <8 x float> [[A]], <8 x i32> <i32 7, i32 5, i32 poison, i32 1, i32 15, i32 13, i32 11, i32 9>+; AVX-NEXT:    [[TMP1:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> [[B:%.*]], <8 x i32> <i32 14, i32 12, i32 poison, i32 8, i32 6, i32 4, i32 2, i32 0>+; AVX-NEXT:    [[TMP2:%.*]] = shufflevector <8 x float> [[A]], <8 x float> [[B]], <8 x i32> <i32 15, i32 13, i32 poison, i32 9, i32 7, i32 5, i32 3, i32 1> ; AVX-NEXT:    [[RESULT:%.*]] = fsub <8 x float> [[TMP1]], [[TMP2]] ; AVX-NEXT:    ret <8 x float> [[RESULT]] ;diff --git a/llvm/test/Transforms/VectorCombine/AArch64/ext-extract.ll b/llvm/test/Transforms/VectorCombine/AArch64/ext-extract.llindex 60700412686ea..7358ebf637662 100644--- a/llvm/test/Transforms/VectorCombine/AArch64/ext-extract.ll+++ b/llvm/test/Transforms/VectorCombine/AArch64/ext-extract.ll@@ -17,11 +17,21 @@ define void @zext_v4i8_all_lanes_used(<4 x i8> %src) { ; CHECK-NEXT:    [[TMP6:%.*]] = lshr i32 [[TMP1]], 8 ; CHECK-NEXT:    [[TMP7:%.*]] = and i32 [[TMP6]], 255 ; CHECK-NEXT:    [[TMP9:%.*]] = and i32 [[TMP1]], 255-; CHECK-NEXT:    [[EXT9:%.*]] = zext nneg <4 x i8> [[SRC]] to <4 x i32>-; CHECK-NEXT:    [[EXT_0:%.*]] = extractelement <4 x i32> [[EXT9]], i64 0-; CHECK-NEXT:    [[EXT_1:%.*]] = extractelement <4 x i32> [[EXT9]], i64 1-; CHECK-NEXT:    [[EXT_2:%.*]] = extractelement <4 x i32> [[EXT9]], i64 2-; CHECK-NEXT:    [[EXT_3:%.*]] = extractelement <4 x i32> [[EXT9]], i64 3+; CHECK-NEXT:    [[TMP8:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP23:%.*]] = bitcast <4 x i8> [[TMP8]] to i32+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP23]], 24+; CHECK-NEXT:    [[TMP11:%.*]] = lshr i32 [[TMP23]], 16+; CHECK-NEXT:    [[TMP12:%.*]] = and i32 [[TMP11]], 255+; CHECK-NEXT:    [[TMP13:%.*]] = lshr i32 [[TMP23]], 8+; CHECK-NEXT:    [[TMP14:%.*]] = and i32 [[TMP13]], 255+; CHECK-NEXT:    [[TMP15:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP16:%.*]] = bitcast <4 x i8> [[TMP15]] to i32+; CHECK-NEXT:    [[TMP17:%.*]] = lshr i32 [[TMP16]], 24+; CHECK-NEXT:    [[TMP18:%.*]] = lshr i32 [[TMP16]], 16+; CHECK-NEXT:    [[TMP19:%.*]] = and i32 [[TMP18]], 255+; CHECK-NEXT:    [[TMP20:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP21:%.*]] = bitcast <4 x i8> [[TMP20]] to i32+; CHECK-NEXT:    [[TMP22:%.*]] = lshr i32 [[TMP21]], 24 ; CHECK-NEXT:    call void @use.i32(i32 [[TMP9]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP7]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP5]])@@ -83,10 +93,14 @@ define void @zext_v4i8_3_lanes_used_1(<4 x i8> %src) { ; CHECK-NEXT:    [[TMP5:%.*]] = and i32 [[TMP4]], 255 ; CHECK-NEXT:    [[TMP6:%.*]] = lshr i32 [[TMP1]], 8 ; CHECK-NEXT:    [[TMP7:%.*]] = and i32 [[TMP6]], 255-; CHECK-NEXT:    [[EXT9:%.*]] = zext nneg <4 x i8> [[SRC]] to <4 x i32>-; CHECK-NEXT:    [[EXT_1:%.*]] = extractelement <4 x i32> [[EXT9]], i64 1-; CHECK-NEXT:    [[EXT_2:%.*]] = extractelement <4 x i32> [[EXT9]], i64 2-; CHECK-NEXT:    [[EXT_3:%.*]] = extractelement <4 x i32> [[EXT9]], i64 3+; CHECK-NEXT:    [[TMP15:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP8:%.*]] = bitcast <4 x i8> [[TMP15]] to i32+; CHECK-NEXT:    [[TMP9:%.*]] = lshr i32 [[TMP8]], 24+; CHECK-NEXT:    [[TMP10:%.*]] = lshr i32 [[TMP8]], 16+; CHECK-NEXT:    [[TMP11:%.*]] = and i32 [[TMP10]], 255+; CHECK-NEXT:    [[TMP12:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP13:%.*]] = bitcast <4 x i8> [[TMP12]] to i32+; CHECK-NEXT:    [[TMP14:%.*]] = lshr i32 [[TMP13]], 24 ; CHECK-NEXT:    call void @use.i32(i32 [[TMP7]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP5]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP2]])@@ -114,10 +128,14 @@ define void @zext_v4i8_3_lanes_used_2(<4 x i8> %src) { ; CHECK-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP1]], 8 ; CHECK-NEXT:    [[TMP5:%.*]] = and i32 [[TMP4]], 255 ; CHECK-NEXT:    [[TMP7:%.*]] = and i32 [[TMP1]], 255-; CHECK-NEXT:    [[EXT9:%.*]] = zext nneg <4 x i8> [[SRC]] to <4 x i32>-; CHECK-NEXT:    [[EXT_0:%.*]] = extractelement <4 x i32> [[EXT9]], i64 0-; CHECK-NEXT:    [[EXT_1:%.*]] = extractelement <4 x i32> [[EXT9]], i64 1-; CHECK-NEXT:    [[EXT_3:%.*]] = extractelement <4 x i32> [[EXT9]], i64 3+; CHECK-NEXT:    [[TMP6:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP14:%.*]] = bitcast <4 x i8> [[TMP6]] to i32+; CHECK-NEXT:    [[TMP8:%.*]] = lshr i32 [[TMP14]], 24+; CHECK-NEXT:    [[TMP9:%.*]] = lshr i32 [[TMP14]], 8+; CHECK-NEXT:    [[TMP10:%.*]] = and i32 [[TMP9]], 255+; CHECK-NEXT:    [[TMP11:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP12:%.*]] = bitcast <4 x i8> [[TMP11]] to i32+; CHECK-NEXT:    [[TMP13:%.*]] = lshr i32 [[TMP12]], 24 ; CHECK-NEXT:    call void @use.i32(i32 [[TMP7]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP5]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP2]])@@ -145,9 +163,10 @@ define void @zext_v4i8_2_lanes_used_1(<4 x i8> %src) { ; CHECK-NEXT:    [[TMP3:%.*]] = and i32 [[TMP2]], 255 ; CHECK-NEXT:    [[TMP4:%.*]] = lshr i32 [[TMP1]], 8 ; CHECK-NEXT:    [[TMP5:%.*]] = and i32 [[TMP4]], 255-; CHECK-NEXT:    [[EXT9:%.*]] = zext nneg <4 x i8> [[SRC]] to <4 x i32>-; CHECK-NEXT:    [[EXT_1:%.*]] = extractelement <4 x i32> [[EXT9]], i64 1-; CHECK-NEXT:    [[EXT_2:%.*]] = extractelement <4 x i32> [[EXT9]], i64 2+; CHECK-NEXT:    [[TMP6:%.*]] = freeze <4 x i8> [[SRC]]+; CHECK-NEXT:    [[TMP7:%.*]] = bitcast <4 x i8> [[TMP6]] to i32+; CHECK-NEXT:    [[TMP8:%.*]] = lshr i32 [[TMP7]], 16+; CHECK-NEXT:    [[TMP9:%.*]] = and i32 [[TMP8]], 255 ; CHECK-NEXT:    call void @use.i32(i32 [[TMP5]]) ; CHECK-NEXT:    call void @use.i32(i32 [[TMP3]]) ; CHECK-NEXT:    ret void@@ -171,9 +190,10 @@ define void @zext_v4i8_2_lanes_used_2(<4 x i8> %src) { ; CHECK-NEXT:    [[TMP2:%.*]] = lshr i32 [[TMP1]], 16 ; CHECK-NEXT:    [[TMP3:%.*]] = and i32 [[TMP2]], 255 ; CHECK-NEXT:    [[TMP5:%.*]] = and i32 [[TMP1]], 255-; CHECK-NEXT:    [[EXT9:%.*]] = zext nneg <4 x i8> [[SRC]] to <4 x i32>-; CHECK-NEXT:    [...[truncated]

@github-actionsGitHub Actions
Copy link

⚠️ undef deprecator found issues in your code.⚠️

You can test this locally with the following command:
git diff -U0 --pickaxe-regex -S'([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)''HEAD~1' HEAD llvm/lib/Transforms/Vectorize/VectorCombine.cpp llvm/test/Transforms/PhaseOrdering/X86/hadd.ll llvm/test/Transforms/PhaseOrdering/X86/hsub.ll llvm/test/Transforms/VectorCombine/AArch64/ext-extract.ll llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll llvm/test/Transforms/VectorCombine/AArch64/select-shuffle.ll llvm/test/Transforms/VectorCombine/RISCV/load-widening.ll llvm/test/Transforms/VectorCombine/X86/concat-boolmasks.ll llvm/test/Transforms/VectorCombine/X86/extract-binop-inseltpoison.ll llvm/test/Transforms/VectorCombine/X86/extract-binop.ll llvm/test/Transforms/VectorCombine/X86/reduction-two-vecs-combine.ll llvm/test/Transforms/VectorCombine/X86/select-shuffle.ll llvm/test/Transforms/VectorCombine/pr88796.ll

The following files introduce new uses of undef:

  • llvm/test/Transforms/VectorCombine/AArch64/select-shuffle.ll

Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yieldsundef. You should usepoison values for placeholders instead.

In tests, avoid usingundef and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

For example, this is considered a bad practice:

definevoid@fn() {  ...bri1undef, ...}

Please use the following instead:

definevoid@fn(i1%cond) {  ...bri1%cond, ...}

Please refer to theUndefined Behavior Manual for more information.

@github-actionsGitHub 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 HEAD~1 HEAD --extensions cpp -- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cppindex 3c7101c9f..9d7d2d00e 100644--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp@@ -3803,7 +3803,7 @@ bool VectorCombine::run() {     }   };-  SmallVector<Instruction*, 128> InstrsForInstructionWorklist;+  SmallVector<Instruction *, 128> InstrsForInstructionWorklist;   for (BasicBlock &BB : F) {     // Ignore unreachable basic blocks.     if (!DT.isReachableFromEntry(&BB))

Copy link
Contributor

@nikicnikic left a comment

Choose a reason for hiding this comment

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

Compile-time:https://llvm-compile-time-tracker.com/compare.php?from=60579ec3059b2b6cc9dad90eaac1ed363fc395a7&to=7322d4b393c94af7164439419100d9c25df1e420&stat=instructions:u

Adding the entire function to the worklist at once is quite expensive...

Possibly we could do something more targeted at removing dead instructions early?

@davemgreen
Copy link
CollaboratorAuthor

davemgreen commentedJul 17, 2025
edited
Loading

Compile-time:https://llvm-compile-time-tracker.com/compare.php?from=60579ec3059b2b6cc9dad90eaac1ed363fc395a7&to=7322d4b393c94af7164439419100d9c25df1e420&stat=instructions:u

Adding the entire function to the worklist at once is quite expensive...

Possibly we could do something more targeted at removing dead instructions early?

Thanks, Yeah it is probably not be very useful for a lot of node - many will not be vector instructions. I will look into erasing the instructions as we replace them if we can.

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

@nikicnikicnikic left review comments

@fhahnfhahnAwaiting requested review from fhahn

@RKSimonRKSimonAwaiting requested review from RKSimon

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@davemgreen@llvmbot@nikic

[8]ページ先頭

©2009-2025 Movatter.jp