From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97205 invoked by alias); 30 Oct 2015 17:41:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 97126 invoked by uid 48); 30 Oct 2015 17:41:07 -0000 From: "alalaw01 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/68165] New: Not constant-folding setting vector element Date: Fri, 30 Oct 2015 17:41:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: alalaw01 at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg02587.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68165 Bug ID: 68165 Summary: Not constant-folding setting vector element Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: alalaw01 at gcc dot gnu.org Target Milestone: --- I believe these two C functions are equivalent: typedef float __attribute__((__vector_size__ (2 * sizeof(float)))) float32x2_t; float32x2_t test_cprop () { float32x2_t vec = {0.0, 0.0}; vec[0] = 3.14f; vec[1] = 2.71f; return vec * ((float32x2_t) { 1.5f, 4.5f }); } float32x2_t test_cprop2 () { float32x2_t vec = {3.14f, 2.71f}; return vec * ((float32x2_t) { 1.5f, 4.5f }); } at -O3 -fdump-tree-optimized, on AArch64: ===== ;; Function test_cprop (test_cprop, funcdef_no=0, decl_uid=2603, cgraph_uid=0, symbol_order=0) test_cprop () { float32x2_t vec; vector(2) float vec.0_5; float32x2_t _6; : vec = { 0.0, 0.0 }; BIT_FIELD_REF = 3.1400001049041748046875e+0; BIT_FIELD_REF = 2.71000003814697265625e+0; vec.0_5 = vec; _6 = vec.0_5 * { 1.5e+0, 4.5e+0 }; vec ={v} {CLOBBER}; return _6; } ;; Function test_cprop2 (test_cprop2, funcdef_no=1, decl_uid=2607, cgraph_uid=1, symbol_order=1) test_cprop2 () { : return { 4.71000003814697265625e+0, 1.219499969482421875e+1 }; } ===== x86 is identical for test_cprop2, worse in test_cprop: ===== test_cprop () { float32x2_t vec; vector(2) float vec.0_5; float32x2_t _6; float _8; float _9; float _10; float _11; : vec = { 0.0, 0.0 }; BIT_FIELD_REF = 3.1400001049041748046875e+0; BIT_FIELD_REF = 2.71000003814697265625e+0; vec.0_5 = vec; _8 = BIT_FIELD_REF ; _9 = _8 * 1.5e+0; _10 = BIT_FIELD_REF ; _11 = _10 * 4.5e+0; _6 = {_9, _11}; vec ={v} {CLOBBER}; return _6; } ===== i.e. we are not understanding the result of assigning to the BIT_FIELD_REF on the whole vector, although we can resolve individual elements: float32x2_t test_cprop3 () { float32x2_t vec = {0.0, 0.0}; vec[0] = 3.14f; vec[1] = 2.71f; return (float32x2_t) {vec[0], vec[1]} * ((float32x2_t) { 1.5f, 4.5f }); } produces ===== test_cprop3 () { : return { 4.71000003814697265625e+0, 1.219499969482421875e+1 }; }