[Bug tree-optimization/104992] New: [missed optimization] x / y * y == x not optimized to x % y == 0

2022-03-20 Thread tilkax at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104992

Bug ID: 104992
   Summary: [missed optimization] x / y * y == x not optimized to
x % y == 0
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tilkax at gmail dot com
  Target Milestone: ---

This is especially helpful for constant y because checking
division-by-a-constant remainders against zero allows further optimization.

Repro case:

unsigned foo(unsigned x, unsigned y)
{
return x / y * y == x;
}

GCC -O3:
mov eax, edi
xor edx, edx
div esi
mov eax, edi
sub eax, edx
cmp eax, edi
seteal
movzx   eax, al
ret

Clang -O3:
mov eax, edi
xor edx, edx
div esi
xor eax, eax
testedx, edx
seteal
ret

[Bug c++/78147] The -Wshadow warning is too aggressive with constructor parameters

2020-07-31 Thread tilkax at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78147

Tillmann Karras  changed:

   What|Removed |Added

 CC||tilkax at gmail dot com

--- Comment #5 from Tillmann Karras  ---
Ping.

This warning is useful, but as was pointed out in comment #2, it currently
triggers three times for each parameter.

[Bug c++/96311] false positive for -Wunused-but-set-variable (const/constexpr identifier used in generic lambda)

2020-07-27 Thread tilkax at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96311

--- Comment #2 from Tillmann Karras  ---
(In reply to Martin Liška from comment #1)
> Confirmed, but it seems the code is rejected with clang:
> [...]
> Is it a valid test-case?

I think so.

There is a bug report for Clang: https://bugs.llvm.org/show_bug.cgi?id=25627
And MSVC used to have the same problem:
https://developercommunity.visualstudio.com/content/problem/367326/problems-with-capturing-constexpr-in-lambda.html

[Bug c++/96311] New: false positive for -Wunused-but-set-variable (const/constexpr identifier used in generic lambda)

2020-07-24 Thread tilkax at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96311

Bug ID: 96311
   Summary: false positive for -Wunused-but-set-variable
(const/constexpr identifier used in generic lambda)
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tilkax at gmail dot com
  Target Milestone: ---

Using gcc version 11.0.0 20200723, this code:

void foo()
{
constexpr int used = 0;
[](auto unused)
{
return used;
};
}

triggers an incorrect warning:

:3:19: warning: variable 'used' set but not used
[-Wunused-but-set-variable]
3 | constexpr int used = 0;
  |   ^~~~

It doesn't matter whether the lambda is called but it does need to be a generic
lambda to trigger the incorrect warning.

Also, both the lambda parameter as well as the lambda itself are unused here
but don't trigger any warnings :/

[Bug target/85539] New: x86_64: loads are not always narrowed

2018-04-26 Thread tilkax at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85539

Bug ID: 85539
   Summary: x86_64: loads are not always narrowed
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tilkax at gmail dot com
  Target Milestone: ---

When casting a 64-bit memory value to 32 bits, it's possible to only load the
lower 32 bits (this also avoids the REX prefix). GCC doesn't always do this:
https://godbolt.org/g/EzqKNo


#include 

uint32_t foo(uint64_t *p)
{
return *p;
}


Actual:
mov rax, QWORD PTR [rdi]
ret

Expected:
mov eax, DWORD PTR [rdi]
ret