public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110281] New: wrong code with '-O3'
@ 2023-06-16 10:06 19373742 at buaa dot edu.cn
  2023-06-16 10:07 ` [Bug c/110281] " 19373742 at buaa dot edu.cn
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-06-16 10:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

            Bug ID: 110281
           Summary: wrong code with '-O3'
           Product: gcc
           Version: 11.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 19373742 at buaa dot edu.cn
  Target Milestone: ---

Created attachment 55341
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55341&action=edit
The preprocessed file

*******************************************************************************
OS and Platform:
CentOS Linux release 7.9.2009 (Core), x86_64 GNU/Linux
*******************************************************************************
gcc version:

# /home/gcc-releases/gcc-11-0615/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/gcc-releases/gcc-11-0615/bin/gcc
COLLECT_LTO_WRAPPER=/home/gcc-releases/gcc-11-0615/libexec/gcc/x86_64-pc-linux-gnu/11.4.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/gcc-releases/gcc-11-0615/
--disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.1 20230615 (GCC)
*******************************************************************************
Command Lines:
/home/gcc-releases/gcc-11-0615/bin/gcc -I
/home/csmith_record/include/csmith-2.3.0/ -O3
-fno-aggressive-loop-optimizations -fno-align-functions -fno-align-jumps
-fno-align-labels -fno-align-loops -fno-allocation-dce
-fno-asynchronous-unwind-tables -fno-auto-inc-dec -fno-bit-tests
-fno-branch-count-reg -fno-caller-saves -fno-code-hoisting
-fno-combine-stack-adjustments -fno-compare-elim -fno-cprop-registers
-fno-crossjumping -fno-cse-follow-jumps -fno-dce -fno-defer-pop
-fno-delete-null-pointer-checks -fno-devirtualize
-fno-devirtualize-speculatively -fno-dse -fno-early-inlining
-fno-expensive-optimizations -fno-forward-propagate -fno-fp-int-builtin-inexact
-fno-function-cse -fno-gcse -fno-gcse-after-reload -fno-gcse-lm
-fno-guess-branch-probability -fno-hoist-adjacent-loads -fno-if-conversion
-fno-if-conversion2 -fno-indirect-inlining -fno-inline -fno-inline-atomics
-fno-inline-functions -fno-inline-functions-called-once
-fno-inline-small-functions -fno-ipa-bit-cp -fno-ipa-cp -fno-ipa-cp-clone
-fno-ipa-icf -fno-ipa-icf-functions -fno-ipa-icf-variables -fno-ipa-modref
-fno-ipa-profile -fno-ipa-pure-const -fno-ipa-ra -fno-ipa-reference
-fno-ipa-reference-addressable -fno-ipa-sra -fno-ipa-stack-alignment
-fno-ipa-vrp -fno-ira-hoist-pressure -fno-ira-share-save-slots
-fno-ira-share-spill-slots -fno-isolate-erroneous-paths-dereference -fno-ivopts
-fno-jump-tables -fno-lifetime-dse -fno-loop-interchange
-fno-loop-unroll-and-jam -fno-lra-remat -fno-math-errno
-fno-move-loop-invariants -fno-omit-frame-pointer -fno-optimize-sibling-calls
-fno-optimize-strlen -fno-partial-inlining -fno-peel-loops -fno-peephole
-fno-peephole2 -fno-plt -fno-predictive-commoning -fno-prefetch-loop-arrays
-fno-printf-return-value -fno-ree -fno-reg-struct-return -fno-rename-registers
-fno-reorder-blocks -fno-reorder-blocks-and-partition -fno-reorder-functions
-fno-rerun-cse-after-loop -fno-sched-critical-path-heuristic
-fno-sched-dep-count-heuristic -fno-sched-group-heuristic -fno-sched-interblock
-fno-sched-last-insn-heuristic -fno-sched-rank-heuristic -fno-sched-spec
-fno-sched-spec-insn-heuristic -fno-sched-stalled-insns-dep
-fno-schedule-fusion -fno-schedule-insns2 -fno-short-enums -fno-shrink-wrap
-fno-shrink-wrap-separate -fno-signed-zeros -fno-split-ivs-in-unroller
-fno-split-loops -fno-split-paths -fno-split-wide-types -fno-ssa-backprop
-fno-ssa-phiopt -fno-stdarg-opt -fno-store-merging -fno-strict-aliasing
-fno-strict-volatile-bitfields -fno-thread-jumps -fno-toplevel-reorder
-fno-trapping-math -fno-tree-bit-ccp -fno-tree-builtin-call-dce -fno-tree-ccp
-fno-tree-ch -fno-tree-coalesce-vars -fno-tree-copy-prop -fno-tree-cselim
-fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-forwprop
-fno-tree-fre -fno-tree-loop-distribute-patterns -fno-tree-loop-distribution
-fno-tree-loop-if-convert -fno-tree-loop-im -fno-tree-loop-ivcanon
-fno-tree-loop-optimize -fno-tree-loop-vectorize -fno-tree-partial-pre
-fno-tree-phiprop -fno-tree-pre -fno-tree-pta -fno-tree-reassoc
-fno-tree-scev-cprop -fno-tree-sink -fno-tree-slp-vectorize -fno-tree-slsr
-fno-tree-sra -fno-tree-switch-conversion -fno-tree-tail-merge -fno-tree-ter
-fno-tree-vrp -fno-unroll-completely-grow-size -fno-unswitch-loops
-fno-unwind-tables -fno-var-tracking -fno-var-tracking-assignments
-fno-version-loops-for-strides -fno-web -faggressive-loop-optimizations
-fno-align-functions -fno-align-jumps -falign-labels -fno-align-loops
-fno-allocation-dce -fasynchronous-unwind-tables -fauto-inc-dec -fbit-tests
-fno-branch-count-reg -fno-caller-saves -fno-code-hoisting
-fcombine-stack-adjustments -fcompare-elim -fno-cprop-registers -fcrossjumping
-fcse-follow-jumps -fdce -fno-defer-pop -fno-delete-null-pointer-checks
-fdevirtualize -fdevirtualize-speculatively -fdse -fno-early-inlining
-fno-expensive-optimizations -fno-forward-propagate -ffp-int-builtin-inexact
-ffunction-cse -fno-gcse -fno-gcse-after-reload -fgcse-lm
-fguess-branch-probability -fno-hoist-adjacent-loads -fif-conversion
-fif-conversion2 -fno-indirect-inlining -finline -finline-atomics
-finline-functions -finline-functions-called-once -finline-small-functions
-fipa-bit-cp -fno-ipa-cp -fno-ipa-cp-clone -fipa-icf -fipa-icf-functions
-fno-ipa-icf-variables -fipa-modref -fipa-profile -fno-ipa-pure-const
-fno-ipa-ra -fipa-reference -fipa-reference-addressable -fno-ipa-sra
-fno-ipa-stack-alignment -fno-ipa-vrp -fno-ira-hoist-pressure
-fno-ira-share-save-slots -fno-ira-share-spill-slots
-fno-isolate-erroneous-paths-dereference -fivopts -fno-jump-tables
-flifetime-dse -fno-loop-interchange -fno-loop-unroll-and-jam -flra-remat
-fmath-errno -fno-move-loop-invariants -fno-omit-frame-pointer
-fno-optimize-sibling-calls -fno-optimize-strlen -fpartial-inlining
-fpeel-loops -fno-peephole -fpeephole2 -fno-plt -fpredictive-commoning
-fprefetch-loop-arrays -fprintf-return-value -fno-ree -fno-reg-struct-return
-frename-registers -fno-reorder-blocks -freorder-blocks-and-partition
-freorder-functions -frerun-cse-after-loop -fsched-critical-path-heuristic
-fno-sched-dep-count-heuristic -fno-sched-group-heuristic -fno-sched-interblock
-fno-sched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec
-fno-sched-spec-insn-heuristic -fno-sched-stalled-insns-dep -fschedule-fusion
-fschedule-insns2 -fshort-enums -fshrink-wrap -fshrink-wrap-separate
-fsigned-zeros -fno-split-ivs-in-unroller -fsplit-loops -fsplit-paths
-fsplit-wide-types -fno-ssa-backprop -fssa-phiopt -fno-stdarg-opt
-fstore-merging -fstrict-aliasing -fstrict-volatile-bitfields -fthread-jumps
-ftoplevel-reorder -ftrapping-math -ftree-bit-ccp -ftree-builtin-call-dce
-fno-tree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop -ftree-cselim
-ftree-dce -ftree-dominator-opts -fno-tree-dse -ftree-forwprop -ftree-fre
-fno-tree-loop-distribute-patterns -ftree-loop-distribution
-ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize
-fno-tree-loop-vectorize -fno-tree-partial-pre -ftree-phiprop -ftree-pre
-fno-tree-pta -fno-tree-reassoc -fno-tree-scev-cprop -fno-tree-sink
-ftree-slp-vectorize -fno-tree-slsr -fno-tree-sra -fno-tree-switch-conversion
-ftree-tail-merge -fno-tree-ter -fno-tree-vrp -fno-unroll-completely-grow-size
-funswitch-loops -fno-unwind-tables -fno-var-tracking
-fno-var-tracking-assignments -fno-version-loops-for-strides -fno-web
-save-temps t.c -o t.o 2>t_error.txt

# /home/gcc-releases/gcc-11-0615/bin/gcc -I
/home/csmith_record/include/csmith-2.3.0/ t.c -o t2.o

# ./t2.o
checksum = 85C697B
# ./t.o
checksum = E43ACEEF

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
@ 2023-06-16 10:07 ` 19373742 at buaa dot edu.cn
  2023-06-16 10:40 ` [Bug middle-end/110281] " rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-06-16 10:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #1 from CTC <19373742 at buaa dot edu.cn> ---
Created attachment 55342
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55342&action=edit
The compiler output

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
  2023-06-16 10:07 ` [Bug c/110281] " 19373742 at buaa dot edu.cn
