Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000084 [libFirm] optimisations minor always 2011-08-23 18:41 2011-12-24 03:47
Reporter Matze View Status public  
Assigned To Matze
Priority low Resolution fixed  
Status closed   Product Version development
Summary 0000084: unnecessary alignment localopt
Description Typical alignment code works like this:

/* clear lowest 3 bits */
(x + (1<<3)-1) & ~(1<<3)-1

However if x has a value like (x*8), resp. x<<3 then the masking is obviously unnecessary. We should somehow detect this.
(I've seen this when looking at code produced for alloca on sparc where it was obvious that the requested number of bytes is a multiple of 8, but the generated code still contained alignment logic).
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0000123)
Matze (administrator)
2011-10-18 18:28

some notes on how this should be done:

If you do a bit-analysis to analyse set/cleared bit then you should be able to find out that (x + (1<<3)-1) produces no overflows in the aligned x case. In this case the add has the same effect as an or instruction.

Then we can use a (a|b) & ~b => a & ~b to optimize the thing away.
(0000132)
Matze (administrator)
2011-11-04 11:36

The necessary localopt rules are implemented in b7bf9774e5e704382bdf3eb7c09bc5755d4f067e. Note that for using them you need vrp info to be calculated (-fvrp, when and how to enable this by default is another story).

- Issue History
Date Modified Username Field Change
2011-08-23 18:41 Matze New Issue
2011-08-23 18:41 Matze Summary another localopt? => unnecessary alignment localopt
2011-10-18 18:28 Matze Note Added: 0000123
2011-11-04 11:36 Matze Note Added: 0000132
2011-11-04 11:36 Matze Assigned To => Matze
2011-11-04 11:36 Matze Status new => resolved
2011-11-04 11:36 Matze Resolution open => fixed
2011-11-04 11:36 Matze View Status private => public
2011-12-24 03:47 Matze Status resolved => closed


Mantis 1.1.5[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker