}
// For example, "testl %eax, $32776" to "testw %ax, $32776".
- if (isUInt<16>(Mask) && N0.getValueType() != MVT::i16 &&
+ // NOTE: We only want to form TESTW instructions if optimizing for
+ // min size. Otherwise we only save one byte and possibly get a length
+ // changing prefix penalty in the decoders.
+ if (OptForMinSize && isUInt<16>(Mask) && N0.getValueType() != MVT::i16 &&
(!(Mask & 0x8000) || hasNoSignedComparisonUses(Node))) {
SDValue Imm = CurDAG->getTargetConstant(Mask, dl, MVT::i16);
SDValue Reg = N0.getOperand(0);
; CHECK-LABEL: test_x86_tbm_bextri_u32_z2:
; CHECK: # BB#0:
; CHECK-NEXT: shrl $4, %edi
-; CHECK-NEXT: testw $4095, %di # imm = 0xFFF
+; CHECK-NEXT: testl $4095, %edi # imm = 0xFFF
; CHECK-NEXT: cmovnel %edx, %esi
; CHECK-NEXT: movl %esi, %eax
; CHECK-NEXT: retq
; CHECK-LABEL: test_x86_tbm_bextri_u64_z2:
; CHECK: # BB#0:
; CHECK-NEXT: shrl $4, %edi
-; CHECK-NEXT: testw $4095, %di # imm = 0xFFF
+; CHECK-NEXT: testl $4095, %edi # imm = 0xFFF
; CHECK-NEXT: cmovneq %rdx, %rsi
; CHECK-NEXT: movq %rsi, %rax
; CHECK-NEXT: retq
ret void
}
; CHECK-64-LABEL: g64x16:
-; CHECK-64: testw $-32640, %[[A0W:di|cx]]
+; CHECK-64: testl $32896, %[[A0D:edi|ecx]]
; CHECK-64: ret
; CHECK-32-LABEL: g64x16:
-; CHECK-32: testw $-32640, %ax
+; CHECK-32: testl $32896, %eax
; CHECK-32: ret
define void @g64x16(i64 inreg %x) nounwind {
%t = and i64 %x, 32896
%s = icmp eq i64 %t, 0
br i1 %s, label %yes, label %no
+yes:
+ call void @bar()
+ ret void
+no:
+ ret void
+}
+; CHECK-64-LABEL: g64x16minsize:
+; CHECK-64: testw $-32640, %[[A0W:di|cx]]
+; CHECK-64: ret
+; CHECK-32-LABEL: g64x16minsize:
+; CHECK-32: testw $-32640, %ax
+; CHECK-32: ret
+define void @g64x16minsize(i64 inreg %x) nounwind minsize {
+ %t = and i64 %x, 32896
+ %s = icmp eq i64 %t, 0
+ br i1 %s, label %yes, label %no
+
yes:
call void @bar()
ret void
ret void
}
; CHECK-64-LABEL: g32x16:
-; CHECK-64: testw $-32640, %[[A0W]]
+; CHECK-64: testl $32896, %[[A0D]]
; CHECK-64: ret
; CHECK-32-LABEL: g32x16:
-; CHECK-32: testw $-32640, %ax
+; CHECK-32: testl $32896, %eax
; CHECK-32: ret
define void @g32x16(i32 inreg %x) nounwind {
%t = and i32 %x, 32896
%s = icmp eq i32 %t, 0
br i1 %s, label %yes, label %no
+yes:
+ call void @bar()
+ ret void
+no:
+ ret void
+}
+; CHECK-64-LABEL: g32x16minsize:
+; CHECK-64: testw $-32640, %[[A0W]]
+; CHECK-64: ret
+; CHECK-32-LABEL: g32x16minsize:
+; CHECK-32: testw $-32640, %ax
+; CHECK-32: ret
+define void @g32x16minsize(i32 inreg %x) nounwind minsize {
+ %t = and i32 %x, 32896
+ %s = icmp eq i32 %t, 0
+ br i1 %s, label %yes, label %no
+
yes:
call void @bar()
ret void
ret void
}
; CHECK-64-LABEL: g64x32:
-; CHECK-64: testl $268468352, %e[[A0W]]
+; CHECK-64: testl $268468352, %[[A0D]]
; CHECK-64: ret
; CHECK-32-LABEL: g64x32:
; CHECK-32: testl $268468352, %eax