@ 2023-06-16 10:40 ` rguenth at gcc dot gnu.org
  2023-06-16 10:42 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-16 10:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.4.1, 11.3.0, 12.2.1,
                   |                            |13.1.1, 14.0
           Keywords|                            |wrong-code
             Target|                            |x86_64-*-*
          Component|c                           |middle-end

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can confirm a different checksum with GCC 10, 11, 12, 13 and trunk -O2 vs.
-O[01]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
  2023-06-16 10:07 ` [Bug c/110281] " 19373742 at buaa dot edu.cn
  2023-06-16 10:40 ` [Bug middle-end/110281] " rguenth at gcc dot gnu.org
@ 2023-06-16 10:42 ` rguenth at gcc dot gnu.org
  2023-06-16 10:43 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-16 10:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
-fno-strict-aliasing avoids the issue.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
                   ` (2 preceding siblings ...)
  2023-06-16 10:42 ` rguenth at gcc dot gnu.org
@ 2023-06-16 10:43 ` rguenth at gcc dot gnu.org
  2023-06-16 11:18 ` 19373742 at buaa dot edu.cn
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-16 10:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
clang produces the same behavior

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
                   ` (3 preceding siblings ...)
  2023-06-16 10:43 ` rguenth at gcc dot gnu.org
@ 2023-06-16 11:18 ` 19373742 at buaa dot edu.cn
  2023-06-16 11:25 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-06-16 11:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #5 from CTC <19373742 at buaa dot edu.cn> ---
Could you please do me a favor to confirm whether this phenomenon indicates a
bug or a normal behavior? Actually, I also found other optimization sequences
with -fstrict-aliasing which output 'checksum = 85C697B'. Thanks very much for
your efforts in advance!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
                   ` (4 preceding siblings ...)
  2023-06-16 11:18 ` 19373742 at buaa dot edu.cn
@ 2023-06-16 11:25 ` jakub at gcc dot gnu.org
  2023-06-16 11:30 ` 19373742 at buaa dot edu.cn
  2023-06-19 10:17 ` 19373742 at buaa dot edu.cn
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-06-16 11:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That requires detailed analysis nobody performed yet.  csmith is known to
generate invalid programs sometimes, especially with some options, and only
such analysis can give definite answers.  Though, two independent compilers
behaving the same and -fno-strict-aliasing option making it go away is a strong
indication it could very well be a bug in the generated testcase.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
                   ` (5 preceding siblings ...)
  2023-06-16 11:25 ` jakub at gcc dot gnu.org
