Add optimizations:
authorChris Lattner <sabre@nondot.org>
Mon, 10 Mar 2003 23:52:54 +0000 (23:52 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 10 Mar 2003 23:52:54 +0000 (23:52 +0000)
 - (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
 - (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5741 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/add.ll
test/Transforms/InstCombine/and.ll
test/Transforms/InstCombine/or.ll

index 19fa6261cdd51a71f95a94e334a065ef2c11ee79..4043a7f9c35e3c64e1588760525d34e9dcc805cb 100644 (file)
@@ -51,3 +51,9 @@ int %test7(int %A) {
         ret int %C
 }
 
+int %test8(int %A, int %B) {     ; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
+       %A1 = and int %A, 7
+       %B1 = and int %B, 128
+       %C = add int %A1, %B1
+       ret int %C
+}
index 03b67f57b6e4bd96698c62d62847045bc3e2494a..269b33c285ae5fbc3be280f3fdda65caee6cdd20 100644 (file)
@@ -49,3 +49,4 @@ ubyte %test8(ubyte %A) {    ; AND associates
        %C = and ubyte %B, 4
        ret ubyte %C
 }
+
index 7ffd3461bc68ebb23a6b4d4d171989e2f4f6b0b9..ec28e20ad3f5c5597c7103503aff77d08423095e 100644 (file)
@@ -1,7 +1,7 @@
 ; This test makes sure that these instructions are properly eliminated.
 ;
 
-; RUN: if as < %s | opt -instcombine | dis | grep or\ 
+; RUN: if as < %s | opt -instcombine | dis | grep -v '%OROK = or' | grep or\ 
 ; RUN: then exit 1
 ; RUN: else exit 0
 ; RUN: fi
@@ -91,3 +91,11 @@ ubyte %test15(ubyte %A) {
        %C = xor ubyte %B, 17
        ret ubyte %C
 }
+
+int %test16(int %A, int %B) {     ; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
+        %A1 = and int %A, 7
+        %B1 = and int %B, 128
+        %OROK = xor int %A1, %B1
+        ret int %OROK
+}
+