[llvm] r341557 - [InstCombine] add tests for xor-not; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 6 08:35:02 PDT 2018
Author: spatel
Date: Thu Sep 6 08:35:01 2018
New Revision: 341557
URL: http://llvm.org/viewvc/llvm-project?rev=341557&view=rev
Log:
[InstCombine] add tests for xor-not; NFC
These tests demonstrate a missing fold that would
also be needed to avoid a regression when we try
to recommit rL300977.
Modified:
llvm/trunk/test/Transforms/InstCombine/xor.ll
Modified: llvm/trunk/test/Transforms/InstCombine/xor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor.ll?rev=341557&r1=341556&r2=341557&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/xor.ll Thu Sep 6 08:35:01 2018
@@ -587,6 +587,78 @@ define i32 @and_xor_extra_use(i32 %a, i3
ret i32 %r
}
+; TODO: (~X | C2) ^ C1 --> ((X & ~C2) ^ -1) ^ C1 --> (X & ~C2) ^ ~C1
+; The extra use (store) is here because the simpler case
+; may be transformed using demanded bits.
+
+define i8 @xor_or_not(i8 %x, i8* %p) {
+; CHECK-LABEL: @xor_or_not(
+; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT: store i8 [[NX]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[NX]], 7
+; CHECK-NEXT: [[R:%.*]] = xor i8 [[OR]], 12
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %nx = xor i8 %x, -1
+ store i8 %nx, i8* %p
+ %or = or i8 %nx, 7
+ %r = xor i8 %or, 12
+ ret i8 %r
+}
+
+; Don't do this if the 'or' has extra uses.
+
+define i8 @xor_or_not_uses(i8 %x, i8* %p) {
+; CHECK-LABEL: @xor_or_not_uses(
+; CHECK-NEXT: [[TMP1:%.*]] = or i8 [[X:%.*]], 7
+; CHECK-NEXT: [[OR:%.*]] = xor i8 [[TMP1]], -8
+; CHECK-NEXT: store i8 [[OR]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[R:%.*]] = xor i8 [[TMP1]], -12
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %nx = xor i8 %x, -1
+ %or = or i8 %nx, 7
+ store i8 %or, i8* %p
+ %r = xor i8 %or, 12
+ ret i8 %r
+}
+
+; TODO: (~X & C2) ^ C1 --> ((X | ~C2) ^ -1) ^ C1 --> (X | ~C2) ^ ~C1
+; The extra use (store) is here because the simpler case
+; may be transformed using demanded bits.
+
+define i8 @xor_and_not(i8 %x, i8* %p) {
+; CHECK-LABEL: @xor_and_not(
+; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT: store i8 [[NX]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[AND:%.*]] = and i8 [[NX]], 42
+; CHECK-NEXT: [[R:%.*]] = xor i8 [[AND]], 31
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %nx = xor i8 %x, -1
+ store i8 %nx, i8* %p
+ %and = and i8 %nx, 42
+ %r = xor i8 %and, 31
+ ret i8 %r
+}
+
+; Don't do this if the 'and' has extra uses.
+
+define i8 @xor_and_not_uses(i8 %x, i8* %p) {
+; CHECK-LABEL: @xor_and_not_uses(
+; CHECK-NEXT: [[NX:%.*]] = and i8 [[X:%.*]], 42
+; CHECK-NEXT: [[AND:%.*]] = xor i8 [[NX]], 42
+; CHECK-NEXT: store i8 [[AND]], i8* [[P:%.*]], align 1
+; CHECK-NEXT: [[R:%.*]] = xor i8 [[NX]], 53
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %nx = xor i8 %x, -1
+ %and = and i8 %nx, 42
+ store i8 %and, i8* %p
+ %r = xor i8 %and, 31
+ ret i8 %r
+}
+
; The tests 39-47 are related to the canonicalization:
; %notx = xor i32 %x, -1
; %cmp = icmp sgt i32 %notx, %y
More information about the llvm-commits
mailing list