[llvm] e529cda - [NFC] Add test cases for D147827
Amaury Séchet via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 11 06:18:09 PDT 2023
Author: Amaury Séchet
Date: 2023-04-11T13:14:10Z
New Revision: e529cda970e4422647bcc296cc306d08f2757be9
URL: https://github.com/llvm/llvm-project/commit/e529cda970e4422647bcc296cc306d08f2757be9
DIFF: https://github.com/llvm/llvm-project/commit/e529cda970e4422647bcc296cc306d08f2757be9.diff
LOG: [NFC] Add test cases for D147827
Added:
Modified:
llvm/test/CodeGen/X86/add-and-not.ll
llvm/test/CodeGen/X86/and-or-fold.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/add-and-not.ll b/llvm/test/CodeGen/X86/add-and-not.ll
index 5025773b4327..4f2a3074dabb 100644
--- a/llvm/test/CodeGen/X86/add-and-not.ll
+++ b/llvm/test/CodeGen/X86/add-and-not.ll
@@ -308,15 +308,15 @@ define ptr @gep_and_xor_const(ptr %a) {
ret ptr %p
}
-define i64 @add_and_xor_const_ext_trunc(i64 %x) {
-; X86-LABEL: add_and_xor_const_ext_trunc:
+define i64 @add_and_xor_const_zext_trunc(i64 %x) {
+; X86-LABEL: add_and_xor_const_zext_trunc:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
; X86-NEXT: orl $1, %eax
; X86-NEXT: retl
;
-; X64-LABEL: add_and_xor_const_ext_trunc:
+; X64-LABEL: add_and_xor_const_zext_trunc:
; X64: # %bb.0:
; X64-NEXT: movl %edi, %eax
; X64-NEXT: notl %eax
@@ -330,3 +330,27 @@ define i64 @add_and_xor_const_ext_trunc(i64 %x) {
%add = add i64 %ext, %x
ret i64 %add
}
+
+define i64 @add_and_xor_const_zext_trunc_var(i64 %x, i64 %y) {
+; X86-LABEL: add_and_xor_const_zext_trunc_var:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: orl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: add_and_xor_const_zext_trunc_var:
+; X64: # %bb.0:
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: notl %eax
+; X64-NEXT: andl %esi, %eax
+; X64-NEXT: orq %rdi, %rax
+; X64-NEXT: retq
+ %tx = trunc i64 %x to i32
+ %ty = trunc i64 %y to i32
+ %xor = xor i32 %tx, -1
+ %and = and i32 %ty, %xor
+ %ext = zext i32 %and to i64
+ %add = add i64 %ext, %x
+ ret i64 %add
+}
diff --git a/llvm/test/CodeGen/X86/and-or-fold.ll b/llvm/test/CodeGen/X86/and-or-fold.ll
index 314e05b772b9..1bb5fdeebac7 100644
--- a/llvm/test/CodeGen/X86/and-or-fold.ll
+++ b/llvm/test/CodeGen/X86/and-or-fold.ll
@@ -2,6 +2,40 @@
; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck -check-prefix=DARWIN %s
; RUN: opt < %s -O2 | llc -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN-OPT %s
+define i64 @or_and_fold(i64 %x, i64 %y) {
+; DARWIN-LABEL: or_and_fold:
+; DARWIN: ## %bb.0:
+; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
+; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %edx
+; DARWIN-NEXT: retl
+;
+; DARWIN-OPT-LABEL: or_and_fold:
+; DARWIN-OPT: ## %bb.0:
+; DARWIN-OPT-NEXT: movq %rdi, %rax
+; DARWIN-OPT-NEXT: retq
+ %and = and i64 %x, %y
+ %or = or i64 %x, %and
+ ret i64 %or
+}
+
+define i32 @or_and_trunc_fold(i64 %x, i64 %y) {
+; DARWIN-LABEL: or_and_trunc_fold:
+; DARWIN: ## %bb.0:
+; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
+; DARWIN-NEXT: retl
+;
+; DARWIN-OPT-LABEL: or_and_trunc_fold:
+; DARWIN-OPT: ## %bb.0:
+; DARWIN-OPT-NEXT: movq %rdi, %rax
+; DARWIN-OPT-NEXT: ## kill: def $eax killed $eax killed $rax
+; DARWIN-OPT-NEXT: retq
+ %tx = trunc i64 %x to i32
+ %and = and i64 %x, %y
+ %tand = trunc i64 %and to i32
+ %or = or i32 %tx, %tand
+ ret i32 %or
+}
+
; The dag combiner should fold together (x&127)|(y&16711680) -> (x|y)&c1
; in this case.
More information about the llvm-commits
mailing list