1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck -check-prefix=DARWIN %s
3 ; RUN: opt < %s -O2 | llc -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN-OPT %s
5 define i64 @or_and_fold(i64 %x, i64 %y) {
6 ; DARWIN-LABEL: or_and_fold:
8 ; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %edx
12 ; DARWIN-OPT-LABEL: or_and_fold:
13 ; DARWIN-OPT: ## %bb.0:
14 ; DARWIN-OPT-NEXT: movq %rdi, %rax
15 ; DARWIN-OPT-NEXT: retq
21 define i32 @or_and_trunc_fold(i64 %x, i64 %y) {
22 ; DARWIN-LABEL: or_and_trunc_fold:
24 ; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
27 ; DARWIN-OPT-LABEL: or_and_trunc_fold:
28 ; DARWIN-OPT: ## %bb.0:
29 ; DARWIN-OPT-NEXT: movq %rdi, %rax
30 ; DARWIN-OPT-NEXT: ## kill: def $eax killed $eax killed $rax
31 ; DARWIN-OPT-NEXT: retq
32 %tx = trunc i64 %x to i32
34 %tand = trunc i64 %and to i32
35 %or = or i32 %tx, %tand
39 ; The dag combiner should fold together (x&127)|(y&16711680) -> (x|y)&c1
42 define i32 @test1(i32 %x, i16 %y) {
43 ; DARWIN-LABEL: test1:
45 ; DARWIN-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
46 ; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
47 ; DARWIN-NEXT: shll $16, %eax
48 ; DARWIN-NEXT: orl %ecx, %eax
49 ; DARWIN-NEXT: andl $16711807, %eax ## imm = 0xFF007F
52 ; DARWIN-OPT-LABEL: test1:
53 ; DARWIN-OPT: ## %bb.0:
54 ; DARWIN-OPT-NEXT: andl $127, %esi
55 ; DARWIN-OPT-NEXT: movzbl %dil, %eax
56 ; DARWIN-OPT-NEXT: shll $16, %eax
57 ; DARWIN-OPT-NEXT: orl %esi, %eax
58 ; DARWIN-OPT-NEXT: retq
59 %tmp1 = zext i16 %y to i32
60 %tmp2 = and i32 %tmp1, 127
61 %tmp4 = shl i32 %x, 16
62 %tmp5 = and i32 %tmp4, 16711680
63 %tmp6 = or i32 %tmp2, %tmp5
67 ; <rdar://problem/7529774> The optimizer shouldn't fold this into (and (or, C), D)
69 define i64 @test2(i64 %x) nounwind readnone ssp {
70 ; DARWIN-LABEL: test2:
71 ; DARWIN: ## %bb.0: ## %entry
72 ; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax
73 ; DARWIN-NEXT: orl $3, %eax
74 ; DARWIN-NEXT: andl $123127, %eax ## imm = 0x1E0F7
75 ; DARWIN-NEXT: xorl %edx, %edx
78 ; DARWIN-OPT-LABEL: test2:
79 ; DARWIN-OPT: ## %bb.0: ## %entry
80 ; DARWIN-OPT-NEXT: andl $123124, %edi ## imm = 0x1E0F4
81 ; DARWIN-OPT-NEXT: leaq 3(%rdi), %rax
82 ; DARWIN-OPT-NEXT: retq
84 %tmp1 = and i64 %x, 123127
85 %tmp2 = or i64 %tmp1, 3