New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 43233 - Assertion failed: (Exp != 0 && "Incorrect exponent 0 not handled"), function getPow, on std::pow(n, -0.0)
Summary: Assertion failed: (Exp != 0 && "Incorrect exponent 0 not handled"), function ...
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Sanjay Patel
URL:
Keywords:
Depends on:
Blocks: release-9.0.0
  Show dependency tree
 
Reported: 2019-09-06 01:37 PDT by Alexander Zaitsev
Modified: 2019-09-09 03:54 PDT (History)
10 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zaitsev 2019-09-06 01:37:39 PDT
For the code:


#include <cmath>

double t1(double n) {
    return std::pow(n, -0.0);
}


clang (trunk, 8.0) crashes with the follworing message: https://pastebin.com/w7nVhwtu

clang 7.0 and below works fine.


Godbolt playground: https://godbolt.org/z/aRbTH0
Comment 1 Dimitry Andric 2019-09-06 02:55:57 PDT
FWIW, this is triggered in particular by -ffast-math:

$ cat pr43233-min.cpp
// clang -cc1 -triple x86_64-- -S -ffast-math -O1 pr43233-min.cpp

extern "C" double pow(double, double);

double f(double d)
{
  return pow(d, -0.0);
}

$ clang -cc1 -triple x86_64-- -S -ffast-math -O1 pr43233-min.cpp
Assertion failed: (Exp != 0 && "Incorrect exponent 0 not handled"), function getPow, file llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp, line 1170.
Abort trap

It looks like this regressed with https://reviews.llvm.org/rL339578 ("[SLC] Expand simplification of pow() for vector types") by evandro.
Comment 2 Sanjay Patel 2019-09-06 08:43:00 PDT
(In reply to Dimitry Andric from comment #1)
> It looks like this regressed with https://reviews.llvm.org/rL339578 ("[SLC]
> Expand simplification of pow() for vector types") by evandro.

Yes - this was an unintentional diff:
ExpoC->getValueAPF().isZero() handles either -0.0/+0.0, but m_SpecificFP(0.0) does not.

I can fix this.
Comment 3 Evandro Menezes 2019-09-06 09:09:22 PDT
Thank you.
Comment 4 Sanjay Patel 2019-09-06 09:33:45 PDT
Trunk fix committed:
https://reviews.llvm.org/rL371221

And I didn't know it, but there was an identical patch in progress in here:
https://reviews.llvm.org/D67248

We probably want to get this fixed in the branches too, so not marking as resolved yet.
Comment 5 Hans Wennborg 2019-09-09 02:44:11 PDT
Merged to release_90 in r371381.
Comment 6 Sanjay Patel 2019-09-09 03:54:28 PDT
(In reply to Hans Wennborg from comment #5)
> Merged to release_90 in r371381.

Thanks, Hans!