@ 2023-06-16 11:30 ` 19373742 at buaa dot edu.cn
  2023-06-19 10:17 ` 19373742 at buaa dot edu.cn
  7 siblings, 0 replies; 9+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-06-16 11:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #7 from CTC <19373742 at buaa dot edu.cn> ---
(In reply to Jakub Jelinek from comment #6)
> That requires detailed analysis nobody performed yet.  csmith is known to
> generate invalid programs sometimes, especially with some options, and only
> such analysis can give definite answers.  Though, two independent compilers
> behaving the same and -fno-strict-aliasing option making it go away is a
> strong indication it could very well be a bug in the generated testcase.

Thanks very much for your explanation!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/110281] wrong code with '-O3'
  2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
                   ` (6 preceding siblings ...)
  2023-06-16 11:30 ` 19373742 at buaa dot edu.cn
@ 2023-06-19 10:17 ` 19373742 at buaa dot edu.cn
  7 siblings, 0 replies; 9+ messages in thread
From: 19373742 at buaa dot edu.cn @ 2023-06-19 10:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110281

--- Comment #8 from CTC <19373742 at buaa dot edu.cn> ---
The issue can be reproduced with -O3 -fno-tree-dominator-opts -fno-tree-pre.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-19 10:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 10:06 [Bug c/110281] New: wrong code with '-O3' 19373742 at buaa dot edu.cn
2023-06-16 10:07 ` [Bug c/110281] " 19373742 at buaa dot edu.cn
2023-06-16 10:40 ` [Bug middle-end/110281] " rguenth at gcc dot gnu.org
2023-06-16 10:42 ` rguenth at gcc dot gnu.org
2023-06-16 10:43 ` rguenth at gcc dot gnu.org
2023-06-16 11:18 ` 19373742 at buaa dot edu.cn
2023-06-16 11:25 ` jakub at gcc dot gnu.org
2023-06-16 11:30 ` 19373742 at buaa dot edu.cn
2023-06-19 10:17 ` 19373742 at buaa dot edu.cn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).