On 05/20/2016 04:55 AM, Richard Biener wrote:
+/* Promote definition DEF to promoted type. If the stmt that defines def
+ is def_stmt, make the type of def promoted type. If the stmt is such
+ that, result of the def_stmt cannot be of promoted type, create a
new_def
+ of the original_type and make the def_stmt assign its value to newdef.
+ Then, create a NOP_EXPR to convert new_def to def of promoted type.
+
+ For example, for stmt with original_type char and promoted_type int:
+ char _1 = mem;
+ becomes:
+ char _2 = mem;
+ int _1 = (int)_2;
When does this case happen, and how is this any better than PRE or other
elimination/code motion algorithms in improving the generated code?
The above case mentions one - loads from memory. Another case would be
vector element extracts from vNqi vectors or asm outputs.
Duh. I should have looked the code above more closely.
I would hazard a guess that it could happen if you still needed the char
sized used in a small number of cases, but generally wanted to promote most
uses to int?
I think we want to promote all uses to int, we only can't always combine
the extension with the value-producing stmt on GIMPLE (we don't have
single-stmt sign-extending loads for example). Likewise we don't allow
the equivalent of (subreg:QI SI-reg) at SSA use sites and thus will
generally have a trucating stmt before such uses.
Hmmm, this is all reminding me of some terrible hacks we used to have to
change the types on the LHS of memory loads to discourage unnecessary
extensions and encourage use of promoted types. I wouldn't want to go
down that path again.
So what does this mean for this pass? It means that we need to think
about the immediate goal we want to fulfil - which might be to just
promote things that we can fully promote, avoiding the necessity to
prevent passes from undoing our work.
You're probably right. That's probably valuable in and of itself and
the other cases we can tackle later if they prove important.
That said - we need a set of
testcases the pass should enable to being optimized better than without it
Agreed, 100%.
(I myself see the idea of promoting on GIMPLE according to PROMOTE_MODE
as good design cleanup towards pushing GIMPLE farther out).
I think we're in general agreement here as well.
jeff