[llvm] f7e98ef - [InstCombine] add tests for or-xor-or; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 13 06:16:43 PDT 2022
Author: Sanjay Patel
Date: 2022-08-13T09:16:32-04:00
New Revision: f7e98ef6c27d7f29efaaffb0494e4a09e39989d3
URL: https://github.com/llvm/llvm-project/commit/f7e98ef6c27d7f29efaaffb0494e4a09e39989d3
DIFF: https://github.com/llvm/llvm-project/commit/f7e98ef6c27d7f29efaaffb0494e4a09e39989d3.diff
LOG: [InstCombine] add tests for or-xor-or; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/or-xor.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/or-xor.ll b/llvm/test/Transforms/InstCombine/or-xor.ll
index 79c2141a8179..a98775646aa6 100644
--- a/llvm/test/Transforms/InstCombine/or-xor.ll
+++ b/llvm/test/Transforms/InstCombine/or-xor.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+declare void @use(i8)
+
; X | ~(X | Y) --> X | ~Y
define i32 @test1(i32 %x, i32 %y) {
@@ -633,3 +635,128 @@ define i32 @PR45977_f2(i32 %a, i32 %b) {
%res = xor i32 %or, %ornot
ret i32 %res
}
+
+define i8 @or_xor_common_op_commute0(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute0(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[OR]], [[XOR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %x, %y
+ %xor = xor i8 %x, %z
+ %r = or i8 %or, %xor
+ ret i8 %r
+}
+
+define i8 @or_xor_common_op_commute1(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute1(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: call void @use(i8 [[OR]])
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[OR]], [[XOR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %y, %x
+ call void @use(i8 %or)
+ %xor = xor i8 %x, %z
+ %r = or i8 %or, %xor
+ ret i8 %r
+}
+
+define i8 @or_xor_common_op_commute2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute2(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Z:%.*]], [[X]]
+; CHECK-NEXT: call void @use(i8 [[XOR]])
+; CHECK-NEXT: [[R:%.*]] = or i8 [[OR]], [[XOR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %x, %y
+ %xor = xor i8 %z, %x
+ call void @use(i8 %xor)
+ %r = or i8 %or, %xor
+ ret i8 %r
+}
+
+define i8 @or_xor_common_op_commute3(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute3(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: call void @use(i8 [[OR]])
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Z:%.*]], [[X]]
+; CHECK-NEXT: call void @use(i8 [[XOR]])
+; CHECK-NEXT: [[R:%.*]] = or i8 [[OR]], [[XOR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %y, %x
+ call void @use(i8 %or)
+ %xor = xor i8 %z, %x
+ call void @use(i8 %xor)
+ %r = or i8 %or, %xor
+ ret i8 %r
+}
+
+define <2 x i8> @or_xor_common_op_commute4(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
+; CHECK-LABEL: @or_xor_common_op_commute4(
+; CHECK-NEXT: [[OR:%.*]] = or <2 x i8> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i8> [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[R:%.*]] = or <2 x i8> [[XOR]], [[OR]]
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %or = or <2 x i8> %x, %y
+ %xor = xor <2 x i8> %x, %z
+ %r = or <2 x i8> %xor, %or
+ ret <2 x i8> %r
+}
+
+define i8 @or_xor_common_op_commute5(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute5(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[OR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %y, %x
+ %xor = xor i8 %x, %z
+ %r = or i8 %xor, %or
+ ret i8 %r
+}
+
+define i8 @or_xor_common_op_commute6(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute6(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Z:%.*]], [[X]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[OR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %x, %y
+ %xor = xor i8 %z, %x
+ %r = or i8 %xor, %or
+ ret i8 %r
+}
+
+define i8 @or_xor_common_op_commute7(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @or_xor_common_op_commute7(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Z:%.*]], [[X]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[XOR]], [[OR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %y, %x
+ %xor = xor i8 %z, %x
+ %r = or i8 %xor, %or
+ ret i8 %r
+}
+
+define i8 @or_xor_notcommon_op(i8 %x, i8 %y, i8 %z, i8 %q) {
+; CHECK-LABEL: @or_xor_notcommon_op(
+; CHECK-NEXT: [[OR:%.*]] = or i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[Q:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[R:%.*]] = or i8 [[OR]], [[XOR]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %or = or i8 %x, %y
+ %xor = xor i8 %q, %z
+ %r = or i8 %or, %xor
+ ret i8 %r
+}
More information about the llvm-commits
mailing list