[Bug libstdc++/94295] use __builtin_operator_new and __builtin_operator_delete when available

2020-03-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94295 --- Comment #5 from Marc Glisse --- (In reply to Richard Smith from comment #2) > (In reply to Marc Glisse from comment #1) > > (In reply to Richard Smith from comment #0) > > > The C++ language rules do not permit optimization (eg, deletion) of

[Bug tree-optimization/94294] [missed optimization] new+delete of unused local string not removed

2020-03-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94294 --- Comment #4 from Marc Glisse --- I don't believe there is a "new/delete" issue.

[Bug libstdc++/94295] use __builtin_operator_new and __builtin_operator_delete when available

2020-03-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94295 --- Comment #1 from Marc Glisse --- (In reply to Richard Smith from comment #0) > The C++ language rules do not permit optimization (eg, deletion) of direct > calls to 'operator new' and 'operator delete'. I thought that was considered a bug?

[Bug tree-optimization/94293] [missed optimization] Useless statements populating local string not removed

2020-03-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94293 --- Comment #4 from Marc Glisse --- Or just void f(){ int*p=new int[1]; *p=42; delete[] p; } while it does optimize for void f(){ int*p=new int; *p=42; delete p; } because the front-end gives us a clobber before operator delete.

[Bug tree-optimization/94294] [missed optimization] new+delete of unused local string not removed

2020-03-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94294 --- Comment #2 from Marc Glisse --- (In reply to Eyal Rozenberg from comment #0) > Note: I suppose it's theoretically possible that this bug only manifests > because bug 94293 prevents the allocated space from being recognized as > unused; but

[Bug tree-optimization/94293] [missed optimization] Useless statements populating local string not removed

2020-03-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94293 --- Comment #1 from Marc Glisse --- Adding inline void* operator new(std::size_t n){return __builtin_malloc(n);} inline void operator delete(void*p)noexcept{__builtin_free(p);} inline void operator

[Bug tree-optimization/94274] fold phi whose incoming args are defined from binary operations

2020-03-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94274 --- Comment #1 from Marc Glisse --- Detecting common beginnings / endings in branches is something gcc does very seldom. Even at -Os, for if(cond)f(b);else f(c); we need to wait until rtl-optimizations to get a single call to f. (of course the

[Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1))

2020-03-20 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234 --- Comment #2 from Marc Glisse --- The closest we have is /* (A * C) +- (B * C) -> (A+-B) * C and (A * C) +- A -> A * (C+-1). which does not handle conversions, although it should be possible to add them.

[Bug target/94194] x86: Provide feraiseexcept builtins

2020-03-16 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94194 --- Comment #1 from Marc Glisse --- Is there a convenient way for gcc to know the value of FE_DIVBYZERO, etc on the target? Do we need to hardcode it? Can we rely on different libc on the same processor to use the same value? What happens if the

[Bug tree-optimization/61338] too many permutation in a vectorized "reverse loop"

2020-03-16 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61338 --- Comment #3 from Marc Glisse --- Possibly easier is the case of a reduction, where permutations are clearly irrelevant. int f(int*arr,int size){ int sum=0; for(int i = 0; i < size; i++){ sum += arr[size-1-i]; } return sum; } We

[Bug c++/94141] New: c++20 rewritten operator== recursive call mixing friend and external operators for template class

2020-03-11 Thread glisse at gcc dot gnu.org
Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- (reduced from a user of boost/operators.hpp) template class A; template

[Bug tree-optimization/94092] Code size and performance degradations after -ftree-loop-distribute-patterns was enabled at -O[2s]+

2020-03-09 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94092 --- Comment #3 from Marc Glisse --- Does profile feedback (so we have an idea on the loop count) make any difference? It seems clear that for a loop that in practice just copies one long, having to arrange the arguments, make a function call,

[Bug tree-optimization/93971] std::string considered to alias declared objects of incompatible types

2020-03-01 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93971 --- Comment #7 from Marc Glisse --- (In reply to Martin Sebor from comment #6) > (1) one that would make "std::string::ptr" on par with > that of any other pointer other than char (i.e., a char that's not allowed > to be used to access anything

[Bug tree-optimization/93971] std::string considered to alias declared objects of incompatible types

2020-02-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93971 --- Comment #5 from Marc Glisse --- It has never been very clear to me what restrict means on a struct member, but I believe adding it to the pointer in vector means that in a function: void f(vector*a, vector*b) the compiler could assume that

