2019-04-17 12:52:47 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
|
|
|
|
declare void @use(float)
|
|
|
|
|
2019-05-10 21:18:57 +08:00
|
|
|
define float @fneg_fneg(float %a) {
|
|
|
|
;
|
|
|
|
; CHECK-LABEL: @fneg_fneg(
|
2019-05-11 04:01:04 +08:00
|
|
|
; CHECK-NEXT: ret float [[A:%.*]]
|
2019-05-10 21:18:57 +08:00
|
|
|
;
|
|
|
|
%f = fneg float %a
|
|
|
|
%r = fneg float %f
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; -(X * C) --> X * (-C)
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fsub(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fsub(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul float [[X:%.*]], -4.200000e+01
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fsub float -0.0, %m
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fneg(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fneg(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul float [[X:%.*]], -4.200000e+01
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fneg float %m
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Fast math is not required, but it should be propagated.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fsub_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fsub_fmf(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul reassoc nsz float [[X:%.*]], -4.200000e+01
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fsub reassoc nsz float -0.0, %m
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fneg_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fneg_fmf(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul reassoc nsz float [[X:%.*]], -4.200000e+01
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fneg reassoc nsz float %m
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Extra use prevents the fold. We don't want to replace the fneg with an fmul.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fsub_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fsub_extra_use(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[M]]
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: call void @use(float [[M]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fsub float -0.0, %m
|
|
|
|
call void @use(float %m)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fmul_fneg_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fneg_extra_use(
|
|
|
|
; CHECK-NEXT: [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[M]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[M]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%m = fmul float %x, 42.0
|
|
|
|
%r = fneg float %m
|
|
|
|
call void @use(float %m)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fmul_fsub_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fsub_vec(
|
2020-02-23 20:42:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul <4 x double> [[X:%.*]], <double -4.200000e+01, double 0xFFF8000000000000, double 0xFFF0000000000000, double undef>
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
2020-02-23 20:42:47 +08:00
|
|
|
%m = fmul <4 x double> %x, <double 42.0, double 0x7FF8000000000000, double 0x7FF0000000000000, double undef>
|
2019-04-17 12:52:47 +08:00
|
|
|
%r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %m
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fmul_fneg_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fmul_fneg_vec(
|
2020-02-23 20:42:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fmul <4 x double> [[X:%.*]], <double -4.200000e+01, double 0xFFF8000000000000, double 0xFFF0000000000000, double undef>
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
2020-02-23 20:42:47 +08:00
|
|
|
%m = fmul <4 x double> %x, <double 42.0, double 0x7FF8000000000000, double 0x7FF0000000000000, double undef>
|
2019-05-09 03:06:03 +08:00
|
|
|
%r = fneg <4 x double> %m
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; -(X / C) --> X / (-C)
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fsub(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fsub(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, -42.0
|
|
|
|
%r = fsub float -0.0, %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fneg(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fneg(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, -42.0
|
|
|
|
%r = fneg float %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Fast math is not required, but it should be propagated.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fsub_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fsub_fmf(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, -42.0
|
|
|
|
%r = fsub nnan float -0.0, %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fneg_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fneg_fmf(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[X:%.*]], 4.200000e+01
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, -42.0
|
|
|
|
%r = fneg nnan float %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fsub_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fsub_extra_use(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: call void @use(float [[D]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, 42.0
|
|
|
|
%r = fsub float -0.0, %d
|
|
|
|
call void @use(float %d)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op1_constant_fneg_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fneg_extra_use(
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[D]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float %x, 42.0
|
|
|
|
%r = fneg float %d
|
|
|
|
call void @use(float %d)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fdiv_op1_constant_fsub_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fsub_vec(
|
2019-05-06 00:07:09 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> [[X:%.*]], <double 4.200000e+01, double 0x7FF800000ABCD000, double 0x7FF0000000000000, double undef>
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv <4 x double> %x, <double -42.0, double 0xFFF800000ABCD000, double 0xFFF0000000000000, double undef>
|
|
|
|
%r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fdiv_op1_constant_fneg_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op1_constant_fneg_vec(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> [[X:%.*]], <double 4.200000e+01, double 0x7FF800000ABCD000, double 0x7FF0000000000000, double undef>
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv <4 x double> %x, <double -42.0, double 0xFFF800000ABCD000, double 0xFFF0000000000000, double undef>
|
|
|
|
%r = fneg <4 x double> %d
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; -(C / X) --> (-C) / X
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fsub(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fsub(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float 42.0, %x
|
|
|
|
%r = fsub float -0.0, %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fneg(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fneg(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float 42.0, %x
|
|
|
|
%r = fneg float %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Fast math is not required, but it should be propagated.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fsub_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fsub_fmf(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv fast float -4.200000e+01, [[X:%.*]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float 42.0, %x
|
|
|
|
%r = fsub fast float -0.0, %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fneg_fmf(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fneg_fmf(
|
2019-05-21 03:10:30 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv fast float -4.200000e+01, [[X:%.*]]
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float 42.0, %x
|
|
|
|
%r = fneg fast float %d
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fsub_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fsub_extra_use(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[D:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: call void @use(float [[D]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float -42.0, %x
|
|
|
|
%r = fsub float -0.0, %d
|
|
|
|
call void @use(float %d)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define float @fdiv_op0_constant_fneg_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fneg_extra_use(
|
|
|
|
; CHECK-NEXT: [[D:%.*]] = fdiv float -4.200000e+01, [[X:%.*]]
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[D]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[D]])
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%d = fdiv float -42.0, %x
|
|
|
|
%r = fneg float %d
|
|
|
|
call void @use(float %d)
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
; Try a vector. Use special constants (NaN, INF, undef) because they don't change anything.
|
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fdiv_op0_constant_fsub_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fsub_vec(
|
2020-02-23 20:42:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> <double 4.200000e+01, double 0xFFF8000000000000, double 0x7FF0000000000000, double undef>, [[X:%.*]]
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
2020-02-23 20:42:47 +08:00
|
|
|
%d = fdiv <4 x double> <double -42.0, double 0x7FF8000000000000, double 0xFFF0000000000000, double undef>, %x
|
2019-04-17 12:52:47 +08:00
|
|
|
%r = fsub <4 x double> <double -0.0, double -0.0, double -0.0, double -0.0>, %d
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
2019-05-07 01:29:22 +08:00
|
|
|
|
2019-05-09 03:06:03 +08:00
|
|
|
define <4 x double> @fdiv_op0_constant_fneg_vec(<4 x double> %x) {
|
|
|
|
; CHECK-LABEL: @fdiv_op0_constant_fneg_vec(
|
2020-02-23 20:42:47 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fdiv <4 x double> <double 4.200000e+01, double 0xFFF8000000000000, double 0x7FF0000000000000, double undef>, [[X:%.*]]
|
2019-05-09 03:06:03 +08:00
|
|
|
; CHECK-NEXT: ret <4 x double> [[R]]
|
|
|
|
;
|
2020-02-23 20:42:47 +08:00
|
|
|
%d = fdiv <4 x double> <double -42.0, double 0x7FF8000000000000, double 0xFFF0000000000000, double undef>, %x
|
2019-05-09 03:06:03 +08:00
|
|
|
%r = fneg <4 x double> %d
|
|
|
|
ret <4 x double> %r
|
|
|
|
}
|
|
|
|
|
2019-05-07 01:29:22 +08:00
|
|
|
; Sink FP negation through a select:
|
|
|
|
; c ? -x : -y --> -(c ? x : y)
|
|
|
|
|
|
|
|
define <2 x double> @fneg_fneg_sel(<2 x double> %x, <2 x double> %y, i1 %cond) {
|
|
|
|
; CHECK-LABEL: @fneg_fneg_sel(
|
2019-05-07 04:34:05 +08:00
|
|
|
; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], <2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]
|
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = fneg <2 x double> [[SEL_V]]
|
2019-05-07 01:29:22 +08:00
|
|
|
; CHECK-NEXT: ret <2 x double> [[SEL]]
|
|
|
|
;
|
|
|
|
%n1 = fneg <2 x double> %x
|
|
|
|
%n2 = fneg <2 x double> %y
|
|
|
|
%sel = select i1 %cond, <2 x double> %n1, <2 x double> %n2
|
|
|
|
ret <2 x double> %sel
|
|
|
|
}
|
|
|
|
|
|
|
|
; An extra use is allowed.
|
|
|
|
|
|
|
|
define float @fneg_fneg_sel_extra_use1(float %x, float %y, i1 %cond) {
|
|
|
|
; CHECK-LABEL: @fneg_fneg_sel_extra_use1(
|
|
|
|
; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[N1]])
|
2019-05-07 04:34:05 +08:00
|
|
|
; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X]], float [[Y:%.*]]
|
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
|
2019-05-07 01:29:22 +08:00
|
|
|
; CHECK-NEXT: ret float [[SEL]]
|
|
|
|
;
|
|
|
|
%n1 = fneg float %x
|
|
|
|
call void @use(float %n1)
|
|
|
|
%n2 = fneg float %y
|
|
|
|
%sel = select i1 %cond, float %n1, float %n2
|
|
|
|
ret float %sel
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @fneg_fneg_sel_extra_use2(float %x, float %y, i1 %cond) {
|
|
|
|
; CHECK-LABEL: @fneg_fneg_sel_extra_use2(
|
|
|
|
; CHECK-NEXT: [[N2:%.*]] = fneg float [[Y:%.*]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[N2]])
|
2019-05-07 04:34:05 +08:00
|
|
|
; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X:%.*]], float [[Y]]
|
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
|
2019-05-07 01:29:22 +08:00
|
|
|
; CHECK-NEXT: ret float [[SEL]]
|
|
|
|
;
|
|
|
|
%n1 = fneg float %x
|
|
|
|
%n2 = fneg float %y
|
|
|
|
call void @use(float %n2)
|
|
|
|
%sel = select i1 %cond, float %n1, float %n2
|
|
|
|
ret float %sel
|
|
|
|
}
|
|
|
|
|
|
|
|
; Legacy form of fneg should work too.
|
|
|
|
|
|
|
|
define float @fsub_fsub_sel_extra_use1(float %x, float %y, i1 %cond) {
|
|
|
|
; CHECK-LABEL: @fsub_fsub_sel_extra_use1(
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
|
2019-05-07 01:29:22 +08:00
|
|
|
; CHECK-NEXT: call void @use(float [[N1]])
|
2019-05-07 04:34:05 +08:00
|
|
|
; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X]], float [[Y:%.*]]
|
2020-02-28 01:05:54 +08:00
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]]
|
2019-05-07 01:29:22 +08:00
|
|
|
; CHECK-NEXT: ret float [[SEL]]
|
|
|
|
;
|
|
|
|
%n1 = fsub float -0.0, %x
|
|
|
|
call void @use(float %n1)
|
|
|
|
%n2 = fsub float -0.0, %y
|
|
|
|
%sel = select i1 %cond, float %n1, float %n2
|
|
|
|
ret float %sel
|
|
|
|
}
|
|
|
|
|
|
|
|
; Negative test: but 2 extra uses would require an extra instruction.
|
|
|
|
|
|
|
|
define float @fneg_fneg_sel_extra_use3(float %x, float %y, i1 %cond) {
|
|
|
|
; CHECK-LABEL: @fneg_fneg_sel_extra_use3(
|
|
|
|
; CHECK-NEXT: [[N1:%.*]] = fneg float [[X:%.*]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[N1]])
|
|
|
|
; CHECK-NEXT: [[N2:%.*]] = fneg float [[Y:%.*]]
|
|
|
|
; CHECK-NEXT: call void @use(float [[N2]])
|
|
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], float [[N1]], float [[N2]]
|
|
|
|
; CHECK-NEXT: ret float [[SEL]]
|
|
|
|
;
|
|
|
|
%n1 = fneg float %x
|
|
|
|
call void @use(float %n1)
|
|
|
|
%n2 = fneg float %y
|
|
|
|
call void @use(float %n2)
|
|
|
|
%sel = select i1 %cond, float %n1, float %n2
|
|
|
|
ret float %sel
|
|
|
|
}
|
2020-01-21 02:32:55 +08:00
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; Negative test
|
|
|
|
|
2020-01-21 02:32:55 +08:00
|
|
|
define float @fneg_fadd_constant(float %x) {
|
|
|
|
; CHECK-LABEL: @fneg_fadd_constant(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[A]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
%r = fneg float %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; Negative test
|
|
|
|
|
2020-01-21 02:32:55 +08:00
|
|
|
define float @fake_nsz_fadd_constant(float %x) {
|
|
|
|
; CHECK-LABEL: @fake_nsz_fadd_constant(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg float [[A]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
%r = fsub float -0.0, %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; -(X + C) --> -C - X
|
2020-01-21 02:32:55 +08:00
|
|
|
|
|
|
|
define float @fneg_nsz_fadd_constant(float %x) {
|
|
|
|
; CHECK-LABEL: @fneg_nsz_fadd_constant(
|
2020-01-22 22:29:19 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub nsz float -4.200000e+01, [[X:%.*]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
%r = fneg nsz float %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; -(X + C) --> -C - X
|
2020-01-21 02:32:55 +08:00
|
|
|
|
|
|
|
define float @fake_fneg_nsz_fadd_constant(float %x) {
|
|
|
|
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant(
|
2020-01-22 22:29:19 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub fast float -4.200000e+01, [[X:%.*]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
%r = fsub fast float -0.0, %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; Negative test
|
|
|
|
|
2020-01-21 02:32:55 +08:00
|
|
|
define float @fneg_nsz_fadd_constant_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fneg_nsz_fadd_constant_extra_use(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: call void @use(float [[A]])
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg nsz float [[A]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
call void @use(float %a)
|
|
|
|
%r = fneg nsz float %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; Negative test
|
|
|
|
|
2020-01-21 02:32:55 +08:00
|
|
|
define float @fake_fneg_nsz_fadd_constant_extra_use(float %x) {
|
|
|
|
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_extra_use(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
|
|
|
|
; CHECK-NEXT: call void @use(float [[A]])
|
2020-03-10 23:05:31 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fneg fast float [[A]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, 42.0
|
|
|
|
call void @use(float %a)
|
|
|
|
%r = fsub fast float -0.0, %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; -(X + C) --> -C - X
|
2020-01-21 02:32:55 +08:00
|
|
|
|
|
|
|
define <2 x float> @fneg_nsz_fadd_constant_vec(<2 x float> %x) {
|
|
|
|
; CHECK-LABEL: @fneg_nsz_fadd_constant_vec(
|
2020-01-22 22:29:19 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub reassoc nnan nsz <2 x float> <float -4.200000e+01, float -4.300000e+01>, [[X:%.*]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret <2 x float> [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd <2 x float> %x, <float 42.0, float 43.0>
|
|
|
|
%r = fneg nsz nnan reassoc <2 x float> %a
|
|
|
|
ret <2 x float> %r
|
|
|
|
}
|
|
|
|
|
2020-01-22 22:29:19 +08:00
|
|
|
; -(X + C) --> -C - X
|
2020-01-21 02:32:55 +08:00
|
|
|
|
|
|
|
define <2 x float> @fake_fneg_nsz_fadd_constant_vec(<2 x float> %x) {
|
|
|
|
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_vec(
|
2020-01-22 22:29:19 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub nsz <2 x float> <float -4.200000e+01, float undef>, [[X:%.*]]
|
2020-01-21 02:32:55 +08:00
|
|
|
; CHECK-NEXT: ret <2 x float> [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd <2 x float> %x, <float 42.0, float undef>
|
|
|
|
%r = fsub nsz <2 x float> <float undef, float -0.0>, %a
|
|
|
|
ret <2 x float> %r
|
|
|
|
}
|
2020-01-22 22:29:19 +08:00
|
|
|
|
|
|
|
@g = external global i16, align 1
|
|
|
|
|
|
|
|
define float @fneg_nsz_fadd_constant_expr(float %x) {
|
|
|
|
; CHECK-LABEL: @fneg_nsz_fadd_constant_expr(
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, bitcast (i32 ptrtoint (i16* @g to i32) to float)
|
|
|
|
%r = fneg nsz float %a
|
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @fake_fneg_nsz_fadd_constant_expr(float %x) {
|
|
|
|
; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_expr(
|
|
|
|
; CHECK-NEXT: [[R:%.*]] = fsub nsz float fneg (float bitcast (i32 ptrtoint (i16* @g to i32) to float)), [[X:%.*]]
|
|
|
|
; CHECK-NEXT: ret float [[R]]
|
|
|
|
;
|
|
|
|
%a = fadd float %x, bitcast (i32 ptrtoint (i16* @g to i32) to float)
|
|
|
|
%r = fsub nsz float -0.0, %a
|
|
|
|
ret float %r
|
|
|
|
}
|