https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82405
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > > Isolated test-case where we do not reassociate expressions: > > And I don't think you can reassociate here validly unless -ffast-math. Yep, you're right. With -ffast-math we do the reassociation. Clang does that w/ -O2: $ ~/bin/llvm/bin/clang++ -v clang version 6.0.0 (http://llvm.org/git/clang.git 80f50978299e20c5b2e444e9a4fc06bfaf0183cc) (http://llvm.org/git/llvm.git a29bdba93eaec8e2cf820532c02261ef93ba82b5) Target: x86_64-unknown-linux-gnu $ ~/bin/llvm/bin/clang++ -B. pr82405-reduced2.c -std=c++11 -O2 -o /dev/stdout -S ... .LCPI0_0: .quad 4616189618054758400 # double 4 .quad 4614256447914709615 # double 3.1415000000000002 .text .globl _Z23test_switch_native_slowid .p2align 4, 0x90 .type _Z23test_switch_native_slowid,@function _Z23test_switch_native_slowid: # @_Z23test_switch_native_slowid .cfi_startproc # BB#0: # %entry xorl %eax, %eax cmpl $123, %edi sete %al movsd .LCPI0_0(,%rax,8), %xmm1 # xmm1 = mem[0],zero mulsd %xmm0, %xmm1 mulsd %xmm1, %xmm0 retq ... Reported says the same.