-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86][GlobalISel] Reorganize tests for G_PHI and support fp80 #100047
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
Conversation
* Verify scalar support of G_PHI * Added cases with i1 and ptr types * Added phi input variability We don't enable tests for i686 due to lack of float/integer types in legalizer. We don't distinguish between non-legal 64 bit integer G_LOAD and legal double load using X87..
@llvm/pr-subscribers-backend-x86 Author: Evgenii Kudriashov (e-kud) Changes
We don't enable tests for i686 due to lack of float/integer types in legalizer. We don't distinguish between non-legal 64 bit integer G_LOAD and legal double load using X87. It leads to artificial G_MERGE_VALUES of floats into single double. Patch is 22.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/100047.diff 3 Files Affected:
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index dd8ecf6ef7fc7..7169d588548b0 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -315,7 +315,8 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
getActionDefinitionsBuilder(G_PHI)
.legalIf([=](const LegalityQuery &Query) -> bool {
return typeInSet(0, {s8, s16, s32, p0})(Query) ||
- (Is64Bit && typeInSet(0, {s64})(Query)) ||
+ (UseX87 && typeIs(0, s80)(Query)) ||
+ (Is64Bit && typeIs(0, s64)(Query)) ||
(HasSSE1 && typeInSet(0, {v16s8, v8s16, v4s32, v2s64})(Query)) ||
(HasAVX && typeInSet(0, {v32s8, v16s16, v8s32, v4s64})(Query)) ||
(HasAVX512 &&
diff --git a/llvm/test/CodeGen/X86/GlobalISel/phi.ll b/llvm/test/CodeGen/X86/GlobalISel/phi.ll
deleted file mode 100644
index b29540f002598..0000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/phi.ll
+++ /dev/null
@@ -1,172 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL
-
-define i8 @test_i8(i32 %a, i8 %f, i8 %t) {
-; ALL-LABEL: test_i8:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB0_2
-; ALL-NEXT: # %bb.1:
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: # kill: def $al killed $al killed $eax
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB0_2: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: # kill: def $al killed $al killed $eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i8 %cond
-}
-
-define i16 @test_i16(i32 %a, i16 %f, i16 %t) {
-; ALL-LABEL: test_i16:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB1_2
-; ALL-NEXT: # %bb.1:
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: # kill: def $ax killed $ax killed $eax
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB1_2: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: # kill: def $ax killed $ax killed $eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i16 %cond
-}
-
-define i32 @test_i32(i32 %a, i32 %f, i32 %t) {
-; ALL-LABEL: test_i32:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB2_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB2_1: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i32 %cond
-}
-
-define i64 @test_i64(i32 %a, i64 %f, i64 %t) {
-; ALL-LABEL: test_i64:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: movq %rsi, %rax
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB3_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB3_1: # %cond.false
-; ALL-NEXT: movq %rdx, %rax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i64 %cond
-}
-
-define float @test_float(i32 %a, float %f, float %t) {
-; ALL-LABEL: test_float:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %al
-; ALL-NEXT: testb $1, %al
-; ALL-NEXT: je .LBB4_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB4_1: # %cond.false
-; ALL-NEXT: movaps %xmm1, %xmm0
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
- ret float %cond
-}
-
-define double @test_double(i32 %a, double %f, double %t) {
-; ALL-LABEL: test_double:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %al
-; ALL-NEXT: testb $1, %al
-; ALL-NEXT: je .LBB5_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB5_1: # %cond.false
-; ALL-NEXT: movaps %xmm1, %xmm0
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
- ret double %cond
-}
diff --git a/llvm/test/CodeGen/X86/isel-phi.ll b/llvm/test/CodeGen/X86/isel-phi.ll
new file mode 100644
index 0000000000000..412aeac5eed6a
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-phi.ll
@@ -0,0 +1,494 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=i686-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
+; RUN: llc -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
+; TODO: enable when x87 is supported
+; llc -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86,GLOBAL-X86
+; RUN: llc -mtriple=x86_64-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
+; RUN: llc -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
+; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,GLOBAL-X64
+
+define i1 @test_i1(i1 %a, i1 %b, i1 %c, i1 %pred0, i1 %pred1) {
+; X86-LABEL: test_i1:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB0_1
+; X86-NEXT: # %bb.2: # %cond
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB0_4
+; X86-NEXT: # %bb.3:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_1:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_4: # %cond.false
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i1:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %cl
+; X64-NEXT: je .LBB0_1
+; X64-NEXT: # %bb.2: # %cond
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: testb $1, %r8b
+; X64-NEXT: jne .LBB0_4
+; X64-NEXT: # %bb.3: # %cond.false
+; X64-NEXT: movl %edx, %eax
+; X64-NEXT: .LBB0_4: # %cond.end
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB0_1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred0, label %cond, label %cond.end
+
+cond:
+ br i1 %pred1, label %cond.true, label %cond.false
+
+cond.true:
+ br label %cond.end
+
+cond.false:
+ br label %cond.end
+
+cond.end:
+ %res = phi i1 [ %a, %entry ], [ %b, %cond.true ], [ %c, %cond.false ]
+ ret i1 %res
+}
+
+define i8 @test_i8(i8 %f, i8 %t, i1 %pred) {
+; X86-LABEL: test_i8:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB1_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB1_2: # %cond.false
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i8:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: je .LBB1_2
+; X64-NEXT: # %bb.1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB1_2: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i8 %cond
+}
+
+define i16 @test_i16(i16 %f, i16 %t, i1 %pred) {
+; X86-LABEL: test_i16:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB2_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB2_2: # %cond.false
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i16:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: je .LBB2_2
+; X64-NEXT: # %bb.1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB2_2: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i16 %cond
+}
+
+define i32 @test_i32(i32 %f, i32 %t, i1 %pred) {
+; X86-LABEL: test_i32:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB3_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB3_2: # %cond.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i32:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: jne .LBB3_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: .LBB3_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i32 %cond
+}
+
+define i64 @test_i64(i64 %f, i64 %t, i1 %pred) {
+; X86-LABEL: test_i64:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB4_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB4_2: # %cond.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i64:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: jne .LBB4_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movq %rsi, %rax
+; X64-NEXT: .LBB4_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i64 %cond
+}
+
+define float @test_float(float %f, float %t, i1 %pred) {
+; X86-LABEL: test_float:
+; X86: # %bb.0: # %entry
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: jne .LBB5_2
+; X86-NEXT: # %bb.1: # %cond.false
+; X86-NEXT: fstp %st(0)
+; X86-NEXT: fldz
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: .LBB5_2: # %cond.end
+; X86-NEXT: fstp %st(1)
+; X86-NEXT: retl
+;
+; X64-LABEL: test_float:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dil
+; X64-NEXT: jne .LBB5_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movaps %xmm1, %xmm0
+; X64-NEXT: .LBB5_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
+ ret float %cond
+}
+
+define double @test_double(i32 %a, double %f, double %t, i1 %pred) {
+; X86-LABEL: test_double:
+; X86: # %bb.0: # %entry
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: jne .LBB6_2
+; X86-NEXT: # %bb.1: # %cond.false
+; X86-NEXT: fstp %st(0)
+; X86-NEXT: fldz
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: .LBB6_2: # %cond.end
+; X86-NEXT: fstp %st(1)
+; X86-NEXT: retl
+;
+; X64-LABEL: test_double:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %sil
+; X64-NEXT: jne .LBB6_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movaps %xmm1, %xmm0
+; X64-NEXT: .LBB6_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
+ ret double %cond
+}
+
+define ptr @test_ptr(ptr %a, ptr %b, ptr %c, ptr %d, ptr %e, ptr %f, ptr %g, i1 %pred0, i1 %pred1, i1 %pred2) {
+; X86-LABEL: test_ptr:
+; X86: # %bb.0: # %entry
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB7_6
+; X86-NEXT: # %bb.1: # %cond.true
+; X86-NEXT: testb $1, %cl
+; X86-NEXT: je .LBB7_3
+; X86-NEXT: # %bb.2:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_6: # %cond.false
+; X86-NEXT: testb $1, %cl
+; X86-NEXT: je .LBB7_10
+; X86-NEXT: # %bb.7: # %cond.false.true
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_9
+; X86-NEXT: # %bb.8:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_3: # %cond.true.false
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_5
+; X86-NEXT: # %bb.4:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_10: # %cond.false.false
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_12
+; X86-NEXT: # %bb.11:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_9: # %cond.false.true.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_5: # %cond.true.false.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_12: # %cond.false.false.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; DAG-X64-LABEL: test_ptr:
+; DAG-X64: # %bb.0: # %entry
+; DAG-X64-NEXT: movq %rdi, %rax
+; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %edi
+; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %r10d
+; DAG-X64-NEXT: testb $1, {{[0-9]+}}(%rsp)
+; DAG-X64-NEXT: je .LBB7_4
+; DAG-X64-NEXT: # %bb.1: # %cond.true
+; DAG-X64-NEXT: testb $1, %r10b
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.2: # %cond.true.false
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %rsi, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.3: # %cond.true.false.false
+; DAG-X64-NEXT: movq %rdx, %rax
+; DAG-X64-NEXT: retq
+; DAG-X64-NEXT: .LBB7_4: # %cond.false
+; DAG-X64-NEXT: testb $1, %r10b
+; DAG-X64-NEXT: je .LBB7_7
+; DAG-X64-NEXT: # %bb.5: # %cond.false.true
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %rcx, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.6: # %cond.false.true.false
+; DAG-X64-NEXT: movq %r8, %rax
+; DAG-X64-NEXT: retq
+; DAG-X64-NEXT: .LBB7_7: # %cond.false.false
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %r9, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.8: # %cond.false.false.false
+; DAG-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
+; DAG-X64-NEXT: .LBB7_9: # %cond.end
+; DAG-X64-NEXT: retq
+;
+; GLOBAL-X64-LABEL: test_ptr:
+; GLOBAL-X64: # %bb.0: # %entry
+; GLOBAL-X64-NEXT: movq %rdi, %rax
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r11d
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r10d
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %edi
+; GLOBAL-X64-NEXT: testb $1, %r11b
+; GLOBAL-X64-NEXT: je .LBB7_4
+; GLOBAL-X64-NEXT: # %bb.1: # %cond.true
+; GLOBAL-X64-NEXT: testb $1, %r10b
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.2: # %cond.true.false
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %rsi, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.3: # %cond.true.false.false
+; GLOBAL-X64-NEXT: movq %rdx, %rax
+; GLOBAL-X64-NEXT: retq
+; GLOBAL-X64-NEXT: .LBB7_4: # %cond.false
+; GLOBAL-X64-NEXT: testb $1, %r10b
+; GLOBAL-X64-NEXT: je .LBB7_7
+; GLOBAL-X64-NEXT: # %bb.5: # %cond.false.true
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %rcx, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.6: # %cond.false.true.false
+; GLOBAL-X64-NEXT: movq %r8, %rax
+; GLOBAL-X64-NEXT: retq
+; GLOBAL-X64-NEXT: .LBB7_7: # %cond.false.false
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %r9, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.8: # %cond.false.false.false
+; GLOBAL-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
+; GLOBAL-X64-NEXT: .LBB7_9: # %cond.end
+; GLOBAL-X64-NEXT: retq
+entry:
+ br i1 %pred0, label %cond.true, label %cond.false
+
+cond.true:
+ br i1 %pred1, label %cond.end, label %cond.true.false
+
+cond.true.false:
+ br i1 %pred2, label %cond.true.false.true, label %cond.true.false.false
+
+cond.true.false.true:
+ br label %cond.end
+
+cond.true.false.false:
+ br label %cond.end
+
+cond.false:
+ br i1 %pred1, label %co...
[truncated]
|
@llvm/pr-subscribers-llvm-globalisel Author: Evgenii Kudriashov (e-kud) Changes
We don't enable tests for i686 due to lack of float/integer types in legalizer. We don't distinguish between non-legal 64 bit integer G_LOAD and legal double load using X87. It leads to artificial G_MERGE_VALUES of floats into single double. Patch is 22.41 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/100047.diff 3 Files Affected:
diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
index dd8ecf6ef7fc7..7169d588548b0 100644
--- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
+++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp
@@ -315,7 +315,8 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
getActionDefinitionsBuilder(G_PHI)
.legalIf([=](const LegalityQuery &Query) -> bool {
return typeInSet(0, {s8, s16, s32, p0})(Query) ||
- (Is64Bit && typeInSet(0, {s64})(Query)) ||
+ (UseX87 && typeIs(0, s80)(Query)) ||
+ (Is64Bit && typeIs(0, s64)(Query)) ||
(HasSSE1 && typeInSet(0, {v16s8, v8s16, v4s32, v2s64})(Query)) ||
(HasAVX && typeInSet(0, {v32s8, v16s16, v8s32, v4s64})(Query)) ||
(HasAVX512 &&
diff --git a/llvm/test/CodeGen/X86/GlobalISel/phi.ll b/llvm/test/CodeGen/X86/GlobalISel/phi.ll
deleted file mode 100644
index b29540f002598..0000000000000
--- a/llvm/test/CodeGen/X86/GlobalISel/phi.ll
+++ /dev/null
@@ -1,172 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=ALL
-
-define i8 @test_i8(i32 %a, i8 %f, i8 %t) {
-; ALL-LABEL: test_i8:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB0_2
-; ALL-NEXT: # %bb.1:
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: # kill: def $al killed $al killed $eax
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB0_2: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: # kill: def $al killed $al killed $eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i8 %cond
-}
-
-define i16 @test_i16(i32 %a, i16 %f, i16 %t) {
-; ALL-LABEL: test_i16:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB1_2
-; ALL-NEXT: # %bb.1:
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: # kill: def $ax killed $ax killed $eax
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB1_2: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: # kill: def $ax killed $ax killed $eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i16 %cond
-}
-
-define i32 @test_i32(i32 %a, i32 %f, i32 %t) {
-; ALL-LABEL: test_i32:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: movl %esi, %eax
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB2_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB2_1: # %cond.false
-; ALL-NEXT: movl %edx, %eax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i32 %cond
-}
-
-define i64 @test_i64(i32 %a, i64 %f, i64 %t) {
-; ALL-LABEL: test_i64:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: movq %rsi, %rax
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %cl
-; ALL-NEXT: testb $1, %cl
-; ALL-NEXT: je .LBB3_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB3_1: # %cond.false
-; ALL-NEXT: movq %rdx, %rax
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
- ret i64 %cond
-}
-
-define float @test_float(i32 %a, float %f, float %t) {
-; ALL-LABEL: test_float:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %al
-; ALL-NEXT: testb $1, %al
-; ALL-NEXT: je .LBB4_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB4_1: # %cond.false
-; ALL-NEXT: movaps %xmm1, %xmm0
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
- ret float %cond
-}
-
-define double @test_double(i32 %a, double %f, double %t) {
-; ALL-LABEL: test_double:
-; ALL: # %bb.0: # %entry
-; ALL-NEXT: cmpl $0, %edi
-; ALL-NEXT: setg %al
-; ALL-NEXT: testb $1, %al
-; ALL-NEXT: je .LBB5_1
-; ALL-NEXT: # %bb.2: # %cond.end
-; ALL-NEXT: retq
-; ALL-NEXT: .LBB5_1: # %cond.false
-; ALL-NEXT: movaps %xmm1, %xmm0
-; ALL-NEXT: retq
-entry:
- %cmp = icmp sgt i32 %a, 0
- br i1 %cmp, label %cond.true, label %cond.false
-
-cond.true: ; preds = %entry
- br label %cond.end
-
-cond.false: ; preds = %entry
- br label %cond.end
-
-cond.end: ; preds = %cond.false, %cond.true
- %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
- ret double %cond
-}
diff --git a/llvm/test/CodeGen/X86/isel-phi.ll b/llvm/test/CodeGen/X86/isel-phi.ll
new file mode 100644
index 0000000000000..412aeac5eed6a
--- /dev/null
+++ b/llvm/test/CodeGen/X86/isel-phi.ll
@@ -0,0 +1,494 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=i686-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
+; RUN: llc -mtriple=i686-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86
+; TODO: enable when x87 is supported
+; llc -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X86,GLOBAL-X86
+; RUN: llc -mtriple=x86_64-linux-gnu -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
+; RUN: llc -mtriple=x86_64-linux-gnu -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,DAG-X64
+; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 -verify-machineinstrs < %s -o - | FileCheck %s --check-prefixes=X64,GLOBAL-X64
+
+define i1 @test_i1(i1 %a, i1 %b, i1 %c, i1 %pred0, i1 %pred1) {
+; X86-LABEL: test_i1:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB0_1
+; X86-NEXT: # %bb.2: # %cond
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB0_4
+; X86-NEXT: # %bb.3:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_1:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB0_4: # %cond.false
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i1:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %cl
+; X64-NEXT: je .LBB0_1
+; X64-NEXT: # %bb.2: # %cond
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: testb $1, %r8b
+; X64-NEXT: jne .LBB0_4
+; X64-NEXT: # %bb.3: # %cond.false
+; X64-NEXT: movl %edx, %eax
+; X64-NEXT: .LBB0_4: # %cond.end
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB0_1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred0, label %cond, label %cond.end
+
+cond:
+ br i1 %pred1, label %cond.true, label %cond.false
+
+cond.true:
+ br label %cond.end
+
+cond.false:
+ br label %cond.end
+
+cond.end:
+ %res = phi i1 [ %a, %entry ], [ %b, %cond.true ], [ %c, %cond.false ]
+ ret i1 %res
+}
+
+define i8 @test_i8(i8 %f, i8 %t, i1 %pred) {
+; X86-LABEL: test_i8:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB1_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB1_2: # %cond.false
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i8:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: je .LBB1_2
+; X64-NEXT: # %bb.1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB1_2: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $al killed $al killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i8 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i8 %cond
+}
+
+define i16 @test_i16(i16 %f, i16 %t, i1 %pred) {
+; X86-LABEL: test_i16:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB2_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB2_2: # %cond.false
+; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i16:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: je .LBB2_2
+; X64-NEXT: # %bb.1:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+; X64-NEXT: .LBB2_2: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i16 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i16 %cond
+}
+
+define i32 @test_i32(i32 %f, i32 %t, i1 %pred) {
+; X86-LABEL: test_i32:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB3_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB3_2: # %cond.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i32:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: jne .LBB3_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movl %esi, %eax
+; X64-NEXT: .LBB3_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i32 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i32 %cond
+}
+
+define i64 @test_i64(i64 %f, i64 %t, i1 %pred) {
+; X86-LABEL: test_i64:
+; X86: # %bb.0: # %entry
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB4_2
+; X86-NEXT: # %bb.1:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB4_2: # %cond.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_i64:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: testb $1, %dl
+; X64-NEXT: jne .LBB4_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movq %rsi, %rax
+; X64-NEXT: .LBB4_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi i64 [ %f, %cond.true ], [ %t, %cond.false ]
+ ret i64 %cond
+}
+
+define float @test_float(float %f, float %t, i1 %pred) {
+; X86-LABEL: test_float:
+; X86: # %bb.0: # %entry
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: flds {{[0-9]+}}(%esp)
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: jne .LBB5_2
+; X86-NEXT: # %bb.1: # %cond.false
+; X86-NEXT: fstp %st(0)
+; X86-NEXT: fldz
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: .LBB5_2: # %cond.end
+; X86-NEXT: fstp %st(1)
+; X86-NEXT: retl
+;
+; X64-LABEL: test_float:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %dil
+; X64-NEXT: jne .LBB5_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movaps %xmm1, %xmm0
+; X64-NEXT: .LBB5_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi float [ %f, %cond.true ], [ %t, %cond.false ]
+ ret float %cond
+}
+
+define double @test_double(i32 %a, double %f, double %t, i1 %pred) {
+; X86-LABEL: test_double:
+; X86: # %bb.0: # %entry
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: fldl {{[0-9]+}}(%esp)
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: jne .LBB6_2
+; X86-NEXT: # %bb.1: # %cond.false
+; X86-NEXT: fstp %st(0)
+; X86-NEXT: fldz
+; X86-NEXT: fxch %st(1)
+; X86-NEXT: .LBB6_2: # %cond.end
+; X86-NEXT: fstp %st(1)
+; X86-NEXT: retl
+;
+; X64-LABEL: test_double:
+; X64: # %bb.0: # %entry
+; X64-NEXT: testb $1, %sil
+; X64-NEXT: jne .LBB6_2
+; X64-NEXT: # %bb.1: # %cond.false
+; X64-NEXT: movaps %xmm1, %xmm0
+; X64-NEXT: .LBB6_2: # %cond.end
+; X64-NEXT: retq
+entry:
+ br i1 %pred, label %cond.true, label %cond.false
+
+cond.true: ; preds = %entry
+ br label %cond.end
+
+cond.false: ; preds = %entry
+ br label %cond.end
+
+cond.end: ; preds = %cond.false, %cond.true
+ %cond = phi double [ %f, %cond.true ], [ %t, %cond.false ]
+ ret double %cond
+}
+
+define ptr @test_ptr(ptr %a, ptr %b, ptr %c, ptr %d, ptr %e, ptr %f, ptr %g, i1 %pred0, i1 %pred1, i1 %pred2) {
+; X86-LABEL: test_ptr:
+; X86: # %bb.0: # %entry
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
+; X86-NEXT: je .LBB7_6
+; X86-NEXT: # %bb.1: # %cond.true
+; X86-NEXT: testb $1, %cl
+; X86-NEXT: je .LBB7_3
+; X86-NEXT: # %bb.2:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_6: # %cond.false
+; X86-NEXT: testb $1, %cl
+; X86-NEXT: je .LBB7_10
+; X86-NEXT: # %bb.7: # %cond.false.true
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_9
+; X86-NEXT: # %bb.8:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_3: # %cond.true.false
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_5
+; X86-NEXT: # %bb.4:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_10: # %cond.false.false
+; X86-NEXT: testb $1, %al
+; X86-NEXT: je .LBB7_12
+; X86-NEXT: # %bb.11:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_9: # %cond.false.true.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_5: # %cond.true.false.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+; X86-NEXT: .LBB7_12: # %cond.false.false.false
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; DAG-X64-LABEL: test_ptr:
+; DAG-X64: # %bb.0: # %entry
+; DAG-X64-NEXT: movq %rdi, %rax
+; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %edi
+; DAG-X64-NEXT: movzbl {{[0-9]+}}(%rsp), %r10d
+; DAG-X64-NEXT: testb $1, {{[0-9]+}}(%rsp)
+; DAG-X64-NEXT: je .LBB7_4
+; DAG-X64-NEXT: # %bb.1: # %cond.true
+; DAG-X64-NEXT: testb $1, %r10b
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.2: # %cond.true.false
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %rsi, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.3: # %cond.true.false.false
+; DAG-X64-NEXT: movq %rdx, %rax
+; DAG-X64-NEXT: retq
+; DAG-X64-NEXT: .LBB7_4: # %cond.false
+; DAG-X64-NEXT: testb $1, %r10b
+; DAG-X64-NEXT: je .LBB7_7
+; DAG-X64-NEXT: # %bb.5: # %cond.false.true
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %rcx, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.6: # %cond.false.true.false
+; DAG-X64-NEXT: movq %r8, %rax
+; DAG-X64-NEXT: retq
+; DAG-X64-NEXT: .LBB7_7: # %cond.false.false
+; DAG-X64-NEXT: testb $1, %dil
+; DAG-X64-NEXT: movq %r9, %rax
+; DAG-X64-NEXT: jne .LBB7_9
+; DAG-X64-NEXT: # %bb.8: # %cond.false.false.false
+; DAG-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
+; DAG-X64-NEXT: .LBB7_9: # %cond.end
+; DAG-X64-NEXT: retq
+;
+; GLOBAL-X64-LABEL: test_ptr:
+; GLOBAL-X64: # %bb.0: # %entry
+; GLOBAL-X64-NEXT: movq %rdi, %rax
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r11d
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %r10d
+; GLOBAL-X64-NEXT: movl {{[0-9]+}}(%rsp), %edi
+; GLOBAL-X64-NEXT: testb $1, %r11b
+; GLOBAL-X64-NEXT: je .LBB7_4
+; GLOBAL-X64-NEXT: # %bb.1: # %cond.true
+; GLOBAL-X64-NEXT: testb $1, %r10b
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.2: # %cond.true.false
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %rsi, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.3: # %cond.true.false.false
+; GLOBAL-X64-NEXT: movq %rdx, %rax
+; GLOBAL-X64-NEXT: retq
+; GLOBAL-X64-NEXT: .LBB7_4: # %cond.false
+; GLOBAL-X64-NEXT: testb $1, %r10b
+; GLOBAL-X64-NEXT: je .LBB7_7
+; GLOBAL-X64-NEXT: # %bb.5: # %cond.false.true
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %rcx, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.6: # %cond.false.true.false
+; GLOBAL-X64-NEXT: movq %r8, %rax
+; GLOBAL-X64-NEXT: retq
+; GLOBAL-X64-NEXT: .LBB7_7: # %cond.false.false
+; GLOBAL-X64-NEXT: testb $1, %dil
+; GLOBAL-X64-NEXT: movq %r9, %rax
+; GLOBAL-X64-NEXT: jne .LBB7_9
+; GLOBAL-X64-NEXT: # %bb.8: # %cond.false.false.false
+; GLOBAL-X64-NEXT: movq {{[0-9]+}}(%rsp), %rax
+; GLOBAL-X64-NEXT: .LBB7_9: # %cond.end
+; GLOBAL-X64-NEXT: retq
+entry:
+ br i1 %pred0, label %cond.true, label %cond.false
+
+cond.true:
+ br i1 %pred1, label %cond.end, label %cond.true.false
+
+cond.true.false:
+ br i1 %pred2, label %cond.true.false.true, label %cond.true.false.false
+
+cond.true.false.true:
+ br label %cond.end
+
+cond.true.false.false:
+ br label %cond.end
+
+cond.false:
+ br i1 %pred1, label %co...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
Summary: * Verified scalar support of G_PHI * Added cases with i1, ptr and x86_fp80 types * Added phi inputs variability We don't enable tests for i686 due to lack of float/integer types in legalizer. We don't distinguish between illegal 64 bit integer G_LOAD and legal double load using X87. It leads to artificial G_MERGE_VALUES of floats into a single double. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250592
We don't enable tests for i686 due to lack of float/integer types in legalizer. We don't distinguish between non-legal 64 bit integer G_LOAD and legal double load using X87. It leads to artificial G_MERGE_VALUES of floats into single double.