[Bug tree-optimization/93971] C++ containers considered to alias declared objects of incompatible types

2020-02-28 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93971 --- Comment #1 from Marc Glisse --- If x is NaN, you cannot simplify x!=x to false.

[Bug middle-end/93939] missing optimization for floating-point expression converted to integer whose result is known at compile time

2020-02-26 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93939 --- Comment #1 from Marc Glisse --- typedef long T; also generates a comparison with 24. The main issue is that b is used outside of the branch controlled by if(b==8), so a naive substitution misses it. Repeating 3*b in the branch is useless,

[Bug c/29186] optimzation breaks floating point exception flag reading

2020-02-25 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29186 --- Comment #23 from Marc Glisse --- (In reply to Richard B. Kreckel from comment #22) > I can't reproduce this bug any more, I think you are just lucky, I am sure it hasn't been fixed and gcc will still happily swap FP operations with function

[Bug tree-optimization/93917] New: VRP forgets range of value read from memory

2020-02-24 Thread glisse at gcc dot gnu.org
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- First a case that works: void f(int n){ if(n<0)__builtin_unreachable(); } EVRP assigns a range to n, and VRP1 fo

[Bug middle-end/93902] conversion from 64-bit long or unsigned long to double prevents simple optimization

2020-02-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93902 --- Comment #1 from Marc Glisse --- The current optimization in match.pd is an equivalence, it replaces (double)i==(double)j with i==j when the conversion is always exact. Here, what we would want is that inside the a==b branch, the compiler

[Bug tree-optimization/93896] Store merging uses SSE only for trivial types

2020-02-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93896 --- Comment #1 from Marc Glisse --- Without the constructor, we get plain *this_2(D).a = {}; which is expanded as an __int128 store. With the constructor, we get MEM[(struct M *)this_2(D)].p = 0B; MEM[(struct M *)this_2(D)].sz = 0;

[Bug tree-optimization/93891] CSE where clobber writes the same value

2020-02-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93891 --- Comment #1 from Marc Glisse --- On the original code (I can attach it if needed, but it is large, it is resizing a std::vector with reference-counted elements) FRE3 fails to simplify MEM[(struct Handle_for *)__cur_16] ={v} {CLOBBER};

[Bug tree-optimization/93891] New: CSE where clobber writes the same value

