[LLVMdev] Optimization issue for target's offset field of load operation in DAGSelection

Dan westdac at gmail.com
Tue Jul 9 10:17:08 PDT 2013


I am working on an experimental target and trying to make sure that
the load offset field is used to the best way. There appears to be
some control over the architecture's offset range and whether the
offset is too large and needs to be lowered/converted into a separate
sequence of operations in DAGSelection?

Can someone point me to what might be the case?

For example, the difference between index=63 and 64 causes the
difference in address+offset being generated as separate operation
versus built into the architecture versus just a load operation. In my
architecture, there are larger offsets and 63 and 64 should not be the
dividing line.

Is there a limit on the ranges specified effectively for all targets
or is somehow a constraint for my target set and causing this?

Suggestions?

long long array[100];
long long func()
 {
  return array[63];
  // return array[64];
}

Here is the difference in the .ll code with the 63 or 64 as the index:

  %0 = load i64* getelementptr inbounds ([10000 x i64]* @array, i32 0,
i64 63), align 8
  ret i64 %0


  %0 = load i64* getelementptr inbounds ([10000 x i64]* @array, i32 0,
i64 64), align 8
  ret i64 %0


Here is the Instruction Selection for size 63:


ISEL: Starting pattern match on root node: 0x3d9ad80: i64,ch = load
0x3d866f8, 0x3d9aa80, 0x3d9ac80<LD8[getelementptr inbounds ([10000 x
i64]* @array, i32 0, i64 63)]> [ORD=2] [ID=6]

  Initial Opcode index to 813
  Skipped scope entry (due to false predicate) at index 822, continuing at 876
  Skipped scope entry (due to false predicate) at index 877, continuing at 931
  TypeSwitch[i64] from 934 to 937
  Morphed node: 0x3d9ad80: i64,ch = LDWri 0x3d9a880, 0x3d9ab80,
0x3d866f8<Mem:LD8[getelementptr inbounds ([10000 x i64]* @array, i32
0, i64 63)]> [ORD=2]

ISEL: Match complete!
===== Instruction selection ends:

Here is the Instruction Selection for size 64:


ISEL: Match complete!
ISEL: Starting pattern match on root node: 0x2d2cda0: i64,ch = load
0x2d18718, 0x2d2caa0, 0x2d2cca0<LD8[getelementptr inbounds ([10000 x
i64]* @array, i32 0, i64 64)]> [ORD=2] [ID=6]

  Initial Opcode index to 813
  Skipped scope entry (due to false predicate) at index 822, continuing at 876
  Skipped scope entry (due to false predicate) at index 877, continuing at 931
  TypeSwitch[i64] from 934 to 937
  Morphed node: 0x2d2cda0: i64,ch = LDWri 0x2d2caa0, 0x2d2cba0,
0x2d18718<Mem:LD8[getelementptr inbounds ([10000 x i64]* @array, i32
0, i64 64)]> [ORD=2]

ISEL: Match complete!
ISEL: Starting pattern match on root node: 0x2d2caa0: i64 = add
0x2d2c8a0, 0x2d2c9a0 [ORD=1] [ID=5]

  Initial Opcode index to 1473
  Match failed at index 1482
  Continuing at 1498
  Morphed node: 0x2d2caa0: i64 = ADD 0x2d2c8a0, 0x2d2c9a0 [ORD=1]
  etc



More information about the llvm-dev mailing list