[LLVMbugs] [Bug 3274] New: i1 promotion is not simplified by LegalizeDAG

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 31 12:34:41 PST 2008


http://llvm.org/bugs/show_bug.cgi?id=3274

           Summary: i1 promotion is not simplified by LegalizeDAG
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: scooter.phd at gmail.com
                CC: llvmbugs at cs.uiuc.edu


In this testcase, type legalization promotes a brcond's i1 to i8, which is the
correct thing to do in the CellSPU backend. However, the brcond's setcc is i32,
which subsequently (needlessly) truncated to i8. Legalization does all kinds of
gymnastics to promote the i8 to i16 because the only legal branches in the
CellSPU backend are i16 and i32.

It would seem that the i16->i32 promotion from legalization could be deftly
eliminated or DAG-combined to just the i32 setcc. Alternatively, type
legalization may be too pessimistic by promoting i1 to i8 when it is handed an
i32 setcc that it subsequently truncates to i8.

To recreate:
$ llvm-as testcase1.ll
$ llc -march=cellspu -f -debug testcase1.bc

Output from llc -debug:
CGP: Found      local addrmode: [4 + Base:%in]
CGP: Found      local addrmode: [Base:%in]
CGP: Found      local addrmode: [4 + Base:%in]
CGP: Found      local addrmode: [Base:%in]



=== __floatunsidf
Initial selection DAG:
SelectionDAG has 16 nodes:
  0xd9060c0: ch = EntryToken
      0xd9060c0: <multiple use>
      0xe0079a4: i32 = Register  #1024
    0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
    0xd9060c0: <multiple use>
  0xe007ab4: i32,ch = merge_values 0xe007a2c, 0xd9060c0
  0xe007b3c: i32 = Constant <0>
      0xe007ab4: <multiple use>
      0xe007b3c: <multiple use>
        0xe00780c: i32 = FrameIndex <0>
        0xe007894: i32 = Constant <4>
      0xe00791c: i32 = add 0xe00780c, 0xe007894
      0xe007bc4: i32 = undef
    0xe007c4c: ch = store 0xe007ab4:1, 0xe007b3c, 0xe00791c, 0xe007bc4
<0xd9038c4:0> alignment=4
        0xe007ab4: <multiple use>
        0xe007b3c: <multiple use>
        0xe007cd4: ch = seteq
      0xe007d5c: i1 = setcc 0xe007ab4, 0xe007b3c, 0xe007cd4
      0xe007de4: i1 = Constant <-1>
    0xe007e6c: i1 = xor 0xe007d5c, 0xe007de4
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe007f7c: ch = brcond 0xe007c4c, 0xe007e6c, 0xe007ef4


Replacing.3 0xe007e6c: i1 = xor 0xe007d5c, 0xe007de4
With: 0xe00808c: i1 = setcc 0xe007ab4, 0xe007b3c, 0xe008004
Optimized lowered selection DAG:
SelectionDAG has 13 nodes:
  0xd9060c0: ch = EntryToken
  0xe007b3c: i32 = Constant <0>
      0xd9060c0: <multiple use>
      0xe007b3c: <multiple use>
        0xe00780c: i32 = FrameIndex <0>
        0xe007894: i32 = Constant <4>
      0xe00791c: i32 = add 0xe00780c, 0xe007894
      0xe007bc4: i32 = undef
    0xe007c4c: ch = store 0xd9060c0, 0xe007b3c, 0xe00791c, 0xe007bc4
<0xd9038c4:0> alignment=4
        0xd9060c0: <multiple use>
        0xe0079a4: i32 = Register  #1024
      0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
      0xe007b3c: <multiple use>
      0xe008004: ch = setne
    0xe00808c: i1 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe007f7c: ch = brcond 0xe007c4c, 0xe00808c, 0xe007ef4

