Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Instruction Selection Error #76

Closed
dylanmckay opened this issue Apr 23, 2015 · 1 comment
Closed

Instruction Selection Error #76

dylanmckay opened this issue Apr 23, 2015 · 1 comment

Comments

@dylanmckay
Copy link
Member

Test case (fourierf.ll):

; ModuleID = 'fourierf.c'
target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-i64:8:8-f32:8:8-f64:8:8-n8"
target triple = "avr-none-none"

%struct.__file = type { i8*, i8, i8, i16, i16, i16 (i8, %struct.__file*)*, i16 (%struct.__file*)*, i8* }

@.str = private unnamed_addr constant [7 x i8] c"RealIn\00", align 1
@.str1 = private unnamed_addr constant [8 x i8] c"RealOut\00", align 1
@.str2 = private unnamed_addr constant [8 x i8] c"ImagOut\00", align 1
@__iob = external global [0 x %struct.__file*]
@.str3 = private unnamed_addr constant [35 x i8] c"Error in fft_float():  %s == NULL\0A\00", align 1

; Function Attrs: nounwind
define void @fft_float(i16 %NumSamples, i16 %InverseTransform, float* readonly %RealIn, float* readonly %ImagIn, float* %RealOut, float* %ImagOut) #0 {
entry:
  %tobool = icmp ne i16 %InverseTransform, 0
  %. = select i1 %tobool, double 0xC01921FB54442D18, double 0x401921FB54442D18
  %0 = bitcast float* %RealIn to i8*
  tail call fastcc void @CheckPointer(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i16 0, i16 0))
  %1 = bitcast float* %RealOut to i8*
  tail call fastcc void @CheckPointer(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str1, i16 0, i16 0))
  %2 = bitcast float* %ImagOut to i8*
  tail call fastcc void @CheckPointer(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str2, i16 0, i16 0))
  %call = tail call i16 @NumberOfBitsNeeded(i16 %NumSamples) #4
  %cmp195 = icmp eq i16 %NumSamples, 0
  br i1 %cmp195, label %for.end94, label %for.body.lr.ph

for.body.lr.ph:                                   ; preds = %entry
  %cmp3 = icmp eq float* %ImagIn, null
  br label %for.body

for.cond7.preheader:                              ; preds = %cond.end
  %cmp8191 = icmp ult i16 %NumSamples, 2
  br i1 %cmp8191, label %for.end94, label %for.body10

for.body:                                         ; preds = %for.body.lr.ph, %cond.end
  %i.0196 = phi i16 [ 0, %for.body.lr.ph ], [ %inc, %cond.end ]
  %call1 = tail call i16 @ReverseBits(i16 %i.0196, i16 %call) #4
  %arrayidx = getelementptr inbounds float, float* %RealIn, i16 %i.0196
  %3 = load float, float* %arrayidx, align 4, !tbaa !1
  %arrayidx2 = getelementptr inbounds float, float* %RealOut, i16 %call1
  store float %3, float* %arrayidx2, align 4, !tbaa !1
  br i1 %cmp3, label %cond.end, label %cond.false

cond.false:                                       ; preds = %for.body
  %arrayidx4 = getelementptr inbounds float, float* %ImagIn, i16 %i.0196
  %4 = load float, float* %arrayidx4, align 4, !tbaa !1
  %conv = fpext float %4 to double
  br label %cond.end

cond.end:                                         ; preds = %for.body, %cond.false
  %cond = phi double [ %conv, %cond.false ], [ 0.000000e+00, %for.body ]
  %conv5 = fptrunc double %cond to float
  %arrayidx6 = getelementptr inbounds float, float* %ImagOut, i16 %call1
  store float %conv5, float* %arrayidx6, align 4, !tbaa !1
  %inc = add nuw i16 %i.0196, 1
  %cmp = icmp ult i16 %inc, %NumSamples
  br i1 %cmp, label %for.body, label %for.cond7.preheader

