mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-28 02:37:37 +00:00
[InstCombine] add tests for fmul/fdiv with fabs operands; NFC
This commit is contained in:
parent
7a3f2a734a
commit
fc3cf48e12
@ -595,3 +595,63 @@ define float @fabs_same_op_extra_use(float %x) {
|
||||
%r = fdiv ninf reassoc float %a, %a
|
||||
ret float %r
|
||||
}
|
||||
|
||||
define float @fabs_fabs(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[R:%.*]] = fdiv float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
;
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
%y.fabs = call float @llvm.fabs.f32(float %y)
|
||||
%r = fdiv float %x.fabs, %y.fabs
|
||||
ret float %r
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use1(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use1(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[X_FABS]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[R:%.*]] = fdiv ninf float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
;
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
call void @use_f32(float %x.fabs)
|
||||
%y.fabs = call float @llvm.fabs.f32(float %y)
|
||||
%r = fdiv ninf float %x.fabs, %y.fabs
|
||||
ret float %r
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use2(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use2(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call fast float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call fast float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[Y_FABS]])
|
||||
; CHECK-NEXT: [[R:%.*]] = fdiv reassoc ninf float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
;
|
||||
%x.fabs = call fast float @llvm.fabs.f32(float %x)
|
||||
%y.fabs = call fast float @llvm.fabs.f32(float %y)
|
||||
call void @use_f32(float %y.fabs)
|
||||
%r = fdiv reassoc ninf float %x.fabs, %y.fabs
|
||||
ret float %r
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use3(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use3(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[X_FABS]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[Y_FABS]])
|
||||
; CHECK-NEXT: [[R:%.*]] = fdiv float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
;
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
call void @use_f32(float %x.fabs)
|
||||
%y.fabs = call float @llvm.fabs.f32(float %y)
|
||||
call void @use_f32(float %y.fabs)
|
||||
%r = fdiv float %x.fabs, %y.fabs
|
||||
ret float %r
|
||||
}
|
||||
|
@ -480,8 +480,8 @@ define float @fabs_squared_fast(float %x) {
|
||||
ret float %mul
|
||||
}
|
||||
|
||||
define float @fabs_x_fabs(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_x_fabs(
|
||||
define float @fabs_fabs(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X_FABS]], [[Y_FABS]]
|
||||
@ -493,6 +493,53 @@ define float @fabs_x_fabs(float %x, float %y) {
|
||||
ret float %mul
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use1(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use1(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[X_FABS]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul ninf float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[MUL]]
|
||||
;
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
call void @use_f32(float %x.fabs)
|
||||
%y.fabs = call float @llvm.fabs.f32(float %y)
|
||||
%mul = fmul ninf float %x.fabs, %y.fabs
|
||||
ret float %mul
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use2(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use2(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call fast float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call fast float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[Y_FABS]])
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc ninf float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[MUL]]
|
||||
;
|
||||
%x.fabs = call fast float @llvm.fabs.f32(float %x)
|
||||
%y.fabs = call fast float @llvm.fabs.f32(float %y)
|
||||
call void @use_f32(float %y.fabs)
|
||||
%mul = fmul reassoc ninf float %x.fabs, %y.fabs
|
||||
ret float %mul
|
||||
}
|
||||
|
||||
define float @fabs_fabs_extra_use3(float %x, float %y) {
|
||||
; CHECK-LABEL: @fabs_fabs_extra_use3(
|
||||
; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[X_FABS]])
|
||||
; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: call void @use_f32(float [[Y_FABS]])
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X_FABS]], [[Y_FABS]]
|
||||
; CHECK-NEXT: ret float [[MUL]]
|
||||
;
|
||||
%x.fabs = call float @llvm.fabs.f32(float %x)
|
||||
call void @use_f32(float %x.fabs)
|
||||
%y.fabs = call float @llvm.fabs.f32(float %y)
|
||||
call void @use_f32(float %y.fabs)
|
||||
%mul = fmul float %x.fabs, %y.fabs
|
||||
ret float %mul
|
||||
}
|
||||
|
||||
; (X*Y) * X => (X*X) * Y
|
||||
; The transform only requires 'reassoc', but test other FMF in
|
||||
; the commuted variants to make sure FMF propagates as expected.
|
||||
@ -572,9 +619,9 @@ declare float @llvm.log2.f32(float)
|
||||
|
||||
define float @log2half(float %x, float %y) {
|
||||
; CHECK-LABEL: @log2half(
|
||||
; CHECK-NEXT: [[LOG2:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[LOG2]], [[X:%.*]]
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fsub fast float [[TMP1]], [[X]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[X:%.*]]
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fsub fast float [[TMP2]], [[X]]
|
||||
; CHECK-NEXT: ret float [[MUL]]
|
||||
;
|
||||
%halfy = fmul float %y, 0.5
|
||||
@ -585,10 +632,10 @@ define float @log2half(float %x, float %y) {
|
||||
|
||||
define float @log2half_commute(float %x1, float %y) {
|
||||
; CHECK-LABEL: @log2half_commute(
|
||||
; CHECK-NEXT: [[LOG2:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[LOG2]], [[X1:%.*]]
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fsub fast float [[TMP1]], [[X1]]
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[TMP2]], 0x3FC24924A0000000
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]])
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[X1:%.*]]
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP2]], [[X1]]
|
||||
; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[TMP3]], 0x3FC24924A0000000
|
||||
; CHECK-NEXT: ret float [[MUL]]
|
||||
;
|
||||
%x = fdiv float %x1, 7.0 ; thwart complexity-based canonicalization
|
||||
|
Loading…
Reference in New Issue
Block a user