Legally typed node: 0xe008004: ch = setne
Legally typed node: 0xe007ef4: ch = BasicBlock <bb1 0xe013998>
Legally typed node: 0xe007bc4: i32 = undef
Legally typed node: 0xe007b3c: i32 = Constant <0>
Legally typed node: 0xe007894: i32 = Constant <4>
Legally typed node: 0xe00780c: i32 = FrameIndex <0>
Legally typed node: 0xe00791c: i32 = add 0xe00780c, 0xe007894
Legally typed node: 0xe0079a4: i32 = Register  #1024
Legally typed node: 0xd9060c0: ch = EntryToken
Legally typed node: 0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
Promote integer result: 0xe00808c: i1 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
Legally typed node: 0xe007ab4: i32 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
Legally typed node: 0xe007cd4: i8 = truncate 0xe007ab4
Legally typed node: 0xe007c4c: ch = store 0xd9060c0, 0xe007b3c, 0xe00791c,
0xe007bc4 <0xd9038c4:0> alignment=4
Promote integer operand: 0xe007f7c: ch = brcond 0xe007c4c, 0xe00808c, 0xe007ef4
Legally typed node: 0xe007d5c: ch = ValueType :i1
Legally typed node: 0xe007de4: i8 = sign_extend_inreg 0xe007cd4, 0xe007d5c
Legally typed node: 0xe007f7c: ch = brcond 0xe007c4c, 0xe007de4, 0xe007ef4
Legally typed node: 0xbfffef2c: ch = handlenode 0xe007f7c
Type-legalized selection DAG:
SelectionDAG has 16 nodes:
  0xd9060c0: ch = EntryToken
  0xe007b3c: i32 = Constant <0>
      0xd9060c0: <multiple use>
      0xe007b3c: <multiple use>
        0xe00780c: i32 = FrameIndex <0>
        0xe007894: i32 = Constant <4>
      0xe00791c: i32 = add 0xe00780c, 0xe007894
      0xe007bc4: i32 = undef
    0xe007c4c: ch = store 0xd9060c0, 0xe007b3c, 0xe00791c, 0xe007bc4
<0xd9038c4:0> alignment=4
            0xd9060c0: <multiple use>
            0xe0079a4: i32 = Register  #1024
          0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
          0xe007b3c: <multiple use>
          0xe008004: ch = setne
        0xe007ab4: i32 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
      0xe007cd4: i8 = truncate 0xe007ab4
      0xe007d5c: ch = ValueType :i1
    0xe007de4: i8 = sign_extend_inreg 0xe007cd4, 0xe007d5c
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe007f7c: ch = brcond 0xe007c4c, 0xe007de4, 0xe007ef4

Optimized type-legalized selection DAG:
SelectionDAG has 16 nodes:
  0xd9060c0: ch = EntryToken
  0xe007b3c: i32 = Constant <0>
      0xd9060c0: <multiple use>
      0xe007b3c: <multiple use>
        0xe00780c: i32 = FrameIndex <0>
        0xe007894: i32 = Constant <4>
      0xe00791c: i32 = add 0xe00780c, 0xe007894
      0xe007bc4: i32 = undef
    0xe007c4c: ch = store 0xd9060c0, 0xe007b3c, 0xe00791c, 0xe007bc4
<0xd9038c4:0> alignment=4
            0xd9060c0: <multiple use>
            0xe0079a4: i32 = Register  #1024
          0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
          0xe007b3c: <multiple use>
          0xe008004: ch = setne
        0xe007ab4: i32 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
      0xe007cd4: i8 = truncate 0xe007ab4
      0xe007d5c: ch = ValueType :i1
    0xe007de4: i8 = sign_extend_inreg 0xe007cd4, 0xe007d5c
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe007f7c: ch = brcond 0xe007c4c, 0xe007de4, 0xe007ef4

CellSPU LowerSTORE: basePtr = 0xe00819c: i32,ch = CopyFromReg 0xe008114,
0xe007e6c
Legalized selection DAG:
SelectionDAG has 29 nodes:
  0xd9060c0: ch = EntryToken
  0xe007b3c: i32 = Constant <0>
  0xe007bc4: i32 = undef
  0xe007e6c: i32 = Register  #1025
    0xd9060c0: <multiple use>
    0xe007e6c: <multiple use>
      0xe00780c: i32 = FrameIndex <0>
      0xe007894: i32 = Constant <4>
    0xe00808c: i32 = SPUISD::IndirectAddr 0xe00780c, 0xe007894
  0xe008114: ch,flag = CopyToReg 0xd9060c0, 0xe007e6c, 0xe00808c
    0xe008114: <multiple use>
    0xe007e6c: <multiple use>
  0xe00819c: i32,ch = CopyFromReg 0xe008114, 0xe007e6c
    0xe008114: <multiple use>
    0xe00819c: <multiple use>
    0xe007bc4: <multiple use>
  0xe008224: v16i8,ch = load 0xe008114, 0xe00819c, 0xe007bc4 <0xd9038c4:0>
alignment=16
  0xe008554: i32 = Constant <7>
      0xe008224: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
        0xe0084cc: v4i32 = BUILD_VECTOR 0xe007b3c, 0xe007b3c, 0xe007b3c,
0xe007b3c
        0xe008224: <multiple use>
          0xe00819c: <multiple use>
        0xe0082ac: v4i32 = SPUISD::SHUFFLE_MASK 0xe00819c
      0xe0083bc: v4i32 = SPUISD::SHUFB 0xe0084cc, 0xe008224, 0xe0082ac
      0xe00819c: <multiple use>
      0xe007bc4: <multiple use>
    0xe008444: ch = store 0xe008224:1, 0xe0083bc, 0xe00819c, 0xe007bc4
