[llvm] r330771 - [X86][AArch64][NFC] Add tests for masked merge unfolding with %y = const

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 14:23:22 PDT 2018


Author: lebedevri
Date: Tue Apr 24 14:23:22 2018
New Revision: 330771

URL: http://llvm.org/viewvc/llvm-project?rev=330771&view=rev
Log:
[X86][AArch64][NFC] Add tests for masked merge unfolding with %y = const

The fold was added in D45733.

This appears to be a regression.

Modified:
    llvm/trunk/test/CodeGen/AArch64/unfold-masked-merge-scalar-variablemask.ll
    llvm/trunk/test/CodeGen/X86/unfold-masked-merge-scalar-variablemask.ll

Modified: llvm/trunk/test/CodeGen/AArch64/unfold-masked-merge-scalar-variablemask.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/unfold-masked-merge-scalar-variablemask.ll?rev=330771&r1=330770&r2=330771&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/unfold-masked-merge-scalar-variablemask.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/unfold-masked-merge-scalar-variablemask.ll Tue Apr 24 14:23:22 2018
@@ -330,6 +330,61 @@ define i32 @in_complex_y1_m1(i32 %x, i32
   ret i32 %r
 }
 ; ============================================================================ ;
+; Both xor's have the same constant operand
+; ============================================================================ ;
+define i32 @out_constant_y_mone(i32 %x, i32 %mask) {
+; CHECK-LABEL: out_constant_y_mone:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    and w8, w0, w1
+; CHECK-NEXT:    orn w0, w8, w1
+; CHECK-NEXT:    ret
+  %mx = and i32 %x, %mask
+  %notmask = xor i32 %mask, -1
+  %my = and i32 %notmask, -1 ; %y
+  %r = or i32 %mx, %my
+  ret i32 %r
+}
+; FIXME: should be bic+mvn
+define i32 @in_constant_y_mone(i32 %x, i32 %mask) {
+; CHECK-LABEL: in_constant_y_mone:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    and w8, w0, w1
+; CHECK-NEXT:    orn w0, w8, w1
+; CHECK-NEXT:    ret
+  %n0 = xor i32 %x, -1 ; %y
+  %n1 = and i32 %n0, %mask
+  %r = xor i32 %n1, -1 ; %y
+  ret i32 %r
+}
+define i32 @out_constant_y_one(i32 %x, i32 %mask) {
+; CHECK-LABEL: out_constant_y_one:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    mvn w9, w1
+; CHECK-NEXT:    and w8, w0, w1
+; CHECK-NEXT:    and w9, w9, #0x1
+; CHECK-NEXT:    orr w0, w8, w9
+; CHECK-NEXT:    ret
+  %mx = and i32 %x, %mask
+  %notmask = xor i32 %mask, -1
+  %my = and i32 %notmask, 1 ; %y
+  %r = or i32 %mx, %my
+  ret i32 %r
+}
+; FIXME: should be eor+and+eor
+define i32 @in_constant_y_one(i32 %x, i32 %mask) {
+; CHECK-LABEL: in_constant_y_one:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    mvn w9, w1
+; CHECK-NEXT:    and w8, w0, w1
+; CHECK-NEXT:    and w9, w9, #0x1
+; CHECK-NEXT:    orr w0, w8, w9
+; CHECK-NEXT:    ret
+  %n0 = xor i32 %x, 1 ; %y
+  %n1 = and i32 %n0, %mask
+  %r = xor i32 %n1, 1 ; %y
+  ret i32 %r
+}
+; ============================================================================ ;
 ; Negative tests. Should not be folded.
 ; ============================================================================ ;
 ; Multi-use tests.

Modified: llvm/trunk/test/CodeGen/X86/unfold-masked-merge-scalar-variablemask.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unfold-masked-merge-scalar-variablemask.ll?rev=330771&r1=330770&r2=330771&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/unfold-masked-merge-scalar-variablemask.ll (original)
+++ llvm/trunk/test/CodeGen/X86/unfold-masked-merge-scalar-variablemask.ll Tue Apr 24 14:23:22 2018
@@ -535,6 +535,100 @@ define i32 @in_complex_y1_m1(i32 %x, i32
   ret i32 %r
 }
 ; ============================================================================ ;
