1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 ; A copy of fmul.ll, with undef at insertelement/shufflevector replaced with
7 ; Don't crash when attempting to cast a constant FMul to an instruction.
8 define void @test8(i32* %inout) {
11 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
13 ; CHECK-NEXT: [[LOCAL_VAR_7_0:%.*]] = phi <4 x float> [ <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, [[ENTRY:%.*]] ], [ [[TMP0:%.*]], [[FOR_BODY:%.*]] ]
14 ; CHECK-NEXT: br i1 undef, label [[FOR_BODY]], label [[FOR_END:%.*]]
16 ; CHECK-NEXT: [[TMP0]] = insertelement <4 x float> [[LOCAL_VAR_7_0]], float 0.000000e+00, i32 2
17 ; CHECK-NEXT: br label [[FOR_COND]]
19 ; CHECK-NEXT: ret void
22 %0 = load i32, i32* %inout, align 4
23 %conv = uitofp i32 %0 to float
24 %vecinit = insertelement <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float undef>, float %conv, i32 3
25 %sub = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %vecinit
26 %1 = shufflevector <4 x float> %sub, <4 x float> poison, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
27 %mul = fmul <4 x float> zeroinitializer, %1
30 for.cond: ; preds = %for.body, %entry
31 %local_var_7.0 = phi <4 x float> [ %mul, %entry ], [ %2, %for.body ]
32 br i1 undef, label %for.body, label %for.end
34 for.body: ; preds = %for.cond
35 %2 = insertelement <4 x float> %local_var_7.0, float 0.000000e+00, i32 2
38 for.end: ; preds = %for.cond
43 ; fastmath => z * splat(0) = splat(0), even for scalable vectors
44 define <vscale x 2 x float> @mul_scalable_splat_zero(<vscale x 2 x float> %z) {
45 ; CHECK-LABEL: @mul_scalable_splat_zero(
46 ; CHECK-NEXT: ret <vscale x 2 x float> zeroinitializer
48 %shuf = shufflevector <vscale x 2 x float> insertelement (<vscale x 2 x float> undef, float 0.0, i32 0), <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
49 %t3 = fmul fast <vscale x 2 x float> %shuf, %z
50 ret <vscale x 2 x float> %t3