From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by sourceware.org (Postfix) with ESMTPS id 2748D385BF84 for ; Sun, 20 Feb 2022 22:40:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2748D385BF84 Received: by mail-vs1-xe2f.google.com with SMTP id i27so15684343vsr.10 for ; Sun, 20 Feb 2022 14:40:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NS9pBZ3gcaDPvtZPM7HQ4bXjwMxO9GEnyvYEltRhLNk=; b=WP7Gqe8+fXt020DgqP2dnYQGc4xECEhZFjyfLoln6o9/IHFnN/HDJORpobp902tntc SSUZPcxnb/9vVvS2u8wBRYi4MYx5B4a0XFFmvn0Q+rx/p9w2GMLi/Uzngfly1FD5OvRH 37bY1HB9T/zXso+b/5ucM1sFBxua96/FyIRYsMGFVms6D9HOKWUTNtPo6CU3khNzMtK5 vLWvm6LL592dK2kbLE2CDu+x/ZK7k/z6lPGkcc09sypyY23w3EaCTvnyT+XWPggB9yYB h23/vgdKUPDsvi8/u5YKQxOvvVg2POMKm3TKCBHkZZOEX6IdfCv0R8a9gTsnoVdImZI0 5rlQ== X-Gm-Message-State: AOAM530OVv+XFS+yJKHtNLZ9Qep6QWSw/vUWn98uRk+Q1Tpeq6S2AKD+ Ro5XQUDwCR+nVxIPgPY/eyT7rI37rr/HRjtYhB9LCySU X-Google-Smtp-Source: ABdhPJwWFMUl6O5Iw3R8Lor1VymZZOMZxHlJ/dj2aJvPULE71tfRyTISJQcMJF1k4fS8xCvA2vtETyh3mWVe3S0wQmU= X-Received: by 2002:a05:6102:3f15:b0:31b:80a1:77d0 with SMTP id k21-20020a0561023f1500b0031b80a177d0mr6125739vsv.79.1645396820715; Sun, 20 Feb 2022 14:40:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Sun, 20 Feb 2022 14:40:09 -0800 Message-ID: Subject: Re: Validation of adding left shift stmt at GIMPLE - [Custom GCC plugin]] To: Shubham Narlawar Cc: GCC Development Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Feb 2022 22:40:22 -0000 On Sun, Feb 20, 2022 at 10:45 AM Shubham Narlawar wrote: > > On Sat, Feb 19, 2022 at 1:15 AM Andrew Pinski wrote: > > > > On Fri, Feb 18, 2022 at 11:04 AM Shubham Narlawar via Gcc > > wrote: > > > > > > Hello, > > > > > > I want to know whether it is correct to add left shift instruction to > > > a constant expression statement like "_3 + 4"? > > > > > > I am trying to add a left shift instruction in between below GIMPLE > > > instructions - > > > > > > : > > > instrn_buffer.0_1 = instrn_buffer; > > > _2 = tree.cnt; > > > _3 = (int) _2; > > > _4 = _3 + 4; > > > _5 = (unsigned int) _4; // I want to add left shift here > > > D.2993 = __builtin_riscv_sfploadi (instrn_buffer.0_1, 0, _5); > > > //this is "stmt" > > > > > > I am using this snippet in custom gcc plugin - > > > > > > tree lshift_tmp = make_temp_ssa_name (integer_type_node, > > > NULL, "slli"); > > > > A couple of things. > > I Noticed you use integer_type_node here. Why not the type of what is > > being replaced? > > That is the main thing I see right now. > > I want to apply left shift to a constant expression with 8 which is an > integer. Since I am not replacing a statement, I am creating new > GIMPLE statement - > > tree shift_amt = build_int_cst (integer_type_node, 8); > > Here, I am not replacing any GIMPLE statement. Is this the correct way > to do this? > > My goal is to left shift constant expression and update its usage as below - > > _19 = (unsigned int) _18; > D.2996 = __builtin_riscv_sfploadi (lexer.5_16, 12, _19); > > into > > _19 = (unsigned int) _18; > temp = _19 << 8 > D.2996 = __builtin_riscv_sfploadi (lexer.5_16, 12, temp); > > I am storing the left shift result to the new ssa variable name "temp" > and updating sfploadi parameters as expected. > > On doing the above, dom_walker_eliminate is prohibiting me to do the > above gimple transformation. Is the above transformation complete and > correct? I think you misunderstood me. I was saying for a left shift gimple, the result type and the first operand type must be compatible (signed and unsigned types are not compatible). In the above case, you have: integer_type_node = unsigned_int << integer_type_name . Does that make sense now? Thanks, Andrew > > > > > Also you shouldn't need to do: > > update_ssa (TODO_update_ssa); > > > > As make_temp_ssa_name is a new SSA name already and such. > > Understood. > > Thanks and Regards, > Shubham > > > > > > Thanks, > > Andrew Pinski > > > > > gimple *lshift = gimple_build_assign (lshift_tmp, LSHIFT_EXPR, parm, > > > build_int_cst > > > (integer_type_node, 8)); > > > gsi_insert_before(&gsi, lshift, GSI_NEW_STMT); > > > //Update function call > > > gimple_call_set_arg (stmt, idx, lshift_tmp); > > > update_stmt (stmt); > > > update_ssa (TODO_update_ssa); > > > > > > from which above GIMPLE IR is modified to - > > > > > > : > > > instrn_buffer.0_1 = instrn_buffer; > > > _2 = tree.cnt; > > > _3 = (int) _2; > > > _4 = _3 + 4; > > > _5 = (unsigned int) _4; > > > slli_24 = _5 << 8; > > > D.2993 = __builtin_riscv_sfploadi (instrn_buffer.0_1, 0, slli_24); > > > > > > > > > 1. When I run above code, either dominator tree validation or tree cfg > > > fixup is failing which suggests to me it is either incorrect to apply > > > such left shift or some more work is missing? > > > > > > 2. I followed how a left shift gimple assignment is generated but > > > still feels there is something wrong with the above generation. Can > > > someone please point me out? > > > > > > Thanks in advance! As always, the GCC community and its members are > > > very supportive, responsive and helpful! > > > > > > Regards, > > > Shubham