[AArch64][NFC] NFC for const vector as Instruction operand (#116790)
[llvm-project.git] / llvm / test / Transforms / InstCombine / math-odd-even-parity.ll
blob4c8cf7a99d895f20b20a84309fa208618a040c24
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 declare double @erf(double)
5 declare double @cos(double)
6 declare double @fabs(double)
8 declare void @use(double) nounwind
10 ; Check odd parity: -erf(-x) == erf(x)
11 define double @test_erf(double %x) {
12 ; CHECK-LABEL: define double @test_erf(
13 ; CHECK-SAME: double [[X:%.*]]) {
14 ; CHECK-NEXT:    [[RES:%.*]] = tail call reassoc double @erf(double [[X]])
15 ; CHECK-NEXT:    ret double [[RES]]
17   %neg_x = fneg double %x
18   %res = tail call reassoc double @erf(double %neg_x)
19   %neg_res = fneg double %res
20   ret double %neg_res
23 ; Check even parity: cos(fabs(x)) == cos(x)
24 define double @test_cos_fabs(double %x) {
25 ; CHECK-LABEL: define double @test_cos_fabs(
26 ; CHECK-SAME: double [[X:%.*]]) {
27 ; CHECK-NEXT:    [[RES:%.*]] = tail call reassoc double @cos(double [[X]])
28 ; CHECK-NEXT:    ret double [[RES]]
30   %fabs_res = call double @fabs(double %x)
31   %res = tail call reassoc double @cos(double %fabs_res)
32   ret double %res
35 ; Do nothing in case of multi-use
36 define double @test_erf_multi_use(double %x) {
37 ; CHECK-LABEL: define double @test_erf_multi_use(
38 ; CHECK-SAME: double [[X:%.*]]) {
39 ; CHECK-NEXT:    [[NEG_X:%.*]] = fneg double [[X]]
40 ; CHECK-NEXT:    call void @use(double [[NEG_X]])
41 ; CHECK-NEXT:    [[RES:%.*]] = call double @erf(double [[NEG_X]])
42 ; CHECK-NEXT:    [[NEG_RES:%.*]] = fneg double [[RES]]
43 ; CHECK-NEXT:    ret double [[NEG_RES]]
45   %neg_x = fneg double %x
46   call void @use(double %neg_x)
47   %res = call double @erf(double %neg_x)
48   %neg_res = fneg double %res
49   ret double %neg_res