[PATCH 1/2] Fix PR 100925: Limit some a?CST1:CST2 optimizations to intergal types only

2021-06-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is with offset (and pointer) types is we produce a negative expression when this optimization hits. It is easier to disable this optimization for all non-integeral types instead of finding an integer type which is the same precission as the type to do the nega

[PATCH 2/2] Disallow pointer and offset types on some gimple

2021-06-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski While debugging PR 100925, I found that the gimple verifiers don't reject NEGATE on pointer or offset type. This patch adds the check on some unary and binary gimple which should not have operated on pointer/offset types. OK? Bootstrapped and tested on x86_64-linux-gnu with n

[PATCH] Add statistics counting to PHI-OPT

2021-06-10 Thread apinski--- via Gcc-patches
From: Andrew Pinski This should have been done before I started to work on connecting PHI-OPT to match-and-simplify to see quickly if we miss anything but it is better late than never. Anyways there was no statistics counting in PHI-OPT before so adding it is the right thing to do. OK? Bootstrap

[committed] Fix bb-slp-pr97709.c after computed goto change

2021-10-01 Thread apinski--- via Gcc-patches
From: Andrew Pinski Looks like I tested the change for bb-slp-pr97709.c on an older tree which did not have the error message so I had missed one more place where the change was needed. Anyways committed after testing to make sure the testcase passes now. gcc/testsuite/ChangeLog: * gcc

[PATCH] tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"

2021-10-09 Thread apinski--- via Gcc-patches
From: Andrew Pinski So it turns out this is kinda of a latent bug but not really latent. In GCC 9 and 10, phi-opt would transform a?-1:0 (even for signed 1-bit integer) to -(type)a but the type is an one bit integer which means the negation is undefined. GCC 11 fixed the problem by checking for a

[PATCH] [GCC 10 branch] tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"

2021-10-10 Thread apinski--- via Gcc-patches
From: Andrew Pinski So here is the GCC 10 branch version which fixes the wrong code. The problem is we create a negation of an one bit signed integer type which is undefined if the value was -1. This is not needed for GCC 11 branch since the case is handled differently there and has been fixed th

[PATCH 0/4] Fix PR tree-opt/102703

2021-10-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski This patch series fixes PR tree-opt/102703 by improving the code which will delete write only stores to also delete the phi node (if it was a phi node) that was used to define the write. We need to some factoring out of the code to make it easier to understand and less indenti

[PATCH 1/4] Add dump prints when execute_fixup_cfg removes a write only var store.

2021-10-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski While debugging PR 102703, I found it was hard to figure out where the store was being removed as there was no pass which was outputting why the store was removed. This adds to execute_fixup_cfg the output. Also note most of removals happen when execute_fixup_cfg is called fro

[PATCH 2/4] Remove outdated comment about execute_fixup_cfg

2021-10-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski The comment about execute_fixup_cfg not being able to run as a standalone pass is not true for a long time now. It has been a standalone pass for a while now. gcc/ChangeLog: * tree-cfg.c (execute_fixup_cfg): Remove comment about standalone pass. --- gcc/tre

[PATCH 3/4] Factor out removal of write only stores from execute_fixup_cfg

2021-10-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski To make it easier to fix PR 102703, factoring this code out to its own function makes it easier to read and less indentions too. gcc/ChangeLog: * tree-cfg.c (maybe_remove_writeonly_store): New function factored out from ... (execute_fixup_cfg): Here.

[PATCH 4/4] Improve maybe_remove_writeonly_store to do a simple DCE for defining statement

2021-10-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski Instead of putting a full blow DCE after execute_fixup_cfg, it makes sense to try to remove the defining statement for the store that is being removed. Right now we only handle PHI node statements as there needs no extra checks except for it is only used once in the store stat

[PATCH] Improve maybe_remove_writeonly_store to do a simple DCE for defining statement

2021-10-20 Thread apinski--- via Gcc-patches
From: Andrew Pinski Instead of putting a full blow DCE after execute_fixup_cfg, it makes sense to try to remove the defining statement for the store that is being removed. Using simple_dce_from_worklist makes this easier, just mark the ssa_name on the rhs side of the store (if it was one) in a bi

[PATCH] Fix PR 102908: wrongly removing null pointer loads

