<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Optimize switch over fields of homogeneous struct into pointer arithmetic"
   href="https://bugs.llvm.org/show_bug.cgi?id=34285">34285</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Optimize switch over fields of homogeneous struct into pointer arithmetic
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>arcata@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following IR, the switch arms could be optimized away into a dynamic gep
into the homogeneous struct, but this does not happen:

%equistruct = type { i32, i32, i32, i32 }

declare void @llvm.trap() noreturn nounwind

define void @index(%equistruct* %a, i32 %b, i32 %c) {
entry:
  switch i32 %b, label %default [
    i32 0, label %i0
    i32 1, label %i1
    i32 2, label %i2
    i32 3, label %i3
  ]

i0:
  %d0 = getelementptr %equistruct, %equistruct* %a, i32 0, i32 0
  store i32 %c, i32* %d0
  ret void

i1:
  %d1 = getelementptr %equistruct, %equistruct* %a, i32 0, i32 1
  store i32 %c, i32* %d1
  ret void

i2:
  %d2 = getelementptr %equistruct, %equistruct* %a, i32 0, i32 2
  store i32 %c, i32* %d2
  ret void

i3:
  %d3 = getelementptr %equistruct, %equistruct* %a, i32 0, i32 3
  store i32 %c, i32* %d3
  ret void

default:
  call void @llvm.trap()
  unreachable
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>