1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-popcnt,+sse2 | FileCheck %s --check-prefix=NOPOPCNT
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+popcnt,+sse2 | FileCheck %s --check-prefix=POPCNT
define i1 @noncanonical_parity(<16 x i1> %x) {
; NOPOPCNT-LABEL: noncanonical_parity:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: xorb %ah, %al
; NOPOPCNT-NEXT: setnp %al
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: noncanonical_parity:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: andl $1, %eax
; POPCNT-NEXT: # kill: def $al killed $al killed $eax
; POPCNT-NEXT: retq
%r = call i1 @llvm.vector.reduce.xor.v16i1(<16 x i1> %x)
ret i1 %r
}
define i1 @canonical_parity(<16 x i1> %x) {
; NOPOPCNT-LABEL: canonical_parity:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: xorb %ah, %al
; NOPOPCNT-NEXT: setnp %al
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: canonical_parity:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: andl $1, %eax
; POPCNT-NEXT: # kill: def $al killed $al killed $eax
; POPCNT-NEXT: retq
%i1 = bitcast <16 x i1> %x to i16
%i2 = call i16 @llvm.ctpop.i16(i16 %i1)
%i3 = and i16 %i2, 1
%i4 = icmp ne i16 %i3, 0
ret i1 %i4
}
define i1 @canonical_parity_noncanonical_pred(<16 x i1> %x) {
; NOPOPCNT-LABEL: canonical_parity_noncanonical_pred:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: movl %eax, %ecx
; NOPOPCNT-NEXT: shrl %ecx
; NOPOPCNT-NEXT: andl $21845, %ecx # imm = 0x5555
; NOPOPCNT-NEXT: subl %ecx, %eax
; NOPOPCNT-NEXT: movl %eax, %ecx
; NOPOPCNT-NEXT: andl $13107, %ecx # imm = 0x3333
; NOPOPCNT-NEXT: shrl $2, %eax
; NOPOPCNT-NEXT: andl $13107, %eax # imm = 0x3333
; NOPOPCNT-NEXT: addl %ecx, %eax
; NOPOPCNT-NEXT: movl %eax, %ecx
; NOPOPCNT-NEXT: shrl $4, %ecx
; NOPOPCNT-NEXT: addl %eax, %ecx
; NOPOPCNT-NEXT: andl $3855, %ecx # imm = 0xF0F
; NOPOPCNT-NEXT: movl %ecx, %eax
; NOPOPCNT-NEXT: shll $8, %eax
; NOPOPCNT-NEXT: addl %ecx, %eax
; NOPOPCNT-NEXT: shrl $8, %eax
; NOPOPCNT-NEXT: # kill: def $al killed $al killed $eax
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: canonical_parity_noncanonical_pred:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: # kill: def $al killed $al killed $eax
; POPCNT-NEXT: retq
%i1 = bitcast <16 x i1> %x to i16
%i2 = call i16 @llvm.ctpop.i16(i16 %i1)
%i3 = and i16 %i2, 1
%i4 = icmp eq i16 %i3, 1
ret i1 %i4
}
define i1 @noncanonical_nonparity(<16 x i1> %x) {
; NOPOPCNT-LABEL: noncanonical_nonparity:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: xorb %ah, %al
; NOPOPCNT-NEXT: setp %al
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: noncanonical_nonparity:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: andl $1, %eax
; POPCNT-NEXT: xorb $1, %al
; POPCNT-NEXT: # kill: def $al killed $al killed $eax
; POPCNT-NEXT: retq
%r.inv = call i1 @llvm.vector.reduce.xor.v16i1(<16 x i1> %x)
%r = xor i1 %r.inv, -1
ret i1 %r
}
define i1 @canonical_nonparity(<16 x i1> %x) {
; NOPOPCNT-LABEL: canonical_nonparity:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: xorb %ah, %al
; NOPOPCNT-NEXT: setp %al
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: canonical_nonparity:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: testb $1, %al
; POPCNT-NEXT: sete %al
; POPCNT-NEXT: retq
%i1 = bitcast <16 x i1> %x to i16
%i2 = call i16 @llvm.ctpop.i16(i16 %i1)
%i3 = and i16 %i2, 1
%i4 = icmp eq i16 %i3, 0
ret i1 %i4
}
define i1 @canonical_nonparity_noncanonical_pred(<16 x i1> %x) {
; NOPOPCNT-LABEL: canonical_nonparity_noncanonical_pred:
; NOPOPCNT: # %bb.0:
; NOPOPCNT-NEXT: psllw $7, %xmm0
; NOPOPCNT-NEXT: pmovmskb %xmm0, %eax
; NOPOPCNT-NEXT: xorb %ah, %al
; NOPOPCNT-NEXT: setp %al
; NOPOPCNT-NEXT: retq
;
; POPCNT-LABEL: canonical_nonparity_noncanonical_pred:
; POPCNT: # %bb.0:
; POPCNT-NEXT: psllw $7, %xmm0
; POPCNT-NEXT: pmovmskb %xmm0, %eax
; POPCNT-NEXT: popcntl %eax, %eax
; POPCNT-NEXT: andl $1, %eax
; POPCNT-NEXT: xorb $1, %al
; POPCNT-NEXT: # kill: def $al killed $al killed $eax
; POPCNT-NEXT: retq
%i1 = bitcast <16 x i1> %x to i16
%i2 = call i16 @llvm.ctpop.i16(i16 %i1)
%i3 = and i16 %i2, 1
%i4 = icmp ne i16 %i3, 1
ret i1 %i4
}
declare i1 @llvm.vector.reduce.xor.v16i1(<16 x i1>)
declare i16 @llvm.ctpop.i16(i16)
|