88 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck -check-prefix=DARWIN %s3; RUN: opt < %s -O2 | llc -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN-OPT %s4 5define i64 @or_and_fold(i64 %x, i64 %y) {6; DARWIN-LABEL: or_and_fold:7; DARWIN: ## %bb.0:8; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax9; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %edx10; DARWIN-NEXT: retl11;12; DARWIN-OPT-LABEL: or_and_fold:13; DARWIN-OPT: ## %bb.0:14; DARWIN-OPT-NEXT: movq %rdi, %rax15; DARWIN-OPT-NEXT: retq16 %and = and i64 %x, %y17 %or = or i64 %x, %and18 ret i64 %or19}20 21define i32 @or_and_trunc_fold(i64 %x, i64 %y) {22; DARWIN-LABEL: or_and_trunc_fold:23; DARWIN: ## %bb.0:24; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax25; DARWIN-NEXT: retl26;27; DARWIN-OPT-LABEL: or_and_trunc_fold:28; DARWIN-OPT: ## %bb.0:29; DARWIN-OPT-NEXT: movq %rdi, %rax30; DARWIN-OPT-NEXT: ## kill: def $eax killed $eax killed $rax31; DARWIN-OPT-NEXT: retq32 %tx = trunc i64 %x to i3233 %and = and i64 %x, %y34 %tand = trunc i64 %and to i3235 %or = or i32 %tx, %tand36 ret i32 %or37}38 39; The dag combiner should fold together (x&127)|(y&16711680) -> (x|y)&c140; in this case.41 42define i32 @test1(i32 %x, i16 %y) {43; DARWIN-LABEL: test1:44; DARWIN: ## %bb.0:45; DARWIN-NEXT: movzwl {{[0-9]+}}(%esp), %ecx46; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax47; DARWIN-NEXT: shll $16, %eax48; DARWIN-NEXT: orl %ecx, %eax49; DARWIN-NEXT: andl $16711807, %eax ## imm = 0xFF007F50; DARWIN-NEXT: retl51;52; DARWIN-OPT-LABEL: test1:53; DARWIN-OPT: ## %bb.0:54; DARWIN-OPT-NEXT: andl $127, %esi55; DARWIN-OPT-NEXT: movzbl %dil, %eax56; DARWIN-OPT-NEXT: shll $16, %eax57; DARWIN-OPT-NEXT: orl %esi, %eax58; DARWIN-OPT-NEXT: retq59 %tmp1 = zext i16 %y to i3260 %tmp2 = and i32 %tmp1, 12761 %tmp4 = shl i32 %x, 1662 %tmp5 = and i32 %tmp4, 1671168063 %tmp6 = or i32 %tmp2, %tmp564 ret i32 %tmp665}66 67; <rdar://problem/7529774> The optimizer shouldn't fold this into (and (or, C), D)68; if (C & D) == 069define i64 @test2(i64 %x) nounwind readnone ssp {70; DARWIN-LABEL: test2:71; DARWIN: ## %bb.0: ## %entry72; DARWIN-NEXT: movl {{[0-9]+}}(%esp), %eax73; DARWIN-NEXT: orl $3, %eax74; DARWIN-NEXT: andl $123127, %eax ## imm = 0x1E0F775; DARWIN-NEXT: xorl %edx, %edx76; DARWIN-NEXT: retl77;78; DARWIN-OPT-LABEL: test2:79; DARWIN-OPT: ## %bb.0: ## %entry80; DARWIN-OPT-NEXT: andl $123124, %edi ## imm = 0x1E0F481; DARWIN-OPT-NEXT: leaq 3(%rdi), %rax82; DARWIN-OPT-NEXT: retq83entry:84 %tmp1 = and i64 %x, 12312785 %tmp2 = or i64 %tmp1, 386 ret i64 %tmp287}88