Hi,

Could a gatekeeper please review the fix done for bug 787?

The problem is with the simplification of INTRN_CONSTANT_P intrinsic 
(buitin_constant_p operand). The SIMPNODE_SimplifyIntrinsic function replaces 
the INTRN_CONSTANT_P intrinsic with a constant operand 1 when found that all 
operands are constants and with a 0 when they are not constants. When replacing 
the intrinsic function, the current results are deleted.

In the current test case, the current result happen to be the input for 
ASM_STMT (inlined assembly statements). SPRE_rename_var throws assertion for 
zero_version_cr for ASM_STMT operands since their definitions are  deleted.

Since the zeroing of INTRN_CONSTANT_P is done in lower_expr function while 
lowering to CG, I feel it is better to remove the zeroing at 
SIMPNODE_SimplifyIntrinsic function and the change is done that way.

The patch file and a simplified testcase is attached. The assertion can be 
reproduced with the debug build compiler.

Regards,
Shivaram

Index: common/com/wn_simp_code.h
===================================================================
--- common/com/wn_simp_code.h   (revision 3737)
+++ common/com/wn_simp_code.h   (working copy)
@@ -6585,15 +6585,6 @@
    {
       r = SIMPNODE_FoldIntrinsic (opc, intrinsic, n, k);
    }
-#else
-   else if (intrinsic == INTRN_CONSTANT_P) {
-      /* bug 14470: argument not a constant, we are called from wopt
-         constant-folding, assume that no later phase will be able
-         to prove it constant */
-      r = SIMP_INTCONST(MTYPE_U4, 0);
-      SHOW_TREE(opc,k[0],NULL,r);
-      SIMP_DELETE(k[0]);
-   }
 #endif /* WN_SIMP_WORKING_ON_WHIRL */
 #endif /* KEY */
    return (r);
# 1 "tg3.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "tg3.c"
typedef unsigned int __u32;
typedef unsigned char u8;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef __u32 __be32;
static inline __attribute__((__const__)) __u32 __arch_swab32(__u32 val) {
   asm("bswapl %0" : "=r" (val) : "0" (val));
   return val;
};
static inline __attribute__((__const__)) __u32 __fswab32(__u32 val1) {
        return __arch_swab32(val1);
};
main(int data, char *argv[])
{
    __u32 v1= __builtin_constant_p(data+ __fswab32(data)) 
?0:(__fswab32((__builtin_constant_p(data)) ?0:__fswab32(data)));
    printf("%d\n", v1);
}
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to