[llvm] r305704 - [Reassociate] Support some reassociation of vector xors
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 09:23:47 PDT 2017
Author: ctopper
Date: Mon Jun 19 11:23:46 2017
New Revision: 305704
URL: http://llvm.org/viewvc/llvm-project?rev=305704&view=rev
Log:
[Reassociate] Support some reassociation of vector xors
Summary:
Currently we don't try to do anything with vector xors.
This patch adds support for removing duplicate pairs from a chain of vector xors as its pretty easy to support. We still dont' try to combine the xors with and/ors, but I might try that in a future patch.
Reviewers: mcrosier, davide, resistor
Reviewed By: mcrosier
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D34338
Modified:
llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll
Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=305704&r1=305703&r2=305704&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Mon Jun 19 11:23:46 2017
@@ -1276,9 +1276,15 @@ Value *ReassociatePass::OptimizeXor(Inst
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 @@ void ReassociatePass::OptimizeInst(Instr
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;
Modified: llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll?rev=305704&r1=305703&r2=305704&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll (original)
+++ llvm/trunk/test/Transforms/Reassociate/fast-ReassociateVector.ll Mon Jun 19 11:23:46 2017
@@ -205,15 +205,25 @@ define <2 x i32> @test16(<2 x i32> %x, <
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
+}
More information about the llvm-commits
mailing list