]> git.ipfire.org Git - thirdparty/gcc.git/commit
gimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Oct 2025 16:06:39 +0000 (18:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Oct 2025 16:06:39 +0000 (18:06 +0200)
commit579de8f5295b05573d05f6e4102f1428f35c9f17
tree599c2d3afafda260262dc53137c74af6621776b9
parent0558c6028e47eb623365c3865577f40f9d1fa27c
gimplify: Fix up side-effect handling in 2nd __builtin_c[lt]zg argument [PR122188]

The patch from yesterday made me think about side-effects in the second
argument of __builtin_c[lt]zg.  When we change
__builtin_c[lt]zg (x, y)
when y is not INTEGER_CST into
x ? __builtin_c[lt]zg (x) : y
with evaluating x only once, we omit the side-effects in y unless x is not
0.  That looks undesirable, we should evaluate side-effects in y
unconditionally.

2025-10-09  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Also gimplify the second operand
before the COND_EXPR and use in COND_EXPR result of gimplification.

* gcc.dg/torture/pr122188.c: New test.
gcc/c-family/c-gimplify.cc
gcc/testsuite/gcc.dg/torture/pr122188.c [new file with mode: 0644]