1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=i686-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X86
; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X64
; Fold
; ~(X - 1)
; To
; - X
;
; This needs to be a backend-level fold because only by now pointers
; are just registers; in middle-end IR this can only be done via @llvm.ptrmask()
; intrinsic which is not sufficiently widely-spread yet.
;
; https://bugs.llvm.org/show_bug.cgi?id=44448
; The basic positive tests
define i32 @t0_32(i32 %alignment) nounwind {
; X86-LABEL: t0_32:
; X86: # %bb.0:
; X86-NEXT: xorl %eax, %eax
; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
; X86-NEXT: retl
;
; X64-LABEL: t0_32:
; X64: # %bb.0:
; X64-NEXT: movl %edi, %eax
; X64-NEXT: negl %eax
; X64-NEXT: retq
%mask = add i32 %alignment, -1
%invmask = xor i32 %mask, -1
ret i32 %invmask
}
define i64 @t1_64(i64 %alignment) nounwind {
; X86-LABEL: t1_64:
; X86: # %bb.0:
; X86-NEXT: xorl %edx, %edx
; X86-NEXT: xorl %eax, %eax
; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx
; X86-NEXT: retl
;
; X64-LABEL: t1_64:
; X64: # %bb.0:
; X64-NEXT: movq %rdi, %rax
; X64-NEXT: negq %rax
; X64-NEXT: retq
%mask = add i64 %alignment, -1
%invmask = xor i64 %mask, -1
ret i64 %invmask
}
; Extra use test
define i32 @t2_extrause(i32 %alignment, i32* %mask_storage) nounwind {
; X86-LABEL: t2_extrause:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: leal -1(%eax), %edx
; X86-NEXT: movl %edx, (%ecx)
; X86-NEXT: negl %eax
; X86-NEXT: retl
;
; X64-LABEL: t2_extrause:
; X64: # %bb.0:
; X64-NEXT: movl %edi, %eax
; X64-NEXT: leal -1(%rax), %ecx
; X64-NEXT: movl %ecx, (%rsi)
; X64-NEXT: negl %eax
; X64-NEXT: # kill: def $eax killed $eax killed $rax
; X64-NEXT: retq
%mask = add i32 %alignment, -1
store i32 %mask, i32* %mask_storage
%invmask = xor i32 %mask, -1
ret i32 %invmask
}
; Negative tests
define i32 @n3_not_dec(i32 %alignment) nounwind {
; X86-LABEL: n3_not_dec:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: incl %eax
; X86-NEXT: notl %eax
; X86-NEXT: retl
;
; X64-LABEL: n3_not_dec:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
; X64-NEXT: leal 1(%rdi), %eax
; X64-NEXT: notl %eax
; X64-NEXT: retq
%mask = add i32 %alignment, 1 ; not -1
%invmask = xor i32 %mask, -1
ret i32 %invmask
}
define i32 @n4_not_not(i32 %alignment) nounwind {
; X86-LABEL: n4_not_not:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: decl %eax
; X86-NEXT: xorl $1, %eax
; X86-NEXT: retl
;
; X64-LABEL: n4_not_not:
; X64: # %bb.0:
; X64-NEXT: # kill: def $edi killed $edi def $rdi
; X64-NEXT: leal -1(%rdi), %eax
; X64-NEXT: xorl $1, %eax
; X64-NEXT: retq
%mask = add i32 %alignment, -1
%invmask = xor i32 %mask, 1 ; not -1
ret i32 %invmask
}
|