+; Both xor's have the same constant operand
+; ============================================================================ ;
+define i32 @out_constant_y_mone(i32 %x, i32 %mask) {
+; CHECK-NOBMI-LABEL: out_constant_y_mone:
+; CHECK-NOBMI:       # %bb.0:
+; CHECK-NOBMI-NEXT:    andl %esi, %edi
+; CHECK-NOBMI-NEXT:    notl %esi
+; CHECK-NOBMI-NEXT:    orl %edi, %esi
+; CHECK-NOBMI-NEXT:    movl %esi, %eax
+; CHECK-NOBMI-NEXT:    retq
+;
+; CHECK-BMI-LABEL: out_constant_y_mone:
+; CHECK-BMI:       # %bb.0:
+; CHECK-BMI-NEXT:    andl %esi, %edi
+; CHECK-BMI-NEXT:    notl %esi
+; CHECK-BMI-NEXT:    orl %edi, %esi
+; CHECK-BMI-NEXT:    movl %esi, %eax
+; CHECK-BMI-NEXT:    retq
+  %mx = and i32 %x, %mask
+  %notmask = xor i32 %mask, -1
+  %my = and i32 %notmask, -1 ; %y
+  %r = or i32 %mx, %my
+  ret i32 %r
+}
+; FIXME: should be andnl+notl if BMI
+define i32 @in_constant_y_mone(i32 %x, i32 %mask) {
+; CHECK-NOBMI-LABEL: in_constant_y_mone:
+; CHECK-NOBMI:       # %bb.0:
+; CHECK-NOBMI-NEXT:    notl %edi
+; CHECK-NOBMI-NEXT:    andl %esi, %edi
+; CHECK-NOBMI-NEXT:    notl %edi
+; CHECK-NOBMI-NEXT:    movl %edi, %eax
+; CHECK-NOBMI-NEXT:    retq
+;
+; CHECK-BMI-LABEL: in_constant_y_mone:
+; CHECK-BMI:       # %bb.0:
+; CHECK-BMI-NEXT:    andl %esi, %edi
+; CHECK-BMI-NEXT:    notl %esi
+; CHECK-BMI-NEXT:    orl %edi, %esi
+; CHECK-BMI-NEXT:    movl %esi, %eax
+; CHECK-BMI-NEXT:    retq
+  %n0 = xor i32 %x, -1 ; %y
+  %n1 = and i32 %n0, %mask
+  %r = xor i32 %n1, -1 ; %y
+  ret i32 %r
+}
+define i32 @out_constant_y_one(i32 %x, i32 %mask) {
+; CHECK-NOBMI-LABEL: out_constant_y_one:
+; CHECK-NOBMI:       # %bb.0:
+; CHECK-NOBMI-NEXT:    andl %esi, %edi
+; CHECK-NOBMI-NEXT:    notl %esi
+; CHECK-NOBMI-NEXT:    andl $1, %esi
+; CHECK-NOBMI-NEXT:    orl %edi, %esi
+; CHECK-NOBMI-NEXT:    movl %esi, %eax
+; CHECK-NOBMI-NEXT:    retq
+;
+; CHECK-BMI-LABEL: out_constant_y_one:
+; CHECK-BMI:       # %bb.0:
+; CHECK-BMI-NEXT:    andl %esi, %edi
+; CHECK-BMI-NEXT:    notl %esi
+; CHECK-BMI-NEXT:    andl $1, %esi
+; CHECK-BMI-NEXT:    orl %edi, %esi
+; CHECK-BMI-NEXT:    movl %esi, %eax
+; CHECK-BMI-NEXT:    retq
+  %mx = and i32 %x, %mask
+  %notmask = xor i32 %mask, -1
+  %my = and i32 %notmask, 1 ; %y
+  %r = or i32 %mx, %my
+  ret i32 %r
+}
+; FIXME: NOBMI and BMI should match, or BMI should be better.
+define i32 @in_constant_y_one(i32 %x, i32 %mask) {
+; CHECK-NOBMI-LABEL: in_constant_y_one:
+; CHECK-NOBMI:       # %bb.0:
+; CHECK-NOBMI-NEXT:    xorl $1, %edi
+; CHECK-NOBMI-NEXT:    andl %esi, %edi
+; CHECK-NOBMI-NEXT:    xorl $1, %edi
+; CHECK-NOBMI-NEXT:    movl %edi, %eax
+; CHECK-NOBMI-NEXT:    retq
+;
+; CHECK-BMI-LABEL: in_constant_y_one:
+; CHECK-BMI:       # %bb.0:
+; CHECK-BMI-NEXT:    andl %esi, %edi
+; CHECK-BMI-NEXT:    notl %esi
+; CHECK-BMI-NEXT:    andl $1, %esi
+; CHECK-BMI-NEXT:    orl %edi, %esi
+; CHECK-BMI-NEXT:    movl %esi, %eax
+; CHECK-BMI-NEXT:    retq
+  %n0 = xor i32 %x, 1 ; %y
+  %n1 = and i32 %n0, %mask
+  %r = xor i32 %n1, 1 ; %y
+  ret i32 %r
+}
+; ============================================================================ ;
 ; Negative tests. Should not be folded.
 ; ============================================================================ ;
 ; Multi-use tests.




More information about the llvm-commits mailing list