[X86] Add scalar (abs (abs x)) -> (abs x) combine test.

Before landing D38895

llvm-svn: 316160
This commit is contained in:
Simon Pilgrim 2017-10-19 14:59:26 +00:00
parent ee7c7ecd03
commit d0649f978f
1 changed files with 19 additions and 0 deletions

View File

@ -23,6 +23,25 @@ define <16 x i16> @combine_v16i16_abs_constant() {
}
; fold (abs (abs x)) -> (abs x)
define i32 @combine_i32_abs_abs(i32 %a) {
; CHECK-LABEL: combine_i32_abs_abs:
; CHECK: # BB#0:
; CHECK-NEXT: movl %edi, %ecx
; CHECK-NEXT: negl %ecx
; CHECK-NEXT: cmovll %edi, %ecx
; CHECK-NEXT: movl %ecx, %eax
; CHECK-NEXT: negl %eax
; CHECK-NEXT: cmovll %ecx, %eax
; CHECK-NEXT: retq
%n1 = sub i32 zeroinitializer, %a
%b1 = icmp slt i32 %a, zeroinitializer
%a1 = select i1 %b1, i32 %n1, i32 %a
%n2 = sub i32 zeroinitializer, %a1
%b2 = icmp sgt i32 %a1, zeroinitializer
%a2 = select i1 %b2, i32 %a1, i32 %n2
ret i32 %a2
}
define <8 x i16> @combine_v8i16_abs_abs(<8 x i16> %a) {
; CHECK-LABEL: combine_v8i16_abs_abs:
; CHECK: # BB#0: