llvm.org GIT mirror llvm / 22aae05
[Reassoc] Small fix to support unary FNeg in NegateValue(...) Differential Revision: https://reviews.llvm.org/D66612 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369772 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 30 days ago
2 changed file(s) with 25 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
860860 // this use. We do this by moving it to the entry block (if it is a
861861 // non-instruction value) or right after the definition. These negates will
862862 // be zapped by reassociate later, so we don't need much finesse here.
863 BinaryOperator *TheNeg = cast>(U);
863 Instruction *TheNeg = cast>(U);
864864
865865 // Verify that the negate is in this function, V might be a constant expr.
866866 if (TheNeg->getParent()->getParent() != BI->getParent()->getParent())
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -S | FileCheck %s
2 ; D61675
3
4 define float @test1(float %arg, float %arg1, float %arg2, float %arg3) {
5 ; CHECK-LABEL: @test1(
6 ; CHECK-NEXT: [[TMP5:%.*]] = fneg fast float [[ARG:%.*]]
7 ; CHECK-NEXT: [[TMP1:%.*]] = fsub fast float [[ARG3:%.*]], [[ARG2:%.*]]
8 ; CHECK-NEXT: [[TMP2_NEG:%.*]] = fadd fast float [[TMP5]], 5.000000e+02
9 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast float [[TMP2_NEG]], [[TMP1]]
10 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast float [[TMP3]], [[TMP3]]
11 ; CHECK-NEXT: [[TMP6:%.*]] = fdiv fast float [[TMP5]], [[ARG1:%.*]]
12 ; CHECK-NEXT: [[TMP7:%.*]] = fadd fast float [[TMP4]], [[TMP6]]
13 ; CHECK-NEXT: ret float [[TMP7]]
14 ;
15 %tmp1 = fsub fast float %arg3, %arg2
16 %tmp2 = fadd fast float %arg, -5.000000e+02
17 %tmp3 = fsub fast float %tmp1, %tmp2
18 %tmp4 = fmul fast float %tmp3, %tmp3
19 %tmp5 = fneg fast float %arg
20 %tmp6 = fdiv fast float %tmp5, %arg1
21 %tmp7 = fadd fast float %tmp6, %tmp4
22 ret float %tmp7
23 }