diff --git a/llvm/test/CodeGen/X86/select-constant-xor.ll b/llvm/test/CodeGen/X86/select-constant-xor.ll --- a/llvm/test/CodeGen/X86/select-constant-xor.ll +++ b/llvm/test/CodeGen/X86/select-constant-xor.ll @@ -256,6 +256,53 @@ %x = add i32 %s, %s2 ret i32 %x } + +define i32 @selecti16i32_offby1(i16 %a) { +; X86-LABEL: selecti16i32_offby1: +; X86: # %bb.0: +; X86-NEXT: xorl %ecx, %ecx +; X86-NEXT: cmpw $0, {{[0-9]+}}(%esp) +; X86-NEXT: setns %cl +; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000 +; X86-NEXT: subl %ecx, %eax +; X86-NEXT: retl +; +; X64-LABEL: selecti16i32_offby1: +; X64: # %bb.0: +; X64-NEXT: xorl %ecx, %ecx +; X64-NEXT: testw %di, %di +; X64-NEXT: setns %cl +; X64-NEXT: movl $-2147483648, %eax # imm = 0x80000000 +; X64-NEXT: subl %ecx, %eax +; X64-NEXT: retq + %c = icmp sgt i16 %a, -1 + %s = select i1 %c, i32 2147483647, i32 -2147483648 + ret i32 %s +} + +define i32 @selecti8i32_offby1(i8 %a) { +; X86-LABEL: selecti8i32_offby1: +; X86: # %bb.0: +; X86-NEXT: xorl %ecx, %ecx +; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp) +; X86-NEXT: setns %cl +; X86-NEXT: movl $-2147483648, %eax # imm = 0x80000000 +; X86-NEXT: subl %ecx, %eax +; X86-NEXT: retl +; +; X64-LABEL: selecti8i32_offby1: +; X64: # %bb.0: +; X64-NEXT: xorl %ecx, %ecx +; X64-NEXT: testb %dil, %dil +; X64-NEXT: setns %cl +; X64-NEXT: movl $-2147483648, %eax # imm = 0x80000000 +; X64-NEXT: subl %ecx, %eax +; X64-NEXT: retq + %c = icmp sgt i8 %a, -1 + %s = select i1 %c, i32 2147483647, i32 -2147483648 + ret i32 %s +} + ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; X64-FASTINC: {{.*}} ; X64-SLOWINC: {{.*}}