[llvm] 8001dcb - [NFC][InstCombine] Add test coverage for `(x ^ C) ^ y` pattern

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 24 10:23:34 PST 2020


Author: Roman Lebedev
Date: 2020-12-24T21:20:50+03:00
New Revision: 8001dcbd50ce501e75e06886c5e225298e9eea2b

URL: https://github.com/llvm/llvm-project/commit/8001dcbd50ce501e75e06886c5e225298e9eea2b
DIFF: https://github.com/llvm/llvm-project/commit/8001dcbd50ce501e75e06886c5e225298e9eea2b.diff

LOG: [NFC][InstCombine] Add test coverage for `(x ^ C) ^ y` pattern

Added: 
    llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll b/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
new file mode 100644
index 000000000000..20b114ff0b0c
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll
@@ -0,0 +1,75 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare i8 @gen8()
+declare void @use8(i8)
+
+ at a = global i8 17
+
+define i8 @t0_scalar(i8 %x, i8 %y) {
+; CHECK-LABEL: @t0_scalar(
+; CHECK-NEXT:    [[I0:%.*]] = xor i8 [[X:%.*]], 42
+; CHECK-NEXT:    [[R:%.*]] = xor i8 [[I0]], [[Y:%.*]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %i0 = xor i8 %x, 42
+  %r = xor i8 %i0, %y
+  ret i8 %r
+}
+
+define <2 x i8> @t1_splatvec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @t1_splatvec(
+; CHECK-NEXT:    [[I0:%.*]] = xor <2 x i8> [[X:%.*]], <i8 42, i8 42>
+; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[I0]], [[Y:%.*]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %i0 = xor <2 x i8> %x, <i8 42, i8 42>
+  %r = xor <2 x i8> %i0, %y
+  ret <2 x i8> %r
+}
+define <2 x i8> @t2_vec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @t2_vec(
+; CHECK-NEXT:    [[I0:%.*]] = xor <2 x i8> [[X:%.*]], <i8 42, i8 24>
+; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[I0]], [[Y:%.*]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %i0 = xor <2 x i8> %x, <i8 42, i8 24>
+  %r = xor <2 x i8> %i0, %y
+  ret <2 x i8> %r
+}
+define <2 x i8> @t3_vec_undef(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @t3_vec_undef(
+; CHECK-NEXT:    [[I0:%.*]] = xor <2 x i8> [[X:%.*]], <i8 42, i8 undef>
+; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[I0]], [[Y:%.*]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %i0 = xor <2 x i8> %x, <i8 42, i8 undef>
+  %r = xor <2 x i8> %i0, %y
+  ret <2 x i8> %r
+}
+
+define i8 @t4_extrause(i8 %x, i8 %y) {
+; CHECK-LABEL: @t4_extrause(
+; CHECK-NEXT:    [[I0:%.*]] = xor i8 [[X:%.*]], 42
+; CHECK-NEXT:    call void @use8(i8 [[I0]])
+; CHECK-NEXT:    [[R:%.*]] = xor i8 [[I0]], [[Y:%.*]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %i0 = xor i8 %x, 42
+  call void @use8(i8 %i0)
+  %r = xor i8 %i0, %y
+  ret i8 %r
+}
+
+define i8 @t5_commutativity(i8 %x) {
+; CHECK-LABEL: @t5_commutativity(
+; CHECK-NEXT:    [[I0:%.*]] = xor i8 [[X:%.*]], 42
+; CHECK-NEXT:    [[Y:%.*]] = call i8 @gen8()
+; CHECK-NEXT:    [[R:%.*]] = xor i8 [[Y]], [[I0]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %i0 = xor i8 %x, 42
+  %y = call i8 @gen8()
+  %r = xor i8 %y, %i0
+  ret i8 %r
+}


        


More information about the llvm-commits mailing list