This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/28657] New: could not expand __builtin_constant_p correctly
- From: "dtemirbulatov at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Aug 2006 18:34:21 -0000
- Subject: [Bug rtl-optimization/28657] New: could not expand __builtin_constant_p correctly
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
this code example could not be build for arm-elf correctly
static inline __attribute__((always_inline)) __attribute__((always_inline))
void *my_alloc(unsigned int size)
{
if (__builtin_constant_p(size)) {
__I_think_size_is_a_constant();
return func2(size);
}
return func3(size);
}
static inline __attribute__((always_inline)) __attribute__((always_inline)) int
verify(int type, const void * addr, unsigned int size)
{
return 0;
}
typedef struct my_struct {
int num_entries;
void** list;
int list_size;
} my_struct_t;
int main_func(struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg)
{
struct my_struct urun;
int res=0;
urun.list = 0;
switch (cmd) {
case 1:
func1();
break;
case 2:
fill_array_randomly(&urun, sizeof(struct my_struct));
res = (void *)
my_alloc (urun.num_entries);
if (urun.list) {
int size;
if (urun.list_size > 512) return -1;
size = urun.list_size * sizeof(void*);
if (verify(0, (void *)urun.list, size)) return -1;
urun.list = (void**) my_alloc (size);
}
}
return res + urun.list;
}
compiler thinks that size in my_alloc is a constant
this is a regression from
2003-03-30 Richard Henderson <rth@redhat.com>
PR opt/10011, opt/10252:
* toplev.c (rest_of_compilation): Run purge_builtin_constant_p
before post-gcse cse pass.
and it was fixed by
2004-03-12 Roger Sayle <roger@eyesopen.com>
* combine.c (unmentioned_reg_p): New function to check whether an
expression is a "specialization" of another, i.e. that there are
no registers or memory references mentioned in the first that don't
appear in the second.
(unmentioned_reg_p_1): New helper subroutine of unmentioned_reg_p.
(combine_instructions): Also try combining instructions using the
REG_EQUAL note from a preceding log-linked instruction.
--
Summary: could not expand __builtin_constant_p correctly
Product: gcc
Version: 3.4.6
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dtemirbulatov at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28657