summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-22 08:50:00 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-22 08:50:00 +0000
commit789c209fda231b2b8eb317050530aa975e3d26da (patch)
tree814f4b559dbb98d632f1ed844b3031df1728d560 /gcc
parenteca7bb9bcb5815c4c3a12035122744e97b7384ab (diff)
downloadppe42-gcc-789c209fda231b2b8eb317050530aa975e3d26da.tar.gz
ppe42-gcc-789c209fda231b2b8eb317050530aa975e3d26da.zip
* gcc-interface/utils.c (rest_of_record_type_compilation): Simplify and
robustify pattern machine code for masking operations. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192672 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/utils.c24
2 files changed, 19 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index db9eebcff2a..570dc0fd15b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2012-10-22 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/utils.c (rest_of_record_type_compilation): Simplify and
+ robustify pattern machine code for masking operations.
+
+2012-10-22 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Subprogram_Type>: In
type annotation mode, break circularities introduced by AI05-0151.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index d9121c1931e..624e724f23c 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1731,19 +1731,23 @@ rest_of_record_type_compilation (tree record_type)
tree offset = TREE_OPERAND (curpos, 0);
align = tree_low_cst (TREE_OPERAND (curpos, 1), 1);
- /* An offset which is a bitwise AND with a negative power of 2
- means an alignment corresponding to this power of 2. Note
- that, as sizetype is sign-extended but nonetheless unsigned,
- we don't directly use tree_int_cst_sgn. */
+ /* An offset which is a bitwise AND with a mask increases the
+ alignment according to the number of trailing zeros. */
offset = remove_conversions (offset, true);
if (TREE_CODE (offset) == BIT_AND_EXPR
- && host_integerp (TREE_OPERAND (offset, 1), 0)
- && TREE_INT_CST_HIGH (TREE_OPERAND (offset, 1)) < 0)
+ && TREE_CODE (TREE_OPERAND (offset, 1)) == INTEGER_CST)
{
- unsigned int pow
- = - tree_low_cst (TREE_OPERAND (offset, 1), 0);
- if (exact_log2 (pow) > 0)
- align *= pow;
+ unsigned HOST_WIDE_INT mask
+ = TREE_INT_CST_LOW (TREE_OPERAND (offset, 1));
+ unsigned int i;
+
+ for (i = 0; i < HOST_BITS_PER_WIDE_INT; i++)
+ {
+ if (mask & 1)
+ break;
+ mask >>= 1;
+ align *= 2;
+ }
}
pos = compute_related_constant (curpos,
OpenPOWER on IntegriCloud