Skip to content

[X86] SimplifyDemandedVectorEltsForTargetNode - add X86ISD::MOVDDUP handling #140237

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025

Conversation

RKSimon
Copy link
Collaborator

@RKSimon RKSimon commented May 16, 2025

Reduce YMM MOVDDUP node to XMM if the upper elements are not demanded

Noticed while working on #140234

…andling

Reduce YMM MOVDDUP node to XMM if the upper elements are not demanded

Noticed while working on llvm#140234
@llvmbot
Copy link
Member

llvmbot commented May 16, 2025

@llvm/pr-subscribers-backend-x86

Author: Simon Pilgrim (RKSimon)

Changes

Reduce YMM MOVDDUP node to XMM if the upper elements are not demanded

Noticed while working on #140234


Full diff: https://github.com/llvm/llvm-project/pull/140237.diff

2 Files Affected:

  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+2)
  • (modified) llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll (+1-2)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9be3b39ce16fa..bde4f70b2147f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -44013,6 +44013,8 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(
     case X86ISD::VZEXT_MOVL:
       // Variable blend.
     case X86ISD::BLENDV:
+      // Target unary shuffles:
+    case X86ISD::MOVDDUP:
       // Target unary shuffles by immediate:
     case X86ISD::PSHUFD:
     case X86ISD::PSHUFLW:
diff --git a/llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll b/llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll
index cf546dc2671f2..d848a8b879215 100644
--- a/llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll
+++ b/llvm/test/CodeGen/X86/vector-shuffle-256-v4.ll
@@ -861,8 +861,7 @@ define <4 x double> @shuffle_v4f64_2345_0567_select(<4 x double> %vec1, <4 x dou
 define <4 x double> @shuffle_v4f64_1436_split_load(ptr %px, ptr %py) {
 ; AVX1-LABEL: shuffle_v4f64_1436_split_load:
 ; AVX1:       # %bb.0:
-; AVX1-NEXT:    vmovapd (%rsi), %xmm0
-; AVX1-NEXT:    vmovddup {{.*#+}} ymm0 = ymm0[0,0,2,2]
+; AVX1-NEXT:    vmovddup {{.*#+}} xmm0 = mem[0,0]
 ; AVX1-NEXT:    vmovupd (%rdi), %ymm1
 ; AVX1-NEXT:    vinsertf128 $1, 16(%rsi), %ymm0, %ymm0
 ; AVX1-NEXT:    vshufpd {{.*#+}} ymm0 = ymm1[1],ymm0[1],ymm1[3],ymm0[2]

@RKSimon RKSimon merged commit 2b5222b into llvm:main May 16, 2025
5 of 10 checks passed
@RKSimon RKSimon deleted the x86-demandelts-movddup branch May 16, 2025 13:45
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 16, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: Analysis/ftime-trace.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -cc1 -internal-isystem /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -analyzer-checker=core /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp -ftime-trace=/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.raw.json -ftime-trace-granularity=0 -verify # RUN: at line 1
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -cc1 -internal-isystem /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/21/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -analyzer-checker=core /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp -ftime-trace=/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.raw.json -ftime-trace-granularity=0 -verify
"/usr/bin/python3.10" -c 'import json, sys; print(json.dumps(json.load(sys.stdin), indent=4))' < /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.raw.json > /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json # RUN: at line 2
+ /usr/bin/python3.10 -c 'import json, sys; print(json.dumps(json.load(sys.stdin), indent=4))'
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck --input-file=/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json --check-prefix=CHECK /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp # RUN: at line 3
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck --input-file=/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json --check-prefix=CHECK /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp
�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp:34:11: �[0m�[0;1;31merror: �[0m�[1mCHECK: expected string not found in input
�[0m// CHECK: "name": "Total CheckerManager::runCheckersForStmt (Pre)",
�[0;1;32m          ^
�[0m�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json:2474:3: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m }
�[0;1;32m  ^
�[0m�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json:2674:2: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m "name": "Total CheckerManager::runCheckersForStmt (Post)",
�[0;1;32m ^
�[0m
Input file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Analysis/Output/ftime-trace.cpp.tmp.formatted.json
Check file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
�[1m�[0m�[0;1;30m            1: �[0m�[1m�[0;1;46m{ �[0m
�[0;1;30m            2: �[0m�[1m�[0;1;46m "traceEvents": [ �[0m
�[0;1;30m            3: �[0m�[1m�[0;1;46m { �[0m
�[0;1;30m            4: �[0m�[1m�[0;1;46m "pid": 970905, �[0m
�[0;1;30m            5: �[0m�[1m�[0;1;46m "tid": 970905, �[0m
�[0;1;30m            6: �[0m�[1m�[0;1;46m "ts": 6274, �[0m
�[0;1;30m            7: �[0m�[1m�[0;1;46m "ph": "X", �[0m
�[0;1;30m            8: �[0m�[1m�[0;1;46m "dur": 172, �[0m
�[0;1;30m            9: �[0m�[1m�[0;1;46m "name": "ParseDeclarationOrFunctionDefinition", �[0m
�[0;1;30m           10: �[0m�[1m�[0;1;46m "args": { �[0m
�[0;1;30m           11: �[0m�[1m�[0;1;46m "detail": "/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp:48:1" �[0m
�[0;1;30m           12: �[0m�[1m�[0;1;46m } �[0m
�[0;1;30m           13: �[0m�[1m�[0;1;46m }, �[0m
�[0;1;30m           14: �[0m�[1m�[0;1;46m { �[0m
�[0;1;30m           15: �[0m�[1m�[0;1;46m "pid": 970905, �[0m
�[0;1;30m           16: �[0m�[1m�[0;1;46m "tid": 970905, �[0m
�[0;1;30m           17: �[0m�[1m�[0;1;46m "ts": 6811, �[0m
�[0;1;30m           18: �[0m�[1m�[0;1;46m "ph": "X", �[0m
�[0;1;30m           19: �[0m�[1m�[0;1;46m "dur": 28, �[0m
�[0;1;30m           20: �[0m�[1m�[0;1;46m "name": "EvaluateForOverflow", �[0m
�[0;1;30m           21: �[0m�[1m�[0;1;46m "args": { �[0m
�[0;1;30m           22: �[0m�[1m�[0;1;46m "detail": "</home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/ftime-trace.cpp:53:9, col:13>" �[0m
...

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