for.body10:                                       ; preds = %for.cond7.preheader, %for.end92
  %BlockSize.0193 = phi i16 [ %shl, %for.end92 ], [ 2, %for.cond7.preheader ]
  %BlockEnd.0192 = phi i16 [ %BlockSize.0193, %for.end92 ], [ 1, %for.cond7.preheader ]
  %conv11 = uitofp i16 %BlockSize.0193 to double
  %div = fdiv double %., %conv11
  %mul = fmul double %div, -2.000000e+00
  %call12 = tail call double @sin(double %mul) #5
  %sub13 = fsub double -0.000000e+00, %div
  %call14 = tail call double @sin(double %sub13) #5
  %call16 = tail call double @cos(double %mul) #5
  %cos = tail call double @cos(double %div)
  %mul19 = fmul double %cos, 2.000000e+00
  %cmp29182 = icmp eq i16 %BlockEnd.0192, 0
  br label %for.cond28.preheader

for.cond28.preheader:                             ; preds = %for.body10, %for.inc90
  %i.1190 = phi i16 [ 0, %for.body10 ], [ %add91, %for.inc90 ]
  br i1 %cmp29182, label %for.inc90, label %for.body31

for.body31:                                       ; preds = %for.cond28.preheader, %for.body31
  %j.0188 = phi i16 [ %inc87, %for.body31 ], [ %i.1190, %for.cond28.preheader ]
  %ai.sroa.4.0187 = phi double [ %sub44, %for.body31 ], [ %call14, %for.cond28.preheader ]
  %ai.sroa.8.0186 = phi double [ %ai.sroa.4.0187, %for.body31 ], [ %call12, %for.cond28.preheader ]
  %n.0185 = phi i16 [ %inc88, %for.body31 ], [ 0, %for.cond28.preheader ]
  %ar.sroa.4.0184 = phi double [ %sub35, %for.body31 ], [ %cos, %for.cond28.preheader ]
  %ar.sroa.8.0183 = phi double [ %ar.sroa.4.0184, %for.body31 ], [ %call16, %for.cond28.preheader ]
  %mul33 = fmul double %mul19, %ar.sroa.4.0184
  %sub35 = fsub double %mul33, %ar.sroa.8.0183
  %mul42 = fmul double %mul19, %ai.sroa.4.0187
  %sub44 = fsub double %mul42, %ai.sroa.8.0186
  %add = add i16 %j.0188, %BlockEnd.0192
  %arrayidx51 = getelementptr inbounds float, float* %RealOut, i16 %add
  %5 = load float, float* %arrayidx51, align 4, !tbaa !1
  %conv52 = fpext float %5 to double
  %mul53 = fmul double %sub35, %conv52
  %arrayidx55 = getelementptr inbounds float, float* %ImagOut, i16 %add
  %6 = load float, float* %arrayidx55, align 4, !tbaa !1
  %conv56 = fpext float %6 to double
  %mul57 = fmul double %sub44, %conv56
  %sub58 = fsub double %mul53, %mul57
  %mul62 = fmul double %sub35, %conv56
  %mul66 = fmul double %sub44, %conv52
  %add67 = fadd double %mul66, %mul62
  %arrayidx68 = getelementptr inbounds float, float* %RealOut, i16 %j.0188
  %7 = load float, float* %arrayidx68, align 4, !tbaa !1
  %conv69 = fpext float %7 to double
  %sub70 = fsub double %conv69, %sub58
  %conv71 = fptrunc double %sub70 to float
  store float %conv71, float* %arrayidx51, align 4, !tbaa !1
  %arrayidx73 = getelementptr inbounds float, float* %ImagOut, i16 %j.0188
  %8 = load float, float* %arrayidx73, align 4, !tbaa !1
  %conv74 = fpext float %8 to double
  %sub75 = fsub double %conv74, %add67
  %conv76 = fptrunc double %sub75 to float
  store float %conv76, float* %arrayidx55, align 4, !tbaa !1
  %9 = load float, float* %arrayidx68, align 4, !tbaa !1
  %conv79 = fpext float %9 to double
  %add80 = fadd double %sub58, %conv79
  %conv81 = fptrunc double %add80 to float
  store float %conv81, float* %arrayidx68, align 4, !tbaa !1
  %10 = load float, float* %arrayidx73, align 4, !tbaa !1
  %conv83 = fpext float %10 to double
  %add84 = fadd double %add67, %conv83
  %conv85 = fptrunc double %add84 to float
  store float %conv85, float* %arrayidx73, align 4, !tbaa !1
  %inc87 = add i16 %j.0188, 1
  %inc88 = add nuw i16 %n.0185, 1
  %cmp29 = icmp ult i16 %inc88, %BlockEnd.0192
  br i1 %cmp29, label %for.body31, label %for.inc90

