/* Return true if STMT uses a library function and needs to take
address of its inputs. We need to avoid bit-fields in those
- cases. */
+ cases. Similarly, we need to avoid overlap between destination
+ and source limb arrays. */
bool
stmt_needs_operand_addr (gimple *stmt)
else if (!bitmap_bit_p (m_loads, SSA_NAME_VERSION (s)))
continue;
- tree rhs1 = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (s));
+ gimple *g = SSA_NAME_DEF_STMT (s);
+ tree rhs1 = gimple_assign_rhs1 (g);
if (needs_operand_addr
&& TREE_CODE (rhs1) == COMPONENT_REF
&& DECL_BIT_FIELD_TYPE (TREE_OPERAND (rhs1, 1)))
ao_ref ref;
ao_ref_init (&ref, rhs1);
- tree lvop = gimple_vuse (SSA_NAME_DEF_STMT (s));
+ tree lvop = gimple_vuse (g);
unsigned limit = 64;
tree vuse = cvop;
if (vop != cvop
&& is_gimple_assign (stmt)
&& gimple_store_p (stmt)
- && !operand_equal_p (lhs,
- gimple_assign_rhs1 (SSA_NAME_DEF_STMT (s)),
- 0))
+ && (needs_operand_addr
+ || !operand_equal_p (lhs, gimple_assign_rhs1 (g), 0)))
vuse = vop;
if (vuse != lvop
&& walk_non_aliased_vuses (&ref, vuse, false, vuse_eq,
--- /dev/null
+/* PR tree-optimization/113421 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 1024
+unsigned _BitInt(1024) a = -5wb;
+
+__attribute__((noipa)) void
+foo (unsigned _BitInt(1024) x)
+{
+ a *= x;
+}
+#else
+int a = 30;
+
+void
+foo (int)
+{
+}
+#endif
+
+int
+main ()
+{
+ foo (-6wb);
+ if (a != 30wb)
+ __builtin_abort ();
+ return 0;
+}