{
(*parm_map)[i].parm_index
= ipa_get_jf_pass_through_formal_id (jf);
- (*parm_map)[i].parm_offset_known
- = ipa_get_jf_pass_through_operation (jf) == NOP_EXPR;
- (*parm_map)[i].parm_offset = 0;
+ if (ipa_get_jf_pass_through_operation (jf) == NOP_EXPR)
+ {
+ (*parm_map)[i].parm_offset_known = true;
+ (*parm_map)[i].parm_offset = 0;
+ }
+ else if (ipa_get_jf_pass_through_operation (jf)
+ == POINTER_PLUS_EXPR
+ && ptrdiff_tree_p (ipa_get_jf_pass_through_operand (jf),
+ &(*parm_map)[i].parm_offset))
+ (*parm_map)[i].parm_offset_known = true;
+ else
+ (*parm_map)[i].parm_offset_known = false;
continue;
}
if (jf && jf->type == IPA_JF_ANCESTOR)
--- /dev/null
+/* { dg-options "-O2 -fdump-ipa-modref" } */
+/* { dg-do compile } */
+__attribute__((noinline))
+void a(char *ptr, char *ptr2)
+{
+ (*ptr)++;
+ (*ptr2)++;
+}
+
+__attribute__((noinline))
+b(char *ptr)
+{
+ a(ptr+1,&ptr[2]);
+}
+main()
+{
+ char c[2]={0,1,0};
+ b(c);
+ return c[0]+c[2];
+}
+/* Check that both param offsets are determined correctly. */
+/* { dg-final { scan-ipa-dump "param offset: 1" "modref" } } */
+/* { dg-final { scan-ipa-dump "param offset: 2" "modref" } } */
--- /dev/null
+/* { dg-options "-O2 -fdump-tree-modref1" } */
+/* { dg-do compile } */
+__attribute__((noinline))
+void a(char *ptr, char *ptr2)
+{
+ (*ptr)++;
+ (*ptr2)++;
+}
+
+__attribute__((noinline))
+b(char *ptr)
+{
+ a(ptr+1,&ptr[2]);
+}
+main()
+{
+ char c[2]={0,1,0};
+ b(c);
+ return c[0]+c[2];
+}
+/* Check that both param offsets are determined correctly and the computation
+ is optimized out. */
+/* { dg-final { scan-tree-dump "param offset: 1" "modref1" } } */
+/* { dg-final { scan-tree-dump "param offset: 2" "modref2" } } */
+/* { dg-final { scan-tree-dump "return 0" "modref2" } } */