[llvm] 195d278 - [ValueTracking] Add tests for `xor`/`disjoint or` in `getInvertibleOperands`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 11:14:03 PDT 2024
Author: Noah Goldstein
Date: 2024-04-10T13:13:43-05:00
New Revision: 195d278d502308655edb1e9ff1c6f0c9256d0d15
URL: https://github.com/llvm/llvm-project/commit/195d278d502308655edb1e9ff1c6f0c9256d0d15
DIFF: https://github.com/llvm/llvm-project/commit/195d278d502308655edb1e9ff1c6f0c9256d0d15.diff
LOG: [ValueTracking] Add tests for `xor`/`disjoint or` in `getInvertibleOperands`; NFC
Added:
Modified:
llvm/test/Transforms/InstSimplify/icmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/icmp.ll b/llvm/test/Transforms/InstSimplify/icmp.ll
index 3109768bdfe005..a66f7cb879ef9d 100644
--- a/llvm/test/Transforms/InstSimplify/icmp.ll
+++ b/llvm/test/Transforms/InstSimplify/icmp.ll
@@ -270,7 +270,7 @@ define i1 @load_ptr(ptr %p) {
define i1 @load_ptr_null_valid(ptr %p) null_pointer_is_valid {
; CHECK-LABEL: @load_ptr_null_valid(
-; CHECK-NEXT: [[LOAD_P:%.*]] = load ptr, ptr [[P:%.*]], align 8, !dereferenceable !0
+; CHECK-NEXT: [[LOAD_P:%.*]] = load ptr, ptr [[P:%.*]], align 8, !dereferenceable [[META0:![0-9]+]]
; CHECK-NEXT: [[R:%.*]] = icmp ne ptr [[LOAD_P]], null
; CHECK-NEXT: ret i1 [[R]]
;
@@ -278,3 +278,95 @@ define i1 @load_ptr_null_valid(ptr %p) null_pointer_is_valid {
%r = icmp ne ptr %load_p, null
ret i1 %r
}
+
+define i1 @non_eq_disjoint_or_common_op(i8 %x, i8 %y, i8 %ww, i8 %a) {
+; CHECK-LABEL: @non_eq_disjoint_or_common_op(
+; CHECK-NEXT: [[W:%.*]] = add nuw i8 [[WW:%.*]], 1
+; CHECK-NEXT: [[Z:%.*]] = add i8 [[Y:%.*]], [[W]]
+; CHECK-NEXT: [[XY:%.*]] = or disjoint i8 [[X:%.*]], [[Y]]
+; CHECK-NEXT: [[XZ:%.*]] = or disjoint i8 [[X]], [[Z]]
+; CHECK-NEXT: [[AXY:%.*]] = add i8 [[A:%.*]], [[XY]]
+; CHECK-NEXT: [[AXZ:%.*]] = add i8 [[A]], [[XZ]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AXY]], [[AXZ]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %w = add nuw i8 %ww, 1
+ %z = add i8 %y, %w
+
+ %xy = or disjoint i8 %x, %y
+ %xz = or disjoint i8 %x, %z
+
+ %axy = add i8 %a, %xy
+ %axz = add i8 %a, %xz
+ %r = icmp eq i8 %axy, %axz
+ ret i1 %r
+}
+
+define i1 @non_eq_disjoint_or_common_op_fail(i8 %x, i8 %y, i8 %ww, i8 %a) {
+; CHECK-LABEL: @non_eq_disjoint_or_common_op_fail(
+; CHECK-NEXT: [[W:%.*]] = add nuw i8 [[WW:%.*]], 1
+; CHECK-NEXT: [[Z:%.*]] = add i8 [[Y:%.*]], [[W]]
+; CHECK-NEXT: [[XY:%.*]] = or i8 [[X:%.*]], [[Y]]
+; CHECK-NEXT: [[XZ:%.*]] = or disjoint i8 [[X]], [[Z]]
+; CHECK-NEXT: [[AXY:%.*]] = add i8 [[A:%.*]], [[XY]]
+; CHECK-NEXT: [[AXZ:%.*]] = add i8 [[A]], [[XZ]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AXY]], [[AXZ]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %w = add nuw i8 %ww, 1
+ %z = add i8 %y, %w
+
+ %xy = or i8 %x, %y
+ %xz = or disjoint i8 %x, %z
+
+ %axy = add i8 %a, %xy
+ %axz = add i8 %a, %xz
+ %r = icmp eq i8 %axy, %axz
+ ret i1 %r
+}
+
+define i1 @non_eq_xor_common_op(i8 %x, i8 %y, i8 %ww, i8 %a) {
+; CHECK-LABEL: @non_eq_xor_common_op(
+; CHECK-NEXT: [[W:%.*]] = add nuw i8 [[WW:%.*]], 1
+; CHECK-NEXT: [[Z:%.*]] = add i8 [[Y:%.*]], [[W]]
+; CHECK-NEXT: [[XY:%.*]] = xor i8 [[Y]], [[X:%.*]]
+; CHECK-NEXT: [[XZ:%.*]] = xor i8 [[X]], [[Z]]
+; CHECK-NEXT: [[AXY:%.*]] = add i8 [[A:%.*]], [[XY]]
+; CHECK-NEXT: [[AXZ:%.*]] = add i8 [[A]], [[XZ]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AXY]], [[AXZ]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %w = add nuw i8 %ww, 1
+ %z = add i8 %y, %w
+
+ %xy = xor i8 %y, %x
+ %xz = xor i8 %x, %z
+
+ %axy = add i8 %a, %xy
+ %axz = add i8 %a, %xz
+ %r = icmp eq i8 %axy, %axz
+ ret i1 %r
+}
+
+define i1 @non_eq_xor_common_op_fail(i8 %x, i8 %y, i8 %ww, i8 %a) {
+; CHECK-LABEL: @non_eq_xor_common_op_fail(
+; CHECK-NEXT: [[W:%.*]] = add nsw i8 [[WW:%.*]], 1
+; CHECK-NEXT: [[Z:%.*]] = add i8 [[Y:%.*]], [[W]]
+; CHECK-NEXT: [[XY:%.*]] = xor i8 [[Y]], [[X:%.*]]
+; CHECK-NEXT: [[XZ:%.*]] = xor i8 [[X]], [[Z]]
+; CHECK-NEXT: [[AXY:%.*]] = add i8 [[A:%.*]], [[XY]]
+; CHECK-NEXT: [[AXZ:%.*]] = add i8 [[A]], [[XZ]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AXY]], [[AXZ]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %w = add nsw i8 %ww, 1
+ %z = add i8 %y, %w
+
+ %xy = xor i8 %y, %x
+ %xz = xor i8 %x, %z
+
+ %axy = add i8 %a, %xy
+ %axz = add i8 %a, %xz
+ %r = icmp eq i8 %axy, %axz
+ ret i1 %r
+}
More information about the llvm-commits
mailing list