llvm.org GIT mirror llvm / d326b55
[Reassociate] Remove bogus assert reported in PR42349. Also, add a FIXME for the unsafe transform on a unary FNeg. A unary FNeg can only be transformed to a FMul by -1.0 when the nnan flag is present. The unary FNeg project is a WIP, so the unsafe transformation is acceptable until that work is complete. The bogus assert with introduced in D63445. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363998 91177308-0d34-0410-b5e6-96231b3b80d8 Cameron McInally 3 months ago
2 changed file(s) with 19 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
267267 static BinaryOperator *LowerNegateToMultiply(Instruction *Neg) {
268268 assert((isa(Neg) || isa(Neg)) &&
269269 "Expected a Negate!");
270 // It's not safe to lower a unary FNeg into a FMul by -1.0. However,
271 // we can only reach this function with fast flags set, so it's
272 // safe to do with nnan.
273 assert((!isa(Neg) || Neg->isFast()) &&
274 "Expecting FastMathFlags!");
270 // FIXME: It's not safe to lower a unary FNeg into a FMul by -1.0.
275271 unsigned OpNo = isa(Neg) ? 1 : 0;
276272 Type *Ty = Neg->getType();
277273 Constant *NegOne = Ty->isIntOrIntVectorTy() ?
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -S | FileCheck %s
2
3 define float @wibble(float %tmp6) #0 {
4 ; CHECK-LABEL: @wibble(
5 ; CHECK-NEXT: bb:
6 ; CHECK-NEXT: [[TMP7:%.*]] = fmul float [[TMP6:%.*]], -1.000000e+00
7 ; CHECK-NEXT: [[TMP0:%.*]] = fsub float -0.000000e+00, 0.000000e+00
8 ; CHECK-NEXT: [[TMP9:%.*]] = fmul fast float [[TMP6]], 0xFFF0000000000000
9 ; CHECK-NEXT: ret float [[TMP9]]
10 ;
11 bb:
12 %tmp7 = fsub float -0.000000e+00, %tmp6
13 %tmp9 = fmul fast float %tmp7, 0x7FF0000000000000
14 ret float %tmp9
15 }
16
17 attributes #0 = { "use-soft-float"="false" }