2021-10-24 Thread apinski--- via Gcc-patches
From: Andrew Pinski Just like PR 100382, here we have a DCE removing a null pointer load which is needed still. In this case, execute_fixup_cfg removes a store (correctly) and then removes the null load (incorrectly) due to not checking stmt_unremovable_because_of_non_call_eh_p. This patch adds t

[PATCH] target: [PR102941] Fix inline-asm flags with non-REG_P output

2021-10-26 Thread apinski--- via Gcc-patches
From: Andrew Pinski So the problem here is that arm_md_asm_adjust would just create a set directly to the output memory which is wrong. It needs to output to a temp register first and then do a move. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. I have no way to test on a

[PATCH] Fix tree-optimization/102216: missed optimization causing Warray-bounds

2021-10-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is tree-ssa-forwprop.c likes to produce &MEM [(void *)_4 + 152B] which is the same as _4 p+ 152 which the rest of GCC likes better. This implements this transformation back to pointer plus to improve better code generation later on. OK? Bootstrapped and test

[V2/PATCH] Fix tree-optimization/102216: missed optimization causing Warray-bounds

2021-10-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is tree-ssa-forwprop.c likes to produce &MEM [(void *)_4 + 152B] which is the same as _4 p+ 152 which the rest of GCC likes better. This implements this transformation back to pointer plus to improve better code generation later on. OK? Bootstrapped and test

[PATCH 4/5] Try inverted comparison for match_simplify in phiopt

2021-07-04 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match and simplify does not have all of the inverted comparison patterns, it make sense to just have phi-opt try to do the inversion and try match and simplify again. OK? Bootstrapped and tested on x86_64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: * tree

[PATCH 2/5] Fix PR 101237: Remove element_type call when used with the functions from real

