[PATCH] SelectionDAG: fold (fp_to_u/sint (u/sint_to_fp val)) when possible

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Feb 9 11:11:02 PST 2015


> On 2015-Feb-09, at 08:53, Fiona Glaser <fglaser at apple.com> wrote:
> 
> Some slight improvements/tweaks based on internal comments.
> 
> Fiona

Why not do this at the IR level (in -instcombine)?

Looks like it already handles the case in @bar; it just needs support
for @foo:

$ opt -S -instcombine < float-conv-elim.ll
; ModuleID = '<stdin>'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"

; Function Attrs: nounwind ssp uwtable
define i32 @foo(i8 zeroext %a) #0 {
entry:
  %conv = uitofp i8 %a to float
  %conv1 = fptosi float %conv to i32
  ret i32 %conv1
}

; Function Attrs: nounwind ssp uwtable
define zeroext i8 @bar(i8 zeroext %a) #0 {
entry:
  ret i8 %a
}

attributes #0 = { nounwind ssp uwtable "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" }





More information about the llvm-commits mailing list