for.inc90:                                        ; preds = %for.body31, %for.cond28.preheader
  %add91 = add i16 %i.1190, %BlockSize.0193
  %cmp21 = icmp ult i16 %add91, %NumSamples
  br i1 %cmp21, label %for.cond28.preheader, label %for.end92

for.end92:                                        ; preds = %for.inc90
  %shl = shl i16 %BlockSize.0193, 1
  %cmp8 = icmp ugt i16 %shl, %NumSamples
  br i1 %cmp8, label %for.end94, label %for.body10

for.end94:                                        ; preds = %for.end92, %entry, %for.cond7.preheader
  br i1 %tobool, label %if.then96, label %if.end113

if.then96:                                        ; preds = %for.end94
  %conv97 = uitofp i16 %NumSamples to double
  %cmp99180 = icmp eq i16 %NumSamples, 0
  br i1 %cmp99180, label %if.end113, label %for.body101

for.body101:                                      ; preds = %if.then96, %for.body101
  %i.2181 = phi i16 [ %inc111, %for.body101 ], [ 0, %if.then96 ]
  %arrayidx102 = getelementptr inbounds float, float* %RealOut, i16 %i.2181
  %11 = load float, float* %arrayidx102, align 4, !tbaa !1
  %conv103 = fpext float %11 to double
  %div104 = fdiv double %conv103, %conv97
  %conv105 = fptrunc double %div104 to float
  store float %conv105, float* %arrayidx102, align 4, !tbaa !1
  %arrayidx106 = getelementptr inbounds float, float* %ImagOut, i16 %i.2181
  %12 = load float, float* %arrayidx106, align 4, !tbaa !1
  %conv107 = fpext float %12 to double
  %div108 = fdiv double %conv107, %conv97
  %conv109 = fptrunc double %div108 to float
  store float %conv109, float* %arrayidx106, align 4, !tbaa !1
  %inc111 = add nuw i16 %i.2181, 1
  %cmp99 = icmp ult i16 %inc111, %NumSamples
  br i1 %cmp99, label %for.body101, label %if.end113

if.end113:                                        ; preds = %for.body101, %if.then96, %for.end94
  ret void
}

; Function Attrs: nounwind
define internal fastcc void @CheckPointer(i8* readnone %p, i8* %name) #0 {
entry:
  %cmp = icmp eq i8* %p, null
  br i1 %cmp, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  %0 = load %struct.__file*, %struct.__file** getelementptr inbounds ([0 x %struct.__file*], [0 x %struct.__file*]* @__iob, i16 0, i16 2), align 2, !tbaa !5
  %call = tail call i16 (%struct.__file*, i8*, ...)* @fprintf(%struct.__file* %0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str3, i16 0, i16 0), i8* %name) #4
  tail call void @exit(i16 1) #6
  unreachable

if.end:                                           ; preds = %entry
  ret void
}

declare i16 @NumberOfBitsNeeded(i16) #1

declare i16 @ReverseBits(i16, i16) #1

; Function Attrs: nounwind readnone
declare double @sin(double) #2

; Function Attrs: nounwind readnone
declare double @cos(double) #2

; Function Attrs: nounwind
declare i16 @fprintf(%struct.__file* nocapture, i8* nocapture readonly, ...) #0

; Function Attrs: noreturn
declare void @exit(i16) #3

attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { noreturn "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { nounwind }
attributes #5 = { nounwind readnone }
attributes #6 = { noreturn nounwind }

!llvm.ident = !{!0}

!0 = !{!"clang version 3.7.0 (https://github.com/avr-llvm/clang.git 00a0b3863ac817790d9b344da4fc499b71140a7a) (llvm/llvm.git 70f966eb9eb5e2cae5d4f62ae213ae035677efee)"}
!1 = !{!2, !2, i64 0}
!2 = !{!"float", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C/C++ TBAA"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !3, i64 0}

Command line:

llc fourierf.ll -march=avr

Note that the instruction selection fails presumably because the default MCU avr2 does not support an IR pattern due to not having some subtarget feature. Passing the argument -mcpu=avrxmega7 will succeed.

Tested with revision 3539d69.

@dylanmckay
Copy link
Member Author

Fixed at some point before 5d82a27.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant