The following fixes the bogus IL that does pointer extension from inlining of mismatched function args (testcase with -m32).
The solution as implemented is to not inline by making fold_convertible reject the required conversion. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2018-06-25 Richard Biener <rguent...@suse.de> PR middle-end/86271 * fold-const.c (fold_convertible_p): Pointer extension isn't valid. * gcc.dg/pr86271.c: New testcase. Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 262006) +++ gcc/fold-const.c (working copy) @@ -2358,7 +2358,9 @@ fold_convertible_p (const_tree type, con case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: case POINTER_TYPE: case REFERENCE_TYPE: case OFFSET_TYPE: - return (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig) + return (INTEGRAL_TYPE_P (orig) + || (POINTER_TYPE_P (orig) + && TYPE_PRECISION (type) <= TYPE_PRECISION (orig)) || TREE_CODE (orig) == OFFSET_TYPE); case REAL_TYPE: Index: gcc/testsuite/gcc.dg/pr86271.c =================================================================== --- gcc/testsuite/gcc.dg/pr86271.c (nonexistent) +++ gcc/testsuite/gcc.dg/pr86271.c (working copy) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int main () +{ + int i; + foobar (i, &i); /* { dg-warning "implicit declaration" } */ +} + +int foobar (int a, long long b) +{ + int c; + + c = a % b; + a = a / b; + return a + b; +}