2020-02-22 Thread glisse at gcc dot gnu.org
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- void f(int**p,int**q){ ++**p; *q=*p; --**p; } produces _1 = *p_8(D); _2 = *_1; _3 = _2 + 1; *_1 = _3; *q_10(D

[Bug tree-optimization/93745] [8/9/10 Regression] Redundant store not eliminated with intermediate instruction

2020-02-17 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93745 --- Comment #8 from Marc Glisse --- (In reply to Martin Sebor from comment #7) > But regardless of what language might have even looser rules than C/C++ in > this area, it would seem like a rather unfortunate design limitation for GCC > not to

[Bug tree-optimization/93745] Redundant store not eliminated with intermediate instruction

2020-02-14 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93745 --- Comment #2 from Marc Glisse --- Ah, right :-( I thought the example rang a bell, but before your explanation I couldn't connect it, thanks.

[Bug tree-optimization/93745] New: Redundant store not eliminated with intermediate instruction

2020-02-14 Thread glisse at gcc dot gnu.org
-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- double d; void f(long*p){ long i=*p; d=3.; *p=i; } I would like *p=i

[Bug target/60181] constant folding of complex number incorrect

2020-02-11 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60181 --- Comment #10 from Marc Glisse --- Flags like -ftrapping-math can prevent gcc from folding at compile-time when the result is infinite (or maybe it always refuses to fold in that case). In your example, gcc generates a runtime call to __muldc3

[Bug middle-end/93644] [10 Regression] -Wreturn-local-addr July regression: new false-positive warning

2020-02-09 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93644 --- Comment #2 from Marc Glisse --- # buffer_2 = PHI <_bufD.1939(3), buffer_7(D)(9)> buffer_18 = ASSERT_EXPR ; Can't we deduce from this buffer_18 = buffer_7(D) ? Of course that's not a general solution, but it looks like a sensible

[Bug target/93594] Missed optimization with _mm256_set/setr_m128i intrinsics

2020-02-06 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93594 --- Comment #9 from Marc Glisse --- (In reply to Jakub Jelinek from comment #6) > if we change the cast patterns so that they are a > vec_concat of the operand and UNSPEC_CAST that then represents just the > uninitialized higher part,

[Bug target/93594] Missed optimization with _mm256_set/setr_m128i intrinsics

2020-02-06 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93594 --- Comment #4 from Marc Glisse --- The versions involving _mm256_cast* may be related to PR50829 and others (UNSPEC hiding the semantics of the operation).

[Bug rtl-optimization/90977] Inconsistencies with inline asm

2020-02-04 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90977 --- Comment #3 from Marc Glisse --- (In reply to Segher Boessenkool from comment #2) > Please open a separate bug for the powerpc ICE? I just tried and couldn't reproduce the ICE with the gcc-9 ppc64el cross-compiler I have now. Maybe that ICE

[Bug target/93535] slow float/double simple constant folding with -Ofast

2020-02-02 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93535 --- Comment #1 from Marc Glisse --- (testing clang++ -O2 -ffast-math is useful as well) It would be more helpful if you could isolate some specific transformations that gcc is missing, instead of one big benchmark. For instance: double f(int

[Bug tree-optimization/93504] Missed reassociation with constants and not of that constant with IORs

2020-01-30 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93504 --- Comment #4 from Marc Glisse --- /* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */ I guess several transformations like this one which match (unary m) could do with a second version for the case where m is constant (and thus (unary m) is already

[Bug target/93459] ix86_fold_builtin should handle __builtin_ia32_pcmpeqd128_mask and similar builtins

2020-01-27 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93459 --- Comment #2 from Marc Glisse --- For __builtin_ia32_vec_ext_v4si, shouldn't we lower it to an array access in gimple, when the second argument is constant? I assume we don't want to do it directly in smmintrin.h for diagnostic purposes.

[Bug middle-end/26724] __builtin_constant_p fails to recognise function with constant return

2020-01-22 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26724 --- Comment #4 from Marc Glisse --- (In reply to pskocik from comment #3) > I don't know if this is related, It isn't, please file a separate bug report. memcmp is optimized to an integer comparison in strlen, much later than the lowering of

[Bug rtl-optimization/91333] [9/10 Regression] suboptimal register allocation for inline asm

2020-01-17 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91333 --- Comment #5 from Marc Glisse --- With trunk (master?), compiling with -O3, h gives movapd %xmm1, %xmm3 addsd %xmm3, %xmm1 movapd %xmm0, %xmm2 addsd %xmm2, %xmm0 addsd %xmm1, %xmm0 which looks

[Bug libstdc++/87106] Group move and destruction of the source, where possible, for speed

2020-01-16 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87106 --- Comment #29 from Marc Glisse --- Note that __is_bitwise_relocatable is specialized to true for deque, so we are not super consistent here ;-) The original patch used is_trivially_move_constructible, IIRC I changed it to is_trivial so the

[Bug libstdc++/87106] Group move and destruction of the source, where possible, for speed

2020-01-15 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87106 --- Comment #24 from Marc Glisse --- Something like that, yes. Essentially, I used trivial because I was convinced it was safe in that case, not because it looked like the perfect condition. If someone can convincingly argue for a weaker

[Bug libstdc++/93151] system_error header fails to compile with -D_XOPEN_SOURCE=600

2020-01-09 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93151 --- Comment #2 from Marc Glisse --- (In reply to Jonathan Wakely from comment #1) > I don't know what the advantage of testing for them at configure time is. Strange systems that define them as enum values and not macros?

[Bug libstdc++/93147] std::tuple of empty structs with member equality operators has ambiguous equality operator

2020-01-03 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93147 --- Comment #3 from Marc Glisse --- (In reply to Alexander Kondratskiy from comment #0) > My suspicion is that tuple indirectly inherits the types `A` and `B`, and > even though it may be private inheritance, the compiler still finds both >

[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::unin

2019-12-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059 --- Comment #17 from Marc Glisse --- (In reply to fdlbxtqi from comment #15) > What I am worried about is that whether revamping these functions would be a > new wave of ABI breaking. I don't foresee any ABI issue here. Do make sure your code

[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::unin

2019-12-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059 --- Comment #13 from Marc Glisse --- (In reply to fdlbxtqi from comment #11) > TBH. I would rather see the library does the optimization instead of the > compiler. I do not trust the compiler can always optimize this stuff. If we have both,

[Bug tree-optimization/93063] Loop distribution and NOP conversions

2019-12-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93063 --- Comment #1 from Marc Glisse --- Created attachment 47549 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47549=edit Untested patch Not ready, at the very least it misses a comment and a test, but it shows where the test needs relaxing.

[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::unin

2019-12-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059 --- Comment #8 from Marc Glisse --- (In reply to fdlbxtqi from comment #6) > void copy_char_vector_with_iter(std::vector::iterator > out,std::vector const& bits) > { > std::copy_n(bits.begin(),bits.size(),out); > } > >

[Bug tree-optimization/93063] New: Loop distribution and NOP conversions

2019-12-24 Thread glisse at gcc dot gnu.org
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- This comes from PR 93059. void f(signed short*__restrict p,unsigned short*__restrict q,int n){ for(int i=0;i

[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::unin

2019-12-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059 --- Comment #7 from Marc Glisse --- (In reply to fdlbxtqi from comment #6) > > > clearly incorrect > > > > Please distinguish between what is wrong (generated code crashes, or returns > > 3 instead of 2), and what is suboptimal. > > Suppose

[Bug libstdc++/93059] char and char8_t does not talk with each other with memcpy. std::copy std::copy_n, std::fill, std::fill_n, std::uninitialized_copy std::uninitialized_copy_n, std::fill, std::unin

2019-12-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059 --- Comment #5 from Marc Glisse --- We could indeed relax a bit the "same type" condition. We could also make sure that __restrict appears somewhere in the call chain when using copy or uninitialized_*, which lets the compiler merge the 2

[Bug tree-optimization/93044] extra cast is not removed

2019-12-22 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93044 --- Comment #2 from Marc Glisse --- In match.pd && ((inter_unsignedp && inter_prec > inside_prec) == (final_unsignedp && final_prec > inter_prec)) looks suspicious.

[Bug target/93039] Fails to use SSE bitwise ops for float-as-int manipulations

2019-12-21 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93039 Marc Glisse changed: What|Removed |Added Target||x86_64-*-* --- Comment #1 from Marc

[Bug c++/93005] Redundant NEON loads/stores from stack are not eliminated

2019-12-19 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93005 Marc Glisse changed: What|Removed |Added Target||arm-linux-gnueabihf

[Bug c/92826] Impossible to silence warning: non-standard suffix on floating constant [-Wpedantic]

2019-12-05 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92826 --- Comment #2 from Marc Glisse --- I thought the name "pedantic" made it clear that it is going to warn about things that are just fine, and you shouldn't use it... You can disable the warning by inserting __extension__ in your code. It might

[Bug c++/65656] __builtin_constant_p should always be constexpr

2019-11-30 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65656 --- Comment #11 from Marc Glisse --- Comment #6 looks like it was probably fixed with bug 85746.

[Bug tree-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #20 from Marc Glisse --- (In reply to Jakub Jelinek from comment #19) > Created attachment 47398 [details] > gcc10-pr92712.patch > > Full untested patch. The patch looks very good to me :-)

[Bug rtl-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #16 from Marc Glisse --- (In reply to Jakub Jelinek from comment #15) > I guess we could handle those cases by using something like > check_for_binary_op_overflow, except that for the case where A might be -1 > and plusminus equal to

[Bug c++/92727] Idea for better error messages

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92727 --- Comment #11 from Marc Glisse --- (In reply to Jonathan Wakely from comment #10) > The bug in this example is that the push_back call needs to make a copy and > the type is not copyable. It's not a bug that the copy constructor is > implictly

[Bug c++/92727] Idea for better error messages

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92727 --- Comment #9 from Marc Glisse --- (In reply to Jonathan Wakely from comment #7) > I disagree. The static assert contains all you need to know, expert or not. > The benefit of seeing all the gory details is to figure out why something > didn't

[Bug rtl-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #11 from Marc Glisse --- (In reply to Jakub Jelinek from comment #10) > I know, it will be a small complication, sure, but it can be handled. Ah, I think I understand now. But still x=-1 a=INT_MAX a*x+x gives INT_MIN without

[Bug rtl-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #8 from Marc Glisse --- (In reply to Jakub Jelinek from comment #6) > The suggestion I'll try to work on is to check if C isn't a plus/minus expr > with constant second operand that doesn't go in the other direction and thus > where

[Bug rtl-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #7 from Marc Glisse --- The first question could be why SCCP produces (const int) ((unsigned int) t_2(D) + 4294967295) * v_3(D) + v_3(D) and not directly t*v. Several loop passes do have this tendency to split out the last (or first)

[Bug rtl-optimization/92712] [8/9/10 Regression] Performance regression with assumed values

2019-11-29 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92712 --- Comment #5 from Marc Glisse --- a*x+x -> (a+1)*x is unsafe (a=INT_MAX, x=0), but there are cases where we could prove that it is safe, in particular when a is actually b-1 (more generally for a*x+b*x when we can prove (with VRP?) that a+b

[Bug tree-optimization/92716] -Os doesn't inline byteswap function even though it's a single instruction

2019-11-28 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92716 --- Comment #4 from Marc Glisse --- Yes, the pass that recognizes bswap (unsurprisingly called bswap) happens much later than inlining in the pipeline. This kind of thing is unavoidable since cycling through optimization passes is considered

[Bug target/92592] Redundant comparison after subtraction on x86

2019-11-20 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92592 --- Comment #3 from Marc Glisse --- IFN_SUB_OVERFLOW recognition?

[Bug rtl-optimization/91333] [9/10 Regression] suboptimal register allocation for inline asm

2019-11-20 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91333 --- Comment #3 from Marc Glisse --- gcc version 9.2.1 20191109 (Debian 9.2.1-19) (current debian testing/unstable) gives me the 3 movapd, whether I use -O1, -O2 or -O3, and -Os gives 2 movapd. I didn't try with a vanilla gcc, not sure which

[Bug tree-optimization/71761] missing tailcall optimization

2019-11-18 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71761 --- Comment #5 from Marc Glisse --- The case "struct token { int i; };" was fixed in gcc-7. >= f (); [return slot optimization] [tail call] That's all you should see at this point, it is later that it gives up.

[Bug tree-optimization/92233] missed optimisation for multiplication when it's known that at least one of the arguments is 0

2019-10-26 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92233 --- Comment #1 from Marc Glisse --- (llvm doesn't do it either) Would some kind of threading be the most natural way to handle this? If the compiler duplicates the code as if (a==0) return a*b; else if (b==0) return a*b; then it becomes easy

[Bug c++/92194] maybe-uninitialized false positive with c++2a

2019-10-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92194 --- Comment #2 from Marc Glisse --- With -Wsystem-headers you also get the warning in C++17 (and it is actually a bit more informative, at least it says where it is used).

[Bug c++/85746] Premature evaluation of __builtin_constant_p?

2019-10-22 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85746 Marc Glisse changed: What|Removed |Added Status|NEW |RESOLVED Resolution|---

[Bug c++/85746] Premature evaluation of __builtin_constant_p?

2019-10-22 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85746 --- Comment #9 from Marc Glisse --- Author: glisse Date: Tue Oct 22 14:42:38 2019 New Revision: 277292 URL: https://gcc.gnu.org/viewcvs?rev=277292=gcc=rev Log: PR c++/85746: Don't fold __builtin_constant_p prematurely 2019-10-22 Marc Glisse

[Bug c++/92077] Multiple independent functions degrades optimizations

2019-10-12 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92077 --- Comment #2 from Marc Glisse --- It is quite natural for the compiler to inline functions that are only called once (it won't take more space) (although the compiler doesn't actually know that the function isn't also called in another TU)

[Bug c++/91428] Please warn on if constexpr (std::is_constant_evaluated())

2019-10-12 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91428 --- Comment #5 from Marc Glisse --- Would it make sense to add a fixit hint that removes "constexpr"? I think that might make the warning a bit clearer for some users. On the other hand, if is_constant_evaluated gets removed by P1938, there is

[Bug target/91796] Sub-optimal YMM register allocation.

2019-10-11 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91796 --- Comment #7 from Marc Glisse --- (In reply to Maxim Egorushkin from comment #3) > It seems to me that register allocation has been a weak spot in gcc for > years. Most such testcases show issues with arguments/return in very small

[Bug tree-optimization/91965] missing simplification for (C - a) << N

2019-10-02 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91965 --- Comment #2 from Marc Glisse --- (In reply to Alexander Monakov from comment #0) > Do we want to handle this early on via match.pd? Perhaps also applies to > simplifying (a +- C) << N. What exact transformation do you want? Canonicalize the

[Bug tree-optimization/91940] __builtin_bswap16 loop optimization

2019-10-02 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91940 --- Comment #7 from Marc Glisse --- (In reply to Jakub Jelinek from comment #1) > The loop with the rotate is vectorized, while the one with __builtin_bswap16 > is not. It is a bit surprising that we do not canonicalize one to the other

[Bug c++/91958] type info does not respect 'noexcept' on C++17 function types

2019-10-01 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91958 --- Comment #1 from Marc Glisse --- PR 83534 ? (it could also be related to bug 67772, but it is a bit further)

[Bug c++/86173] Default construction of a union (in std::optional)

2019-09-27 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86173 --- Comment #5 from Marc Glisse --- A similar example was reported on https://stackoverflow.com/q/57964217/1918193

[Bug c++/91889] [10 Regression] error: call of overloaded ‘to_value_ptr(B*&)’ is ambiguous

2019-09-26 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91889 --- Comment #8 from Marc Glisse --- int i; void f(int* const&) { } void f(const int* const &) { } void g(int* p) { f(p); } void h() { f(); } I find it painful that g is ambiguous, and confusing that h remains ok. It needs confirmation that CWG

[Bug sanitizer/91878] No sanitizer report for past-end access of std∷set

2019-09-24 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91878 --- Comment #3 from Marc Glisse --- -D_GLIBCXX_DEBUG is the current way to add many checks to libstdc++, and it detects this.

[Bug middle-end/91866] Sign extend of an int is not recognized

2019-09-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91866 --- Comment #1 from Marc Glisse --- See https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00821.html

[Bug libstdc++/91788] std::variant index +1-1

2019-09-23 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91788 --- Comment #3 from Marc Glisse --- (In reply to Jonathan Wakely from comment #2) > I think we can do that more generically. Does this look right? lgtm > (The downside would be that many more functions might need to be > friends to access

[Bug tree-optimization/91789] Value ranges determined from comparisons not used transitively

2019-09-17 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91789 --- Comment #2 from Marc Glisse --- We do manage if you swap the order of the first 2 comparisons, because this way we don't need to remember symbolic ranges: a<0 yields a range [0,inf] for a, b

[Bug libstdc++/91788] std::variant index +1-1

2019-09-16 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91788 --- Comment #1 from Marc Glisse --- Internally, it may also be possible to avoid calling index() so often and work with the raw _M_index more often.

[Bug libstdc++/91788] New: std::variant index +1-1

2019-09-16 Thread glisse at gcc dot gnu.org
Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- (this is a detail, it probably has a negligible impact) constexpr size_t index() const noexcept { return size_t(typename _Base::__index_type

[Bug libstdc++/78113] std::variant and std::visit's current implementations do not get optimized out (compared to "recursive visitation")

2019-09-16 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78113 --- Comment #6 from Marc Glisse --- (looking at the first testcase) There are 2 things. One is the implementation strategy in libstdc++ vs boost vs others (I don't know what is best, it probably depends on the application). The other one is that

[Bug tree-optimization/90387] [9/10 Regression] __builtin_constant_p and -Warray-bounds warnings

2019-09-11 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90387 --- Comment #8 from Marc Glisse --- (In reply to Bernd Buschinski from comment #6) > From the comments I assumed that the fix is kind of trivial There is a simple change that gives the behavior you want on one example, but it is far from

[Bug middle-end/91725] 275587[10 Regression] ICE in get_nonzero_bits starting with r275587

2019-09-10 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91725 --- Comment #2 from Marc Glisse --- (In reply to Jakub Jelinek from comment #1) > gcc10-pr91725.patch An alternative (I don't claim it is better) would be to make get_nonzero_bits conservatively return -1 on unknown input, like the comment

[Bug tree-optimization/91645] Missed optimization with sqrt(x*x)

2019-09-04 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91645 --- Comment #3 from Marc Glisse --- (In reply to Richard Biener from comment #1) > for y >= 0.0 the result is unspecified? NaN >= 0.0 is false, but even if it was unspecified, the implication would still be true. (In reply to Nikita Lisitsa

[Bug middle-end/91623] [7/8/9 Regression] -msse4.1 -O3 segfault in /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/smmintrin.h:270:10

2019-09-01 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91623 --- Comment #6 from Marc Glisse --- For the missed constant folding, it seems that we end up in fold_vec_perm, with type a vector of "long long", while arg0 and arg1 are vectors of "long", and we give up because of the early check "TREE_TYPE

[Bug middle-end/91623] [7/8/9 Regression] -msse4.1 -O3 segfault in /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/smmintrin.h:270:10

2019-08-31 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91623 Marc Glisse changed: What|Removed |Added Keywords||ice-on-valid-code

[Bug tree-optimization/91435] Better induction variable for vectorization

2019-08-13 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91435 --- Comment #1 from Marc Glisse --- (In reply to Marc Glisse from comment #0) > If we are only ever going to use x+2, why not use that instead, initialize > with {2,3,4,...}, and skip the +2 at every iteration? Or since we have another variable

[Bug tree-optimization/91435] New: Better induction variable for vectorization

2019-08-13 Thread glisse at gcc dot gnu.org
Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- Target: x86_64-*-* (from https://stackoverflow.com/q/57465290/1918193) long RegularTest(int n) { long sum = 0

[Bug c/91432] gcc -Wimplicit-fallthrough does not warn when fallthrough to break;

2019-08-13 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432 --- Comment #1 from Marc Glisse --- The warning basically says "you may have forgotten 'break;'". If it falls through to break anyway, what difference does it make if I add a redundant break?

[Bug tree-optimization/91425] Ordered compares aren't optimised

2019-08-12 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91425 --- Comment #7 from Marc Glisse --- (In reply to Segher Boessenkool from comment #6) > Maybe we should make "is this an ordered comparison" separate from the > actual comparison code. I was considering having a single .IFN_FENV_CMP (a, b, opts)

[Bug tree-optimization/91425] Ordered compares aren't optimised

2019-08-12 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91425 --- Comment #2 from Marc Glisse --- I think part of the problem with the current or_comparison optimization is that it relies on invert_tree_comparison in many cases, and that doesn't really work for floating point (and we handle the unsafe

[Bug c++/91397] -Wstringop-overflow specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807

2019-08-08 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397 --- Comment #7 from Marc Glisse --- (In reply to Steinar H. Gunderson from comment #6) > So basically GCC is worried that I might be calling allocate() with -1 > bytes, and gives a warning? Yes, although it might not always give the warning,

[Bug c++/91397] -Wstringop-overflow specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807

2019-08-08 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397 --- Comment #5 from Marc Glisse --- mem_strdupl calls allocate(len+1). If len+1 is 0, you proceed to write to s[len] i.e. 0[-1]. I think gcc would be happier if you handled this special case explicitly (you could error, trap, just assume it

[Bug c++/91397] -Wstringop-overflow specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807

2019-08-08 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397 --- Comment #4 from Marc Glisse --- I guess it happens in some dead path that gcc doesn't know is dead. At some point, you look at last_slash-path+1. Here there is a branch on whether this number is 0, and if it is 0, nonsense happens (writing 0

[Bug c++/91397] -Wstringop-overflow specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807

2019-08-08 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397 --- Comment #2 from Marc Glisse --- if (g == 0) return (char *)malloc(0); for (;;) ; so the only way this can return is if g is 0. This means that in j, k is -1, and you are calling memcpy with a huge

[Bug c++/91382] Missing pedwarn when using [[maybe_unused]] in C++14

2019-08-07 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91382 --- Comment #2 from Marc Glisse --- (In reply to Jakub Jelinek from comment #1) > Aren't unknown attributes supposed to be ignored? Bug 86368 is related to that point.

[Bug middle-end/91358] Wrong code with dynamic allocation and optional like class

2019-08-07 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91358 --- Comment #5 from Marc Glisse --- (In reply to Richard Biener from comment #4) > I guess valgrind could be improved to check > only at uses of the uninit value? It is used. In the easy case it would be used in "undef & 0", so the result does

[Bug c++/91383] C++17 should remove some library feature deprecated in C++14

2019-08-07 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91383 --- Comment #1 from Marc Glisse --- > "may fail to compile" we don't have to remove them, keeping them is actually on purpose so it is easier for users to have access to new features without breaking the old ones. What we could do is use the

[Bug libstdc++/91356] Poor optimization of calls involving std::unique_ptr

2019-08-06 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91356 --- Comment #9 from Marc Glisse --- (In reply to Jonathan Wakely from comment #8) > you'd still need a change to the Itanium ABI. Or an attribute like [[clang::trivial_abi]], or the one that p1029 is trying to standardize. But since we would

<    1   2   3   4   5   6   7   8   9   10   >