xref: /llvm-project/llvm/test/Transforms/InstCombine/udiv-pow2-vscale.ll (revision acdc419c897f8a9414c7a00c8908ac32312afee2)
1; RUN: opt -passes=instcombine -S < %s | FileCheck %s
2
3; This vscale udiv with a power-of-2 spalt on the rhs should not crash opt
4
5; CHECK: define <vscale x 2 x i32> @udiv_pow2_vscale(<vscale x 2 x i32> %lhs)
6define <vscale x 2 x i32> @udiv_pow2_vscale(<vscale x 2 x i32> %lhs) {
7  %splatter = insertelement <vscale x 2 x i32> undef, i32 2, i32 0
8  %rhs = shufflevector <vscale x 2 x i32> %splatter,
9                       <vscale x 2 x i32> undef,
10                       <vscale x 2 x i32> zeroinitializer
11  %res = udiv <vscale x 2 x i32> %lhs, %rhs
12  ret <vscale x 2 x i32> %res
13}
14
15; This fixed width udiv with a power-of-2 splat on the rhs should also not
16; crash, and instcombine should eliminate the udiv
17
18; CHECK-LABEL: define <2 x i32> @udiv_pow2_fixed(<2 x i32> %lhs)
19; CHECK-NOT: udiv
20define <2 x i32> @udiv_pow2_fixed(<2 x i32> %lhs) {
21  %splatter = insertelement <2 x i32> undef, i32 2, i32 0
22  %rhs = shufflevector <2 x i32> %splatter,
23                       <2 x i32> undef,
24                       <2 x i32> zeroinitializer
25  %res = udiv <2 x i32> %lhs, %rhs
26  ret <2 x i32> %res
27}
28