[Bug tree-optimization/113718] New: std::bit_cast making the compiler generate unnecessary code.

2024-02-02 Thread cassio.neri at gmail dot com via Gcc-bugs
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: #include void f(); auto const p1 = auto const p2 = std::bit_cast(); bool a() { return p1 == p2

[Bug middle-end/110906] New: __attribute__((optimize("no-math-errno"))) has no effect.

2023-08-04 Thread cassio.neri at gmail dot com via Gcc-bugs
ty: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider this C++ code compiled with -O3: double g(double x) { return std::sqrt(x); } Usually this does call t

[Bug tree-optimization/107564] New: Fail to recognize overflow check for addition of __uint128_t operands

2022-11-07 Thread cassio.neri at gmail dot com via Gcc-bugs
: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: char f128(__uint128_t m, __uint128_t n) { #if !defined(USE_BUILTIN_ADD_OVERFLOW) m += n

[Bug tree-optimization/104539] Failed to inline a very simple template function when it's explicit instantiated.

2022-02-14 Thread cassio.neri at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104539 --- Comment #1 from Cassio Neri --- Sorry, the last snippet above should be template inline int f() { return 0; }

[Bug tree-optimization/104539] New: Failed to inline a very simple template function when it's explicit instantiated.

2022-02-14 Thread cassio.neri at gmail dot com via Gcc-bugs
Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: template //inline int f() { return 0; } int g

[Bug tree-optimization/104444] New: Missing constant folding in shift expression.

2022-02-08 Thread cassio.neri at gmail dot com via Gcc-bugs
: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- #include inline bool f(uint32_t m, int n) { return (m >> n) != 0; } bool g(int n) { return f(1 << 24, n); } g can be optimised to &qu

[Bug tree-optimization/101436] Yet another bogus "array subscript is partly outside array bounds"

2021-07-13 Thread cassio.neri at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101436 --- Comment #3 from Cassio Neri --- Because of the typeid check the unsafe static_cast never happens and I think the compiler should not be warning about a problem that doesn't exist. Besides, there's no array involved in this code. I

[Bug tree-optimization/101436] New: Yet another bogus "array subscript is partly outside array bounds"

2021-07-13 Thread cassio.neri at gmail dot com via Gcc-bugs
ty: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- This bogus warning was reported at least twice recently: #98266 and #101374. Below is a new case that

[Bug tree-optimization/101225] New: Example where y % 16 == 0 seems more expensive than y % 400 == 0.

2021-06-26 Thread cassio.neri at gmail dot com via Gcc-bugs
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider this implementation of is_leap_year: bool is_leap_year_1(short year) { return year % 100 == 0 ? year

[Bug tree-optimization/88797] [9 Regression] Unneeded branch added when function is inlined (function runs faster if not inlined)

2021-05-14 Thread cassio.neri at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88797 --- Comment #13 from Cassio Neri --- FWIW: This seems to have been fixed since 10.1. As we can see in [1], on version 10.1, test_f has no unnecessary branches, as opposed to version 9.3. [1] https://godbolt.org/z/h87Efbanb As far as I'm

[Bug middle-end/93634] Improving modular calculations (e.g. divisibility tests).

2020-02-11 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93634 --- Comment #1 from Cassio Neri --- FYI, this is what clang trunk generates: imull $-1431655765, %edi, %eax # imm = 0xAAAB addl $1431655764, %eax # imm = 0x5554 rorl %eax cmpl $715827882, %eax # imm = 0x2AAA setb %al retq

[Bug middle-end/93634] New: Improving modular calculations (e.g. divisibility tests).

2020-02-08 Thread cassio.neri at gmail dot com
Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: bool f(unsigned n) { return n % 6 == 4; } at -O3 the code generated for x86_64 is mov%edi,%eax mov$0xaaab,%edx

[Bug libstdc++/92124] New: std::vector copy-assigning when it should move-assign.

2019-10-16 Thread cassio.neri at gmail dot com
Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider two vectors a and rv. In the situation below a = std::move(rv) copy-assigns elements of rv into a, violating [container.requirements.general]/4, Table

[Bug c++/91158] "if (__builtin_constant_p(n))" versus "if constexpr (__builtin_constant_p(n))"

2019-07-14 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91158 --- Comment #7 from Cassio Neri --- (In reply to Jakub Jelinek from comment #4) Got it! Thank you, Mark and Jonathan. Please, feel free to close the ticket.

[Bug c++/91158] "if (__builtin_constant_p(n))" versus "if constexpr (__builtin_constant_p(n))"

2019-07-14 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91158 --- Comment #3 from Cassio Neri --- Forget my use case and comments on dead code elimination. That was a digression. (My bad.) In general, I don't expect `if` and `if constexpr` to behave the same but I do in this particular case. (I might be

[Bug c++/91158] New: "if (__builtin_constant_p(n))" versus "if constexpr (__builtin_constant_p(n))"

2019-07-13 Thread cassio.neri at gmail dot com
D Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: constexpr bool f0(int n) { if (__builtin_constant_p(n)) return tr

[Bug middle-end/12849] testing divisibility by constant

2019-05-31 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12849 --- Comment #7 from Cassio Neri --- Thanks for implementing the modular inverse algorithm in gcc. However, the implementation has an issue. In some cases, for no obvious reason, the compiler falls back to the old algorithm. For instance,

[Bug tree-optimization/90447] Missed opportunities to use adc (worse when -1 is involved)

2019-05-13 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90447 --- Comment #1 from Cassio Neri --- Forgot to mention this discussion on SO: https://stackoverflow.com/questions/56101507/is-there-anything-special-about-1-0x-regarding-adc

[Bug tree-optimization/90447] New: Missed opportunities to use adc (worse when -1 is involved)

2019-05-12 Thread cassio.neri at gmail dot com
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- The following are three attempts to get gcc to generate adc instructions from C++: #include unsigned constexpr X = 0

[Bug c++/89960] New: Implicit derived to base conversion considered type punning.

2019-04-04 Thread cassio.neri at gmail dot com
Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: struct base { int i; void f(){} }; template struct derived : base { void g1() { return (this->

[Bug tree-optimization/88797] Unneeded branch added when function is inlined (function runs faster if not inlined)

2019-01-11 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88797 --- Comment #5 from Cassio Neri --- There's a (fragile) workaround: void use(unsigned); #define VERSION 0 bool f(unsigned x, unsigned y) { #if VERSION == 0 return x < + (y <= ); #else bool b = y <= ; return x < +

[Bug tree-optimization/88797] Unneeded branch added when function is inlined (function runs faster if not inlined)

2019-01-10 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88797 --- Comment #4 from Cassio Neri --- Comment on attachment 45408 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45408 Running example The magic numbers 4, 6, 7, 0x24924924u and 0xb6db6db7u were chosen in an attempt to maximize the

[Bug tree-optimization/88797] Unneeded branch added when function is inlined (function runs faster if not inlined)

2019-01-10 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88797 --- Comment #3 from Cassio Neri --- The attached file is running example that shows that performance is damaged. The code runs faster when test_f calls g instead of f where g is bool g(unsigned x, unsigned y) { if (x >= y) return false;

[Bug tree-optimization/88797] Unneeded branch added when function is inlined (function runs faster if not inlined)

2019-01-10 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88797 --- Comment #2 from Cassio Neri --- Created attachment 45408 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45408=edit Running example

[Bug rtl-optimization/88797] New: Unneeded branch added when function is inlined (function runs faster if not inlined)

2019-01-10 Thread cassio.neri at gmail dot com
Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- Consider: void use(unsigned); bool f(unsigned x, unsigned y) { return x < + (y <

[Bug middle-end/12849] testing divisibility by constant

2018-03-14 Thread cassio.neri at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12849 Cassio Neri changed: What|Removed |Added CC||cassio.neri at gmail dot com --- Comment

[Bug tree-optimization/84648] New: Missed optimization : loop not removed.

2018-03-01 Thread cassio.neri at gmail dot com
-optimization Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Target Milestone: --- The loop below is not eliminated: int main() { for (unsigned i = 0; i < (1u << 31); ++i) { } return 0; } Compiled with -O3: main: xor eax

[Bug c++/59238] New: Dynamic allocating a list-initialized object of a type with private destructor fails.

2013-11-21 Thread cassio.neri at gmail dot com
Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com Consider: class foo { ~foo() {} }; int main() { new foo; // OK new foo(); // OK new foo{}; // error: 'foo::~foo()' is private

[Bug c++/58170] New: Crash when aliasing a template class that is a member of its template base class.

2013-08-15 Thread cassio.neri at gmail dot com
Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cassio.neri at gmail dot com The code below crashes gcc 4.8.1 (coincidentaly, it also crashes clang 3.3

[Bug c++/56693] New: Fail to ignore const qualification on top of a function type.

2013-03-22 Thread cassio.neri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56693 Bug #: 56693 Summary: Fail to ignore const qualification on top of a function type. Classification: Unclassified Product: gcc Version: 4.8.0 Status:

[Bug c++/55101] New: Invalid implicit conversion in initialization when source type is a template argument type

2012-10-27 Thread cassio.neri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55101 Bug #: 55101 Summary: Invalid implicit conversion in initialization when source type is a template argument type Classification: Unclassified Product: gcc Version:

[Bug libstdc++/54722] New: std::is_nothrow_default_constructibleT::value depends on whether destructor throws or not.

2012-09-26 Thread cassio.neri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54722 Bug #: 54722 Summary: std::is_nothrow_default_constructibleT::value depends on whether destructor throws or not. Classification: Unclassified Product: gcc Version: