1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 ; This test checks a regression in the select operand folding combine, in which
5 ; Constant::getUniqueInteger would crash for a scalable-vector zeroinitializer.
6 define <vscale x 1 x i32> @select_opt(<vscale x 1 x i32> %b, <vscale x 1 x i1> %m) {
7 ; CHECK-LABEL: @select_opt(
8 ; CHECK-NEXT: [[C:%.*]] = add nsw <vscale x 1 x i32> [[B:%.*]], shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> undef, i32 2, i32 0), <vscale x 1 x i32> undef, <vscale x 1 x i32> zeroinitializer)
9 ; CHECK-NEXT: [[D:%.*]] = select <vscale x 1 x i1> [[M:%.*]], <vscale x 1 x i32> [[C]], <vscale x 1 x i32> [[B]]
10 ; CHECK-NEXT: ret <vscale x 1 x i32> [[D]]
12 %head = insertelement <vscale x 1 x i32> undef, i32 2, i32 0
13 %splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> undef, <vscale x 1 x i32> zeroinitializer
14 %c = add nsw <vscale x 1 x i32> %b, %splat
15 %d = select <vscale x 1 x i1> %m, <vscale x 1 x i32> %c, <vscale x 1 x i32> %b
16 ret <vscale x 1 x i32> %d