[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
This commit is contained in:
Simon Pilgrim 2020-10-09 16:54:32 +01:00
parent af1f016436
commit 8a836daaa9
2 changed files with 4 additions and 4 deletions

View File

@ -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();

View File

@ -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: