llvm.org GIT mirror llvm / a38100a
[X86] Add test cases for D58874 Add scalar and vector test cases for missing (add (add (xor a, -1), b), 1) -> (sub b, a) fold git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355400 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 7 months ago
1 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
348348 %3 = add <4 x i32> %2, %a1
349349 ret <4 x i32> %3
350350 }
351
352 ; TODO: (add (add (xor a, -1), b), 1) -> (sub b, a)
353 define i32 @combine_add_add_not(i32 %a, i32 %b) {
354 ; SSE-LABEL: combine_add_add_not:
355 ; SSE: # %bb.0:
356 ; SSE-NEXT: # kill: def $esi killed $esi def $rsi
357 ; SSE-NEXT: # kill: def $edi killed $edi def $rdi
358 ; SSE-NEXT: notl %edi
359 ; SSE-NEXT: leal 1(%rdi,%rsi), %eax
360 ; SSE-NEXT: retq
361 ;
362 ; AVX-LABEL: combine_add_add_not:
363 ; AVX: # %bb.0:
364 ; AVX-NEXT: # kill: def $esi killed $esi def $rsi
365 ; AVX-NEXT: # kill: def $edi killed $edi def $rdi
366 ; AVX-NEXT: notl %edi
367 ; AVX-NEXT: leal 1(%rdi,%rsi), %eax
368 ; AVX-NEXT: retq
369 %nota = xor i32 %a, -1
370 %add = add i32 %nota, %b
371 %r = add i32 %add, 1
372 ret i32 %r
373 }
374
375 define <4 x i32> @combine_vec_add_add_not(<4 x i32> %a, <4 x i32> %b) {
376 ; SSE-LABEL: combine_vec_add_add_not:
377 ; SSE: # %bb.0:
378 ; SSE-NEXT: pcmpeqd %xmm2, %xmm2
379 ; SSE-NEXT: pxor %xmm2, %xmm0
380 ; SSE-NEXT: paddd %xmm1, %xmm0
381 ; SSE-NEXT: paddd {{.*}}(%rip), %xmm0
382 ; SSE-NEXT: retq
383 ;
384 ; AVX-LABEL: combine_vec_add_add_not:
385 ; AVX: # %bb.0:
386 ; AVX-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
387 ; AVX-NEXT: vpxor %xmm2, %xmm0, %xmm0
388 ; AVX-NEXT: vpaddd %xmm1, %xmm0, %xmm0
389 ; AVX-NEXT: vpaddd {{.*}}(%rip), %xmm0, %xmm0
390 ; AVX-NEXT: retq
391 %nota = xor <4 x i32> %a,
392 %add = add <4 x i32> %nota, %b
393 %r = add <4 x i32> %add,
394 ret <4 x i32> %r
395 }