[PATCH] D112258: Add test to check we can instcombine after reassociate. NFC.

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 11:51:00 PDT 2021


rampitec created this revision.
rampitec added a reviewer: spatel.
rampitec requested review of this revision.
Herald added a project: LLVM.

The pattern became optimized after b92412fb286b <https://reviews.llvm.org/rGb92412fb286be26d6f033b9ec283b1b18cb57869>.


https://reviews.llvm.org/D112258

Files:
  llvm/test/Transforms/PhaseOrdering/reassociate-instcombine.ll


Index: llvm/test/Transforms/PhaseOrdering/reassociate-instcombine.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/PhaseOrdering/reassociate-instcombine.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -O1 -S < %s | FileCheck %s
+
+; Make sure we reassociate and1 with and2 before instcombine to siplify
+; (a & ~b) & ~c --> a & ~(b | c)
+define i4 @not_reassociate_and_and_not(i4 %a, i4 %b, i4 %c, i4 %d) {
+; CHECK-LABEL: @not_reassociate_and_and_not(
+; CHECK-NEXT:    [[TMP1:%.*]] = or i4 [[B:%.*]], [[C:%.*]]
+; CHECK-NEXT:    [[TMP2:%.*]] = xor i4 [[TMP1]], -1
+; CHECK-NEXT:    [[AND2:%.*]] = and i4 [[TMP2]], [[A:%.*]]
+; CHECK-NEXT:    [[AND3:%.*]] = and i4 [[AND2]], [[D:%.*]]
+; CHECK-NEXT:    ret i4 [[AND3]]
+;
+  %notb = xor i4 %b, -1
+  %notc = xor i4 %c, -1
+  %and1 = and i4 %a, %notb
+  %and2 = and i4 %and1, %d
+  %and3 = and i4 %and2, %notc
+  ret i4 %and3
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112258.381347.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211021/8c2020c1/attachment.bin>


More information about the llvm-commits mailing list