reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s

declare void @use_f32(float)
declare void @use_v4f32(<4 x float>)

define <4 x float> @bitcast_inselt(i32 %x, <4 x i32> %v) {
; CHECK-LABEL: @bitcast_inselt(
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[X:%.*]], i32 0
; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>
; CHECK-NEXT:    ret <4 x float> [[R]]
;
  %xf = bitcast i32 %x to float
  %vf = bitcast <4 x i32> %v to <4 x float>
  %r = insertelement <4 x float> %vf, float %xf, i32 0
  ret <4 x float> %r
}

define <4 x float> @bitcast_inselt_use1(i32 %x, <4 x i32> %v) {
; CHECK-LABEL: @bitcast_inselt_use1(
; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float
; CHECK-NEXT:    call void @use_f32(float [[XF]])
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[X]], i32 1
; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>
; CHECK-NEXT:    ret <4 x float> [[R]]
;
  %xf = bitcast i32 %x to float
  call void @use_f32(float %xf)
  %vf = bitcast <4 x i32> %v to <4 x float>
  %r = insertelement <4 x float> %vf, float %xf, i32 1
  ret <4 x float> %r
}

define <4 x float> @bitcast_inselt_use2(i32 %x, <4 x i32> %v, i32 %index) {
; CHECK-LABEL: @bitcast_inselt_use2(
; CHECK-NEXT:    [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float>
; CHECK-NEXT:    call void @use_v4f32(<4 x float> [[VF]])
; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V]], i32 [[X:%.*]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>
; CHECK-NEXT:    ret <4 x float> [[R]]
;
  %xf = bitcast i32 %x to float
  %vf = bitcast <4 x i32> %v to <4 x float>
  call void @use_v4f32(<4 x float> %vf)
  %r = insertelement <4 x float> %vf, float %xf, i32 %index
  ret <4 x float> %r
}

; Negative test - 2 extra uses would require an extra instruction.

define <4 x float> @bitcast_inselt_use3(i32 %x, <4 x i32> %v) {
; CHECK-LABEL: @bitcast_inselt_use3(
; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float
; CHECK-NEXT:    call void @use_f32(float [[XF]])
; CHECK-NEXT:    [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float>
; CHECK-NEXT:    call void @use_v4f32(<4 x float> [[VF]])
; CHECK-NEXT:    [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i32 0
; CHECK-NEXT:    ret <4 x float> [[R]]
;
  %xf = bitcast i32 %x to float
  call void @use_f32(float %xf)
  %vf = bitcast <4 x i32> %v to <4 x float>
  call void @use_v4f32(<4 x float> %vf)
  %r = insertelement <4 x float> %vf, float %xf, i32 0
  ret <4 x float> %r
}

; Negative test - wrong source type for vector.

define <2 x float> @bitcast_inselt_wrong_bitcast1(i32 %x, i64 %notv) {
; CHECK-LABEL: @bitcast_inselt_wrong_bitcast1(
; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float
; CHECK-NEXT:    [[VF:%.*]] = bitcast i64 [[NOTV:%.*]] to <2 x float>
; CHECK-NEXT:    [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i32 0
; CHECK-NEXT:    ret <2 x float> [[R]]
;
  %xf = bitcast i32 %x to float
  %vf = bitcast i64 %notv to <2 x float>
  %r = insertelement <2 x float> %vf, float %xf, i32 0
  ret <2 x float> %r
}

; Negative test - wrong source type for scalar.

define <2 x float> @bitcast_inselt_wrong_bitcast2(<2 x i16> %notscalar, <2 x i32> %v) {
; CHECK-LABEL: @bitcast_inselt_wrong_bitcast2(
; CHECK-NEXT:    [[XF:%.*]] = bitcast <2 x i16> [[NOTSCALAR:%.*]] to float
; CHECK-NEXT:    [[VF:%.*]] = bitcast <2 x i32> [[V:%.*]] to <2 x float>
; CHECK-NEXT:    [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i32 0
; CHECK-NEXT:    ret <2 x float> [[R]]
;
  %xf = bitcast <2 x i16> %notscalar to float
  %vf = bitcast <2 x i32> %v to <2 x float>
  %r = insertelement <2 x float> %vf, float %xf, i32 0
  ret <2 x float> %r
}