>>> Sounds like your load / store address selection routine isn't
working like what you expected.
>> Thanks for the reply. Unfortunately, this doesn't seem to be the
problem.
>
> do you handle truncating stores and extending loads?
>
I have instructions matching patterns for zero- and sign-extending loads (8-bit
to 32-bit, 16-bit to 32-bit), and truncating stores (32-bit to 16-bit, 32-bit to
8-bit). And I've also defined patterns to map 'extload*' to
'zextload*'.
A bit more info as to where the problem occurs (in case that helps), the debug
output shows that at the 'Initial selection DAG' phase, the loads,
stores, and select are all as I want them to be. However, the very next dump
'Optimized lowered selection DAG' shows the select having been altered
to operate on the addresses instead of the values. I've listed these two
dumps below.
Regards,
- Mark
=== foo
Initial selection DAG:
SelectionDAG has 35 nodes:
0x1403e98: ch = EntryToken
0x1810e90: i32 = undef
0x1403e98: <multiple use>
0x1810e08: i32 = FrameIndex <-1>
0x1810e90: <multiple use>
0x1810f18: i32,ch = load 0x1403e98, 0x1810e08, 0x1810e90 <null:0>
alignment=4
0x1403e98: <multiple use>
0x1810fa0: i32 = FrameIndex <-2>
0x1810e90: <multiple use>
0x1811028: i32,ch = load 0x1403e98, 0x1810fa0, 0x1810e90 <null:0>
alignment=4
0x1403e98: <multiple use>
0x18110b0: i32 = FrameIndex <-3>
0x1810e90: <multiple use>
0x1811138: i32,ch = load 0x1403e98, 0x18110b0, 0x1810e90 <null:0>
alignment=4
0x18114f0: i32 = FrameIndex <1>
0x1811688: i32 = FrameIndex <2>
0x1811798: i32 = FrameIndex <3>
0x1403e98: <multiple use>
0x1810f18: <multiple use>
0x18114f0: <multiple use>
0x1810e90: <multiple use>
0x1811600: ch = store 0x1403e98, 0x1810f18, 0x18114f0, 0x1810e90
<0x14021fc:0> alignment=4
0x1811028: <multiple use>
0x1811688: <multiple use>
0x1810e90: <multiple use>
0x1811710: ch = store 0x1811600, 0x1811028, 0x1811688, 0x1810e90
<0x140226c:0> alignment=4
0x1811138: <multiple use>
0x1811798: <multiple use>
0x1810e90: <multiple use>
0x1811820: ch = store 0x1811710, 0x1811138, 0x1811798, 0x1810e90
<0x14022ac:0> alignment=4
0x1811820: <multiple use>
0x18114f0: <multiple use>
0x1810e90: <multiple use>
0x18118a8: i32,ch = load 0x1811820, 0x18114f0, 0x1810e90 <0x14021fc:0>
alignment=4
0x1811820: <multiple use>
0x1811688: <multiple use>
0x1810e90: <multiple use>
0x1811a40: i32,ch = load 0x1811820, 0x1811688, 0x1810e90 <0x140226c:0>
alignment=4
0x1811820: <multiple use>
0x1811798: <multiple use>
0x1810e90: <multiple use>
0x1811ac8: i32,ch = load 0x1811820, 0x1811798, 0x1810e90 <0x14022ac:0>
alignment=4
0x1811bd8: i32 = FrameIndex <0>
0x18118a8: <multiple use>
0x1811a40: <multiple use>
0x1811ac8: <multiple use>
0x1811c60: ch = TokenFactor 0x18118a8:1, 0x1811a40:1, 0x1811ac8:1
0x18118a8: <multiple use>
0x1811578: i32 = Constant <0>
0x1811930: ch = setne
0x18119b8: i1 = setcc 0x18118a8, 0x1811578, 0x1811930
0x1811a40: <multiple use>
0x1811ac8: <multiple use>
0x1811b50: i32 = select 0x18119b8, 0x1811a40, 0x1811ac8
0x1811bd8: <multiple use>
0x1810e90: <multiple use>
0x1811ce8: ch = store 0x1811c60, 0x1811b50, 0x1811bd8, 0x1810e90
<0x14020fc:0> alignment=4
0x1403e98: <multiple use>
0x18111c0: i32 = Register #1024
0x1810f18: <multiple use>
0x1811248: ch = CopyToReg 0x1403e98, 0x18111c0, 0x1810f18
0x1403e98: <multiple use>
0x18112d0: i32 = Register #1025
0x1811028: <multiple use>
0x1811358: ch = CopyToReg 0x1403e98, 0x18112d0, 0x1811028
0x1403e98: <multiple use>
0x18113e0: i32 = Register #1026
0x1811138: <multiple use>
0x1811468: ch = CopyToReg 0x1403e98, 0x18113e0, 0x1811138
0x1811ce8: <multiple use>
0x1822808: ch = TokenFactor 0x1811248, 0x1811358, 0x1811468, 0x1811ce8
0x1822890: i32 = Register r3
0x1811ce8: <multiple use>
0x1811bd8: <multiple use>
0x1810e90: <multiple use>
0x1811d70: i32,ch = load 0x1811ce8, 0x1811bd8, 0x1810e90 <0x14020fc:0>
alignment=4
0x1822918: ch,flag = CopyToReg 0x1822808, 0x1822890, 0x1811d70
0x1822918: <multiple use>
0x1822918: <multiple use>
0x18229a0: ch = MYISD::RET_FLAG 0x1822918, 0x1822918:1
Replacing.1 0x1811d70: i32,ch = load 0x1811ce8, 0x1811bd8, 0x1810e90
<0x14020fc:0> alignment=4
With: 0x1811b50: i32 = select 0x18119b8, 0x1811a40, 0x1811ac8 and 1 other values
Replacing.1 0x1811b50: i32 = select 0x18119b8, 0x1811a40, 0x1811ac8
With: 0x1822a28: i32,ch = load 0x1811820, 0x1811d70, 0x1810e90
<0x140226c:0> alignment=4 and 0 other values
Replacing.1 0x1811a40: i32,ch = load 0x1811820, 0x1811688, 0x1810e90
<0x140226c:0> alignment=4
With: 0x1822a28: i32,ch = load 0x1811820, 0x1811d70, 0x1810e90
<0x140226c:0> alignment=4 and 1 other values
Replacing.1 0x1811ac8: i32,ch = load 0x1811820, 0x1811798, 0x1810e90
<0x14022ac:0> alignment=4
With: 0x1822a28: i32,ch = load 0x1811820, 0x1811d70, 0x1810e90
<0x140226c:0> alignment=4 and 1 other values
Replacing.1 0x1811c60: ch = TokenFactor 0x18118a8:1, 0x1822a28:1, 0x1822a28:1
With: 0x1811ac8: ch = TokenFactor 0x18118a8:1, 0x1822a28:1 and 0 other values
Optimized lowered selection DAG:
SelectionDAG has 33 nodes:
0x1403e98: ch = EntryToken
0x1810e90: i32 = undef
0x1403e98: <multiple use>
0x1810e08: i32 = FrameIndex <-1>
0x1810e90: <multiple use>
0x1810f18: i32,ch = load 0x1403e98, 0x1810e08, 0x1810e90 <null:0>
alignment=4
0x1403e98: <multiple use>
0x1810fa0: i32 = FrameIndex <-2>
0x1810e90: <multiple use>
0x1811028: i32,ch = load 0x1403e98, 0x1810fa0, 0x1810e90 <null:0>
alignment=4
0x1403e98: <multiple use>
0x18110b0: i32 = FrameIndex <-3>
0x1810e90: <multiple use>
0x1811138: i32,ch = load 0x1403e98, 0x18110b0, 0x1810e90 <null:0>
alignment=4
0x18114f0: i32 = FrameIndex <1>
0x1811688: i32 = FrameIndex <2>
0x1811798: i32 = FrameIndex <3>
0x1403e98: <multiple use>
0x1810f18: <multiple use>
0x18114f0: <multiple use>
0x1810e90: <multiple use>
0x1811600: ch = store 0x1403e98, 0x1810f18, 0x18114f0, 0x1810e90
<0x14021fc:0> alignment=4
0x1811028: <multiple use>
0x1811688: <multiple use>
0x1810e90: <multiple use>
0x1811710: ch = store 0x1811600, 0x1811028, 0x1811688, 0x1810e90
<0x140226c:0> alignment=4
0x1811138: <multiple use>
0x1811798: <multiple use>
0x1810e90: <multiple use>
0x1811820: ch = store 0x1811710, 0x1811138, 0x1811798, 0x1810e90
<0x14022ac:0> alignment=4
0x1811820: <multiple use>
0x18114f0: <multiple use>
0x1810e90: <multiple use>
0x18118a8: i32,ch = load 0x1811820, 0x18114f0, 0x1810e90 <0x14021fc:0>
alignment=4
0x1403e98: <multiple use>
0x18111c0: i32 = Register #1024
0x1810f18: <multiple use>
0x1811248: ch = CopyToReg 0x1403e98, 0x18111c0, 0x1810f18
0x1403e98: <multiple use>
0x18112d0: i32 = Register #1025
0x1811028: <multiple use>
0x1811358: ch = CopyToReg 0x1403e98, 0x18112d0, 0x1811028
0x1403e98: <multiple use>
0x18113e0: i32 = Register #1026
0x1811138: <multiple use>
0x1811468: ch = CopyToReg 0x1403e98, 0x18113e0, 0x1811138
0x18118a8: <multiple use>
0x1822a28: <multiple use>
0x1811ac8: ch = TokenFactor 0x18118a8:1, 0x1822a28:1
0x1822a28: <multiple use>
0x1811bd8: i32 = FrameIndex <0>
0x1810e90: <multiple use>
0x1811ce8: ch = store 0x1811ac8, 0x1822a28, 0x1811bd8, 0x1810e90
<0x14020fc:0> alignment=4
0x1822808: ch = TokenFactor 0x1811248, 0x1811358, 0x1811468, 0x1811ce8
0x1822890: i32 = Register r3
0x1822a28: <multiple use>
0x1822918: ch,flag = CopyToReg 0x1822808, 0x1822890, 0x1822a28
0x1811820: <multiple use>
0x18118a8: <multiple use>
0x1811578: i32 = Constant <0>
0x1811930: ch = setne
0x18119b8: i1 = setcc 0x18118a8, 0x1811578, 0x1811930
0x1811688: <multiple use>
0x1811798: <multiple use>
0x1811d70: i32 = select 0x18119b8, 0x1811688, 0x1811798
0x1810e90: <multiple use>
0x1822a28: i32,ch = load 0x1811820, 0x1811d70, 0x1810e90 <0x140226c:0>
alignment=4
0x1822918: <multiple use>
0x1822918: <multiple use>
0x18229a0: ch = MYISD::RET_FLAG 0x1822918, 0x1822918:1
Also, just after that, the dump includes:
Legally typed node: 0x1811798: i32 = FrameIndex <3>
Legally typed node: 0x1811688: i32 = FrameIndex <2>
I'm not sure how to indicate that these aren't legally typed. Or at
least, aren't legally typed when storing that i32 into a register.