2014-08-14 23:23:01 +08:00
|
|
|
; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
|
|
|
|
|
|
|
|
define float @test1(float %A, float %B) {
|
2017-11-10 02:26:49 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
|
|
|
; CHECK-NEXT: [[Z:%.*]] = fadd fast float %A, %B
|
|
|
|
; CHECK-NEXT: ret float [[Z]]
|
|
|
|
;
|
|
|
|
%W = fadd fast float %B, -5.0
|
|
|
|
%Y = fadd fast float %A, 5.0
|
|
|
|
%Z = fadd fast float %W, %Y
|
|
|
|
ret float %Z
|
2014-08-14 23:23:01 +08:00
|
|
|
}
|
2017-11-10 02:26:49 +08:00
|
|
|
|
2017-11-14 01:29:11 +08:00
|
|
|
; Check again using minimal subset of FMF.
|
|
|
|
|
|
|
|
define float @test1_reassoc(float %A, float %B) {
|
|
|
|
; CHECK-LABEL: @test1_reassoc(
|
|
|
|
; CHECK-NEXT: [[W:%.*]] = fadd reassoc float %B, -5.000000e+00
|
|
|
|
; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float %A, 5.000000e+00
|
|
|
|
; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[W]]
|
|
|
|
; CHECK-NEXT: ret float [[Z]]
|
|
|
|
;
|
|
|
|
%W = fadd reassoc float %B, -5.0
|
|
|
|
%Y = fadd reassoc float %A, 5.0
|
|
|
|
%Z = fadd reassoc float %W, %Y
|
|
|
|
ret float %Z
|
|
|
|
}
|
|
|
|
|