2021-07-04 Thread apinski--- via Gcc-patches
From: Andrew Pinski HONOR_SIGNED_ZEROS, HONOR_SIGN_DEPENDENT_ROUNDING, and HONOR_SNANS all have an overload for taking a tree type now, so we should do that instead. OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: PR middle-end/101237 * fold-const.c (negate_exp

[PATCH 1/5] Fix 101256: Wrong code due to range incorrect from PHI-OPT

2021-07-04 Thread apinski--- via Gcc-patches
From: Andrew Pinski So the problem here is that replace_phi_edge_with_variable will copy range information to a already (not newly) defined ssa name. This causes wrong code later on. This patch fixes the problem by requiring there to be statements that are to be placed before the conditional to

[PATCH 3/5] Allow match-and-simplified phiopt to run in early phiopt

2021-07-04 Thread apinski--- via Gcc-patches
From: Andrew Pinski To move a few things more to match-and-simplify from phiopt, we need to allow match_simplify_replacement to run in early phiopt. To do this we add a replacement for gimple_simplify that is explictly for phiopt. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressio

[PATCH 5/5] Port most of the A CMP 0 ? A : -A to match

2021-07-04 Thread apinski--- via Gcc-patches
From: Andrew Pinski To improve phiopt and be able to remove abs_replacement, this ports most of "A CMP 0 ? A : -A" from fold_cond_expr_with_comparison to match.pd. There is a few extra changes that are needed to remove the "A CMP 0 ? A : -A" part from fold_cond_expr_with_comparison: * Need to

[PATCH] Fix 101256: Wrong code due to range incorrect from PHI-OPT

2021-07-05 Thread apinski--- via Gcc-patches
From: Andrew Pinski So the problem here is that replace_phi_edge_with_variable will copy range information to a already (not newly) defined ssa name. This causes wrong code later on. This fixes the problem by require the new ssa name to be defined in the same bb as the conditional that is about

[PATCH 0/2] Misc PHIOPT patches

2021-07-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski Just two misc improvements to simplify and match of phiopt. I decided to submit this two before I finish up the min/max movement to match.pd as that will take some time. Both showed up while looking into the movement of min/max though. Andrew Pinski (2): Improve early simpl

[PATCH 2/2] [PHIOPT/MATCH] Remove the statement to move if not used

2021-07-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski Instead of waiting for DCE to remove the unused statement, and maybe optimize another conditional, it is better if we don't move the statement and have the statement removed. gcc/ChangeLog: * tree-ssa-phiopt.c (used_in_seq): New function. (match_simplify_repl

[PATCH 1/2] Improve early simplify and match for phiopt

2021-07-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski Previously the idea was gimple_simplify_phiopt would call resimplify with a NULL sequence but that sometimes fails even if there was only one statement produced. The cases where it fails is when there are two simplifications happen. In the case of the min/max production, the f

[PATCH] [PHIOPT/MATCH] Remove the statement to move if not used

2021-07-09 Thread apinski--- via Gcc-patches
From: Andrew Pinski Instead of waiting for DCE to remove the unused statement, and maybe optimize another conditional, it is better if we don't move the statement and have the statement removed. OK? Bootstrapped and tested on x86_64-linux-gnu. Changes from v1: * v2: Change the order of insertat

[PATCH] move the (a-b) CMP 0 ? (a-b) : (b-a) optimization from fold_cond_expr_with_comparison to match

2021-07-10 Thread apinski--- via Gcc-patches
From: Andrew Pinski This patch moves the (a-b) CMP 0 ? (a-b) : (b-a) optimization from fold_cond_expr_with_comparison to match. OK? Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * match.pd ((A-B) CMP 0 ? (A-B) : (B - A)): New patterns. gcc/testsuite/ChangeLog:

[PATCH] Fix PR 101453: ICE with optimize and large integer constant

2021-07-15 Thread apinski--- via Gcc-patches
From: Andrew Pinski Every base 10 digit will take use ~3.32 bits to represent. So for a 64bit signed integer, it is 20 characters. The buffer was only 20 so it did not fit; add in the null character and "-O" part, the buffer would be 3 bytes too small. Instead of just increasing the size of the

[PATCH] Fix PR 101453: ICE with optimize and large integer constant

2021-07-16 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem is the buffer is too small to hold "-O" and the interger. This fixes the problem by use the correct size instead. Changes since v1: * v2: Use HOST_BITS_PER_LONG and just divide by 3 instead of 3.32. OK? Bootstrapped and tested on x86_64-linux with no regressions

[PATCH] [AARCH64] Fix PR 101205: csinv does not have an zero_extend version

2021-07-17 Thread apinski--- via Gcc-patches
From: Andrew Pinski So the problem is even though there was a csneg with a zero_extend in the front, there was not one for csinv. This fixes it by extending that pattern. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. gcc/ChangeLog: PR target/101205 * con

[PATCH] [AARCH64] Fix PR 101205: csinv does not have an zero_extend version

2021-07-17 Thread apinski--- via Gcc-patches
From: Andrew Pinski So the problem is even though there was a csneg with a zero_extend in the front, there was not one for csinv. This fixes it by extending that pattern. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. gcc/ChangeLog: PR target/101205 * con

[PATCH] Fix PR 10153: tail recusion for vector types.

2021-07-20 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is we try to an initialized value from a scalar constant. For vectors we need to do a vect_dup instead. This fixes that issue and we get the correct code even and it does not crash. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. gcc/C

[PATCH] Fix PR 10153: tail recusion for vector types.

2021-07-21 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is we try to an initialized value from a scalar constant. For vectors we need to do a vect_dup instead. This fixes that issue by using build_{one,zero}_cst instead of integer_{one,zero}_node when calling create_tailcall_accumulator. Changes from v1: * v2: Us

[PATCH] Fix x86/56337 : 1<<28 alignment is broken

2021-07-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is the x86_64 back-end uses a signed integer for alignment and then divides by BITS_PER_UNIT so if we had INT_MIN (which is what 1<<28*8 is), we would get the wrong result. This fixes the problem by using unsigned for the argument to x86_output_aligned_bss an

[PATCH] Add testcases that got lost when tree-ssa was merged

2021-07-29 Thread apinski--- via Gcc-patches
From: Andrew Pinski So I was looking at some older PRs (PR 16016 in this case), I noticed that some of the testcases were removed when the tree-ssa branch was merged. This adds them back in. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski gcc/testsuit

[PATCH] Fix PR 101683: FP exceptions for float->unsigned

2021-07-30 Thread apinski--- via Gcc-patches
From: Andrew Pinski Just like the old bug PR9651, unsigned_fix rtl should also be handled as a trapping instruction. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR rtl-optimization/101683 * rtlanal.c (may_trap_p_1): Handle UNSIGNED_FIX. -

[PATCH] Don't simplify (A & C) != 0 ? D : 0 for pointer types.

2021-05-16 Thread apinski--- via Gcc-patches
From: Andrew Pinski While rewriting part of PHI-OPT to use match-and-simplify, I ran into a bug where this pattern in match.pd would hit and would produce invalid gimple; a shift of a pointer type. This just disables this simplification for pointer types similarly to what is already done in PHI-

[PATCH] Add a couple of A?CST1:CST2 match and simplify optimizations

2021-05-16 Thread apinski--- via Gcc-patches
From: Andrew Pinski Instead of some of the more manual optimizations inside phi-opt, it would be good idea to do a lot of the heavy lifting inside match and simplify instead. In the process, this moves the three simple A?CST1:CST2 (where CST1 or CST2 is zero) simplifications. OK? Boostrapped and

[PATCH] Use toplevel configure for GMP and MPFR for gdb

2022-11-08 Thread apinski--- via Gcc-patches
From: Andrew Pinski This patch uses the toplevel configure parts for GMP/MPFR for gdb. The only thing is that gdb now requires MPFR for building. Before it was a recommended but not required library. Also this allows building of GMP and MPFR with the toplevel directory just like how it is done fo

[PATCH] Remove SLOW_SHORT_ACCESS from target headers

2022-11-09 Thread apinski--- via Gcc-patches
From: Andrew Pinski SLOW_SHORT_ACCESS is defined in bfin and i386 target headers but the target macro is not used elsewhere. So let's remove it from those two headers and posion it. OK? Built x86_64-linux-gnu and bfin-elf. gcc/ChangeLog: * config/bfin/bfin.h (SLOW_SHORT_ACCESS): Delete

[PATCHv2] Use toplevel configure for GMP and MPFR for gdb

2022-11-10 Thread apinski--- via Gcc-patches
From: Andrew Pinski This patch uses the toplevel configure parts for GMP/MPFR for gdb. The only thing is that gdb now requires MPFR for building. Before it was a recommended but not required library. Also this allows building of GMP and MPFR with the toplevel directory just like how it is done fo

[COMMITTED] Fix some @opindex with - in the front

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski I noticed this during the conversion of the docs to sphinx that some options in the option index had a - in the front of it for the texinfo docs. When the sphinx conversion was reverted, I thought I would fix the texinfo documentation for these options. Committed as obvious a

[COMMITTED] Fix @opindex for m80387

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski I noticed that the opindex for -m80387 option was wrong. It was just 80387 which was not consistent with the rest of the options. This fixes that and uses "@opindex m80387". Committed as obvious after "make html" and checking the option index page. gcc/ChangeLog: *

[PATCH] Fix @opindex for mcall-aixdesc and mcall-openbsd

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski For mcall-aixdesc, the opindex was just m which was wrong. For mcall-openbsd, the opindex was mcall-netbsd which was wrong. This two have been broken since the options were added to the documentation back in r0-92913-g244609a618b094 . Committed as obvious after a "make html"

[PATCH] Remove documentation for MeP

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski MeP support was removed in r7-1614-g0609abdad81e26 but it looks like the documentation for the target was missed. Committed as obvious after doing "make html" to make sure the documentation is fine. Thanks, Andrew Pinski gcc/ChangeLog: * doc/extend.texi: Remove MeP

[PATCH] Remove the picoChip documentation

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski PicoChip support was removed in r5-3431-g157e859ffe3b5d but the documentation was missed it seems. Committed as obvious after running "make html" to make sure the building of the documentation still works. Thanks, Andrew Pinski gcc/ChangeLog: * doc/extend.texi: Rem

[PATCH] Remove Score documentation

2022-11-14 Thread apinski--- via Gcc-patches
From: Andrew Pinski Score target support was removed in r5-3909-g3daa7bbf791203 but it looks like some of the documentation was missed. This removes it. Committed as obvious after a "make html". Thanks, Andrew gcc/ChangeLog: * doc/invoke.texi: Remove Score option section. --- gcc/doc

[COMMITTED] Fix PR 107734: valgrind errors with sbitmap in match.pd

2022-11-17 Thread apinski--- via Gcc-patches
From: Andrew Pinski sbitmap is a simple bitmap and the memory allocated is not cleared on creation; you have to clear it or set it to all ones before using it. This is unlike bitmap which is a sparse bitmap and the entries are cleared as created. The code added in r13-4044-gdc95e1e9702f2f missed

[PATCH 2/2] Fix PR middle-end/107705: ICE after reclaration error

2022-11-17 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is after we created a call expression in the C front-end, we replace the decl type with an error mark node. We then end up calling aggregate_value_p with the call expression with the decl with the error mark as the type and we ICE. The fix is to check the fun

[PATCH 1/2] Fix PRs 106764, 106765, and 107307, all ICE after invalid re-declaration

2022-11-17 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is the gimplifier returns GS_ERROR but in some cases we don't check that soon enough and try to do other work which could crash. So the fix in these two cases is to return GS_ERROR early if the gimplify_* functions had return GS_ERROR. OK? Bootstrapped and te

[PATCH 1/7] Reset the range info on the moved instruction in PHIOPT

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski I had missed this when wrote the patch which allowed the gimple to be moved from inside the conditional as it. It was also missed in the review. Anyways the range information needs to be reset for the moved gimple as it was under a conditional and the flow has changed to be

[PATCH 2/7] Duplicate the range information of the phi onto the new ssa_name

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match_simplify_replacement uses gimple_simplify, there is a new ssa name created sometimes and then we go and replace the phi edge with this new ssa name, the range information on the phi is lost. I don't have a testcase right now where we lose the range information thou

[PATCH 3/7] Try inverted comparison for match_simplify in phiopt

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match and simplify does not have all of the inverted comparison patterns, it make sense to just have phi-opt try to do the inversion and try match and simplify again. OK? Bootstrapped and tested on x86_64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: * tree

[PATCH 4/7] Expand the comparison argument of fold_cond_expr_with_comparison

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski To make things slightly easiler to convert fold_cond_expr_with_comparison over to match.pd, expanding the arg0 argument into 3 different arguments is done. Also this was simple because we don't use arg0 after grabbing the code and the two operands. Also since we do this, we do

[PATCH 6/7] Lower for loops before lowering cond in genmatch

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski While converting some fold_cond_expr_with_comparison to match, I found that I wanted to use "for cnd (cond vec_cond)" but that was not causing the lowering of cond to happen. What was happening was the lowering of the for loop was happening after the lowering of the cond. So s

[PATCH 5/7] Allow match-and-simplified phiopt to run in early phiopt

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski To move a few things more to match-and-simplify from phiopt, we need to allow match_simplify_replacement to run in early phiopt. To do this, we need to mark some match patterns if they can be done in early phiopt or not. OK? Bootstrapped and tested on x86_64-linux-gnu with n

[PATCH 7/7] Port most of the A CMP 0 ? A : -A to match

2021-06-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski To improve phiopt and be able to remove abs_replacement, this ports most of "A CMP 0 ? A : -A" from fold_cond_expr_with_comparison to match.pd. There is a few extra changes that are needed to remove the "A CMP 0 ? A : -A" part from fold_cond_expr_with_comparison: * Need to

[PATCH 0/7] PHI-OPT move abs_replacement to match.pd

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski To able to move PHI-OPT's abs_replacement to match.pd, a bunch of support needed to be added to PHI-OPT. This is a set of 7 patches which allows us to remove abs_replacement and even does one set further and does a few extra transformations that abs_replacement did not do (jus

[PATCH 2/7] Reset the range info on the moved instruction in PHIOPT

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski I had missed this when wrote the patch which allowed the gimple to be moved from inside the conditional as it. It was also missed in the review. Anyways the range information needs to be reset for the moved gimple as it was under a conditional and the flow has changed to be

[PATCH 1/7] Expand the comparison argument of fold_cond_expr_with_comparison

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski To make things slightly easiler to convert fold_cond_expr_with_comparison over to match.pd, expanding the arg0 argument into 3 different arguments is done. Also this was simple because we don't use arg0 after grabbing the code and the two operands. Also since we do this, we do

[PATCH 3/7] Duplicate the range information of the phi onto the new ssa_name

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match_simplify_replacement uses gimple_simplify, there is a new ssa name created sometimes and then we go and replace the phi edge with this new ssa name, the range information on the phi is lost. Placing this in replace_phi_edge_with_variable is the best option instead

[PATCH 5/7] Try inverted comparison for match_simplify in phiopt

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match and simplify does not have all of the inverted comparison patterns, it make sense to just have phi-opt try to do the inversion and try match and simplify again. OK? Bootstrapped and tested on x86_64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: * tree

[PATCH 4/7] Allow match-and-simplified phiopt to run in early phiopt

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski To move a few things more to match-and-simplify from phiopt, we need to allow match_simplify_replacement to run in early phiopt. To do this we add a replacement for gimple_simplify that is explictly for phiopt. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressio

[PATCH 6/7] Lower for loops before lowering cond in genmatch

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski While converting some fold_cond_expr_with_comparison to match, I found that I wanted to use "for cnd (cond vec_cond)" but that was not causing the lowering of cond to happen. What was happening was the lowering of the for loop was happening after the lowering of the cond. So s

[PATCH 7/7] Port most of the A CMP 0 ? A : -A to match

2021-06-23 Thread apinski--- via Gcc-patches
From: Andrew Pinski To improve phiopt and be able to remove abs_replacement, this ports most of "A CMP 0 ? A : -A" from fold_cond_expr_with_comparison to match.pd. There is a few extra changes that are needed to remove the "A CMP 0 ? A : -A" part from fold_cond_expr_with_comparison: * Need to

[COMMITTED] Fix PR 101230: ICE in fold_cond_expr_with_comparison

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski This fixes PR 101230 where I had messed up and forgot that invert_tree_comparison can return ERROR_MARK if the comparsion is not invertable (floating point types). Committed as obvious after a bootstrap/test on x86_64-linux-gnu-gnu gcc/ChangeLog: PR middle-end/10123

[PATCH 0/4] v4 PHI-OPT move abs_replacement to match.pd

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski To able to move PHI-OPT's abs_replacement to match.pd, a bunch of support needed to be added to PHI-OPT. This is a set of 4 (unapproved) patches which allows us to remove abs_replacement and even does one set further and does a few extra transformations that abs_replacement di

[PATCH 1/4] Duplicate the range information of the phi onto the new ssa_name

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match_simplify_replacement uses gimple_simplify, there is a new ssa name created sometimes and then we go and replace the phi edge with this new ssa name, the range information on the phi is lost. Placing this in replace_phi_edge_with_variable is the best option instead

[PATCH 2/4] Allow match-and-simplified phiopt to run in early phiopt

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski To move a few things more to match-and-simplify from phiopt, we need to allow match_simplify_replacement to run in early phiopt. To do this we add a replacement for gimple_simplify that is explictly for phiopt. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressio

[PATCH 3/4] Try inverted comparison for match_simplify in phiopt

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since match and simplify does not have all of the inverted comparison patterns, it make sense to just have phi-opt try to do the inversion and try match and simplify again. OK? Bootstrapped and tested on x86_64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: * tree

[PATCH 4/4] Port most of the A CMP 0 ? A : -A to match

2021-06-27 Thread apinski--- via Gcc-patches
From: Andrew Pinski To improve phiopt and be able to remove abs_replacement, this ports most of "A CMP 0 ? A : -A" from fold_cond_expr_with_comparison to match.pd. There is a few extra changes that are needed to remove the "A CMP 0 ? A : -A" part from fold_cond_expr_with_comparison: * Need to

[PATCH] constexprify some tree variables

2022-11-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski Since we use C++11 by default now, we can use constexpr for some const decls in tree-core.h. This patch does that and it allows for better optimizations of GCC code with checking enabled and without LTO. For an example generic-match.cc compiling is speed up due to the less n

[PATCH] Fix PR 106560: Another ICE after conflicting types of redeclaration

2022-11-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski This another one of these ICE after error issues with the gimplifier and a fallout from r12-3278-g823685221de986af. The problem here is gimplify_modify_expr does not check if either from or to was an error operand. This adds the check and fixes the ICE. OK? Bootstrapped and t

[PATCH] tree-optimization/103356 Add missing (~a) == b folding for _Bool

2022-11-26 Thread apinski--- via Gcc-patches
From: Andrew Pinski The following makes sure to fold (~a) == b to a ^ b for truth values. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski PR 103356 gcc/ChangeLog: * match.pd: ((~a) == b -> a ^ b): New pattern. gcc/testsuite/ChangeL

[COMMITTED] Fix comment for (A / (1 << B)) -> (A >> B).

2022-11-28 Thread apinski--- via Gcc-patches
From: Andrew Pinski There was a small typo where Also was done twice. The second also should have been handled. This fixes that. Committed as obvious after a build. gcc/ChangeLog: * match.pd ((A / (1 << B)) -> (A >> B).): Fix comment. --- gcc/match.pd | 2 +- 1 file changed, 1

[PATCH 1/2] Fix C/107926: Wrong error message when initializing char array

2022-11-30 Thread apinski--- via Gcc-patches
From: Andrew Pinski The problem here is the code which handles {"a"} is supposed to handle the case where the is something after the string but it only handles the case where there is another string so we go down the other path and error out saying "excess elements in struct initializer" even tho

[PATCH 2/2] Improve error message for excess elements in array initializer from {"a"}

2022-11-30 Thread apinski--- via Gcc-patches
From: Andrew Pinski So char arrays are not the only type that be initialized from {"a"}. We can have wchar_t (L"") and char16_t (u"") types too. So let's print out the type of the array instead of just saying char. Note in the testsuite I used regex . to match '[' and ']' as I could not figure o

[PATCH] Improve location for new statements in match-and-simplify phiopt

2021-12-18 Thread apinski--- via Gcc-patches
From: Andrew Pinski Before match-and-simplify was used in phiot, the location of the new stamtents were all of that of the conditional, this adds that back as I did not realize gimple_simplify didn't do that for you. OK? Bootstrapped and tested on x86_64 with no regressions. gcc/ChangeLog:

[PATCH] Change the xfail in gcc.dg/uninit-pr89230-1.c

2021-12-19 Thread apinski--- via Gcc-patches
From: Andrew Pinski With the recent PHI-OPT patch for line numbers, I had missed this testcase was now failing. The uninitialized warning was there before my recent patch, just was on the wrong line. The testcase had added an xfail in r12-4698-gf6d012338 (though a bug report was not filed to reco

[PATCH] Committed: Add testcases for a few PRs

2022-01-01 Thread apinski--- via Gcc-patches
From: Andrew Pinski These were fixed as part of the fix for PR 99766, I thought it would be useful to add a few testcases for the other cases that were failing. Committed as obvious after running the tests to make sure they work. PR rtl-optimization/100241 PR rtl-optimization/99

[PATCH] Revamp documentation for _Complex types extension

2022-01-02 Thread apinski--- via Gcc-patches
From: Andrew Pinski While cleaning up the bug database, I noticed there was a request to improve the documentation of the _Complex type extensions. So I rewrote part of the documentation to make things clearer on __real/__imag and even added documentation about casts between the scalar and the co

[PATCH] [COMMITTED] c++: [PR90782] Add testcase

2022-01-03 Thread apinski--- via Gcc-patches
From: Andrew Pinski This testcase was fixed by r12-1744-g3eecc1 as it make sense it fixed a few other class deduction issues. So I thought I would add a testcase for this PR and close it as fixed. Committed after a quick test of the testcase. PR c++/90782 gcc/testsuite/ChangeLog:

[PATCH] Fix target/103910: missing GTY on x86_mfence causing PCH usage to ICE

2022-01-05 Thread apinski--- via Gcc-patches
From: Andrew Pinski With -O3 -march=opteron, a mfence builtin is added after the loop to say the nontemporal stores are no longer needed. This all good without precompiled headers as the function decl that is referneced by x86_mfence is referenced in another variable but with precompiled headers,

[PATCH] Fix PR 59447: --with-dwarf2 should mention or later.

2022-01-06 Thread apinski--- via Gcc-patches
From: Andrew Pinski Dwarf3/4/5 are really just extensions (well not fully) on top of dwarf2 and the option --with-dwarf2 just changes the default to emit dwarf 2, 3, 4, or 5 by default. On the trunk, dwarf 5 is enabled by this configure option. gcc/ChangeLog: PR bootstrap/59447

[PATCH] [aarch64/64821]: Simplify __builtin_aarch64_sqrt* into internal function .SQRT.

2022-01-10 Thread apinski--- via Gcc-patches
From: Andrew Pinski This is a simple patch which simplifies the __builtin_aarch64_sqrt* builtins into the internal function SQRT which allows for constant folding and other optimizations at the gimple level. It was originally suggested we do to __builtin_sqrt just for __builtin_aarch64_sqrtdf whe

<    1   2