test for a variety of new transformations:

* A & ~A == 0
  * A / (2^c) == A >> c  if unsigned
  * 0 / A == 0
  * 1.0 * A == A
  * A * (2^c) == A << c
  * A ^ ~A == -1
  * A | ~A == -1
  * 0 % X = 0
  * A % (2^c) == A & (c-1) if unsigned
  * A - (A & B) == A & ~B
  * -1 - A == ~A


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5588 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-02-18 19:28:47 +00:00
parent a2881961b9
commit 5640f33331
6 changed files with 57 additions and 1 deletions

View File

@ -38,3 +38,8 @@ bool %test6(bool %A) {
ret bool %B
}
int %test7(int %A) { ; A & ~A == 0
%NotA = xor int %A, -1
%B = and int %A, %NotA
ret int %B
}

View File

@ -12,3 +12,13 @@ int %test1(int %A) {
%B = div int %A, 1
ret int %B
}
uint %test2(uint %A) {
%B = div uint %A, 8 ; => Shift
ret int %B
}
int %test3(int %A) {
%B = div int 0, %A ; => 0, don't need to keep traps
ret int %B
}

View File

@ -26,3 +26,12 @@ begin
ret int %B
end
double %test4(double %A) {
%B = mul double 1.0, %A ; This is safe for FP
ret double %B
}
int %test5(int %A) {
%B = mul int %A, 8
ret int %B
}

View File

@ -58,3 +58,14 @@ int %test10(int %A) {
ret int %B
}
int %test11(int %A) { ; A ^ ~A == -1
%NotA = xor int -1, %A
%B = xor int %A, %NotA
ret int %B
}
int %test12(int %A) { ; A | ~A == -1
%NotA = xor int -1, %A
%B = or int %A, %NotA
ret int %B
}

View File

@ -8,8 +8,17 @@
implementation
int "test1"(int %A) {
int %test1(int %A) {
%B = rem int %A, 1 ; ISA constant 0
ret int %B
}
int %test2(int %A) { ; 0 % X = 0, we don't need ot preserve traps
%B = rem int 0, %A
ret int %B
}
uint %test3(uint %A) {
%B = rem uint %A, 8 ; & 7
ret uint %B
}

View File

@ -35,3 +35,15 @@ int "test5"(int %A, int %Bok, int %Cok) {
%E = sub int %A, %D
ret int %E
}
int %test6(int %A, int %B) {
%C = and int %A, %B ; A - (A & B) => A & ~B
%D = sub int %A, %C
ret int %D
}
int %test7(int %A) {
%B = sub int -1, %A ; B = ~A
ret int %B
}