[PATCH] D34338: [Reassociate] Support some reassociation of vector xors

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 09:24:38 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL305704: [Reassociate] Support some reassociation of vector xors (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D34338?vs=102985&id=103061#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34338

Files:
  llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
  llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll


Index: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
@@ -1276,9 +1276,15 @@
   if (Ops.size() == 1)
     return nullptr;
 
+  Type *Ty = Ops[0].Op->getType();
+
+  // TODO: We should optimize vector Xor instructions, but they are
+  // currently unsupported.
+  if (Ty->isVectorTy())
+    return nullptr;
+
   SmallVector<XorOpnd, 8> Opnds;
   SmallVector<XorOpnd*, 8> OpndPtrs;
-  Type *Ty = Ops[0].Op->getType();
   APInt ConstOpnd(Ty->getIntegerBitWidth(), 0);
 
   // Step 1: Convert ValueEntry to XorOpnd
@@ -2000,11 +2006,6 @@
   if (I->isCommutative())
     canonicalizeOperands(I);
 
-  // TODO: We should optimize vector Xor instructions, but they are
-  // currently unsupported.
-  if (I->getType()->isVectorTy() && I->getOpcode() == Instruction::Xor)
-    return;
-
   // Don't optimize floating point instructions that don't have unsafe algebra.
   if (I->getType()->isFPOrFPVectorTy() && !I->hasUnsafeAlgebra())
     return;
Index: llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll
===================================================================
--- llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll
+++ llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll
@@ -205,15 +205,25 @@
   ret <2 x i32> %tmp3
 }
 
-; FIXME: Optimize vector xor.  Currently only commute operands.
 define <2 x i32> @test17(<2 x i32> %x, <2 x i32> %y) {
 ; CHECK-LABEL: test17
-; CHECK-NEXT: %tmp1 = xor <2 x i32> %x, %y
-; CHECK-NEXT: %tmp2 = xor <2 x i32> %x, %y
-; CHECK-NEXT: %tmp3 = xor <2 x i32> %tmp1, %tmp2
+; CHECK-NEXT: ret <2 x i32> zeroinitializer
 
   %tmp1 = xor <2 x i32> %x, %y
   %tmp2 = xor <2 x i32> %y, %x
   %tmp3 = xor <2 x i32> %tmp1, %tmp2
   ret <2 x i32> %tmp3
 }
+
+define <2 x i32> @test18(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: test18
+; CHECK-NEXT: %tmp5 = xor <2 x i32> %y, %x
+; CHECK-NEXT: ret <2 x i32> %tmp5
+
+  %tmp1 = xor <2 x i32> %x, %y
+  %tmp2 = xor <2 x i32> %y, %x
+  %tmp3 = xor <2 x i32> %x, %y
+  %tmp4 = xor <2 x i32> %tmp1, %tmp2
+  %tmp5 = xor <2 x i32> %tmp4, %tmp3
+  ret <2 x i32> %tmp5
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34338.103061.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170619/e47c328f/attachment.bin>


More information about the llvm-commits mailing list