<0xd9038c4:0> alignment=16
                        0xd9060c0: <multiple use>
                        0xe0079a4: i32 = Register  #1024
                      0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
                      0xe007b3c: <multiple use>
                      0xe008004: ch = setne
                    0xe007ab4: i32 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
                  0xe007cd4: i8 = truncate 0xe007ab4
                0xe0086ec: i16 = zero_extend 0xe007cd4
                0xe008554: <multiple use>
              0xe008774: i16 = shl 0xe0086ec, 0xe008554
            0xe018a0c: i8 = truncate 0xe008774
          0xe018a94: i16 = sign_extend 0xe018a0c
          0xe008554: <multiple use>
        0xe018b1c: i16 = sra 0xe018a94, 0xe008554
      0xe018ba4: i8 = truncate 0xe018b1c
    0xe018c2c: i16 = any_extend 0xe018ba4
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe018cb4: ch = brcond 0xe008444, 0xe018c2c, 0xe007ef4


Replacing.3 0xe018c2c: i16 = any_extend 0xe018ba4
With: 0xe018b1c: i16 = sra 0xe018a94, 0xe008554

Replacing.2 0xe0086ec: i16 = zero_extend 0xe007cd4
With: 0xe018ba4: i16 = any_extend 0xe007cd4

Replacing.3 0xe018ba4: i16 = any_extend 0xe007cd4
With: 0xe0086ec: i16 = truncate 0xe007ab4

Replacing.3 0xe018a94: i16 = sign_extend 0xe018a0c
With: 0xe018ba4: i16 = sign_extend_inreg 0xe008774, 0xe007cd4
Optimized legalized selection DAG:
SelectionDAG has 26 nodes:
  0xd9060c0: ch = EntryToken
  0xe007b3c: i32 = Constant <0>
  0xe007bc4: i32 = undef
  0xe007e6c: i32 = Register  #1025
    0xd9060c0: <multiple use>
    0xe007e6c: <multiple use>
      0xe00780c: i32 = FrameIndex <0>
      0xe007894: i32 = Constant <4>
    0xe00808c: i32 = SPUISD::IndirectAddr 0xe00780c, 0xe007894
  0xe008114: ch,flag = CopyToReg 0xd9060c0, 0xe007e6c, 0xe00808c
    0xe008114: <multiple use>
    0xe007e6c: <multiple use>
  0xe00819c: i32,ch = CopyFromReg 0xe008114, 0xe007e6c
    0xe008114: <multiple use>
    0xe00819c: <multiple use>
    0xe007bc4: <multiple use>
  0xe008224: v16i8,ch = load 0xe008114, 0xe00819c, 0xe007bc4 <0xd9038c4:0>
alignment=16
  0xe008554: i32 = Constant <7>
      0xe008224: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
          0xe007b3c: <multiple use>
        0xe0084cc: v4i32 = BUILD_VECTOR 0xe007b3c, 0xe007b3c, 0xe007b3c,
0xe007b3c
        0xe008224: <multiple use>
          0xe00819c: <multiple use>
        0xe0082ac: v4i32 = SPUISD::SHUFFLE_MASK 0xe00819c
      0xe0083bc: v4i32 = SPUISD::SHUFB 0xe0084cc, 0xe008224, 0xe0082ac
      0xe00819c: <multiple use>
      0xe007bc4: <multiple use>
    0xe008444: ch = store 0xe008224:1, 0xe0083bc, 0xe00819c, 0xe007bc4
<0xd9038c4:0> alignment=16
                0xd9060c0: <multiple use>
                0xe0079a4: i32 = Register  #1024
              0xe007a2c: i32,ch = CopyFromReg 0xd9060c0, 0xe0079a4
              0xe007b3c: <multiple use>
              0xe008004: ch = setne
            0xe007ab4: i32 = setcc 0xe007a2c, 0xe007b3c, 0xe008004
          0xe0086ec: i16 = truncate 0xe007ab4
          0xe008554: <multiple use>
        0xe008774: i16 = shl 0xe0086ec, 0xe008554
        0xe007cd4: ch = ValueType :i8
      0xe018ba4: i16 = sign_extend_inreg 0xe008774, 0xe007cd4
      0xe008554: <multiple use>
    0xe018b1c: i16 = sra 0xe018ba4, 0xe008554
    0xe007ef4: ch = BasicBlock <bb1 0xe013998>
  0xe018cb4: ch = brcond 0xe008444, 0xe018b1c, 0xe007ef4


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list