[llvm] 8a836da - [InstCombine] Support lshr(trunc(lshr(x, c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) uniform vector tests
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 08:56:07 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-09T16:54:46+01:00
New Revision: 8a836daaa97bc979cd589f5efb060d2223225d8d
URL: https://github.com/llvm/llvm-project/commit/8a836daaa97bc979cd589f5efb060d2223225d8d
DIFF: https://github.com/llvm/llvm-project/commit/8a836daaa97bc979cd589f5efb060d2223225d8d.diff
LOG: [InstCombine] Support lshr(trunc(lshr(x,c1)), c2) -> trunc(lshr(lshr(x,c1),c2)) uniform vector tests
FoldShiftByConstant is hardcoded for scalar/uniform outer shift amounts atm so that needs to be fixed first to support non-uniform cases
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/test/Transforms/InstCombine/shift.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 627e3390ea14..43b700572826 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -691,8 +691,9 @@ Instruction *InstCombinerImpl::FoldShiftByConstant(Value *Op0, Constant *Op1,
// require that the input operand is a shift-by-constant so that we have
// confidence that the shifts will get folded together. We could do this
// xform in more cases, but it is unlikely to be profitable.
+ const APInt *TrShiftAmt;
if (I.isLogicalShift() &&
- match(TI->getOperand(0), m_Shift(m_Value(), m_ConstantInt()))) {
+ match(TI->getOperand(0), m_Shift(m_Value(), m_APInt(TrShiftAmt)))) {
auto *TrOp = cast<Instruction>(TI->getOperand(0));
Type *SrcTy = TrOp->getType();
diff --git a/llvm/test/Transforms/InstCombine/shift.ll b/llvm/test/Transforms/InstCombine/shift.ll
index aca47336fc80..146440862cc4 100644
--- a/llvm/test/Transforms/InstCombine/shift.ll
+++ b/llvm/test/Transforms/InstCombine/shift.ll
@@ -465,9 +465,8 @@ entry:
define <2 x i32> @test29_uniform(<2 x i64> %d18) {
; CHECK-LABEL: @test29_uniform(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[I916:%.*]] = lshr <2 x i64> [[D18:%.*]], <i64 32, i64 32>
-; CHECK-NEXT: [[I917:%.*]] = trunc <2 x i64> [[I916]] to <2 x i32>
-; CHECK-NEXT: [[I10:%.*]] = lshr <2 x i32> [[I917]], <i32 31, i32 31>
+; CHECK-NEXT: [[I916:%.*]] = lshr <2 x i64> [[D18:%.*]], <i64 63, i64 63>
+; CHECK-NEXT: [[I10:%.*]] = trunc <2 x i64> [[I916]] to <2 x i32>
; CHECK-NEXT: ret <2 x i32> [[I10]]
;
entry:
More information about the llvm-commits
mailing list