This is an archive of the discontinued LLVM Phabricator instance.

DAGCombiner: Relax alignment restriction when changing store type
ClosedPublic

Authored by arsenm on Mar 9 2016, 9:05 PM.

Details

Summary

If the target allows the alignment, this should be OK. This is the partner change to D17306.

This currently breaks 1 ARM test (test/CodeGen/ARM/vector-store.ll), which looks to me like allowsMisalignedMemoryAccesses is incorrectly reporting fast.

The changes all look like this:

define void @store_v8i8_update(<8 x i8>** %ptr, <8 x i8> %val) {
  ;CHECK-LABEL: store_v8i8_update:
  ;CHECK: vst1.8 {{{d[0-9]+}}}, [{{r[0-9]+}}]!
  %A = load <8 x i8>*, <8 x i8>** %ptr
  store  <8 x i8> %val, <8 x i8>* %A, align 1
  %inc = getelementptr <8 x i8>, <8 x i8>* %A, i38 1
  store <8 x i8>* %inc, <8 x i8>** %ptr
  ret void
}

DAG at replacement time:

SelectionDAG has 17 nodes:
  t0: ch = EntryToken
  t2: i32,ch = CopyFromReg t0, Register:i32 %vreg0
  t9: i32 = Constant<0>
  t11: i32,ch = load<LD4[%ptr]> t0, t2, undef:i32
            t4: i32,ch = CopyFromReg t0, Register:i32 %vreg1
            t6: i32,ch = CopyFromReg t0, Register:i32 %vreg2
          t7: f64 = ARMISD::VMOVDRR t4, t6
        t8: v8i8 = bitcast t7
      t12: ch = store<ST8[%A](align=1)> t11:1, t8, t11, undef:i32
      t14: i32 = add t11, Constant:i32<8>
    t15: ch = store<ST4[%ptr]> t12, t14, t2, undef:i32
  t16: ch = ARMISD::RET_FLAG t15

Before:

_store_v8i8_update:
@ BB#0:
  vmov	d16, r1, r2
  ldr	r1, [r0]
  vst1.8	{d16}, [r1]!
  str	r1, [r0]
  bx	lr

After:

_store_v8i8_update:
@ BB#0:
	ldr	r3, [r0]
	str	r1, [r3]
	str	r2, [r3, #4]
	add.w	r1, r3, #8
	str	r1, [r0]
	bx	lr

It also breaks 2 other X86 tests, both of which appear to be i1-vector related:
X86/avx-vextractf128.ll, which replaces a

vxorps	%xmm0, %xmm0, %xmm0

with a

vxorps	%ymm0, %ymm0, %ymm0

X86/avx512-mask-op.ll, where an extra move is introduced

Diff Detail

Event Timeline

arsenm updated this revision to Diff 50232.Mar 9 2016, 9:05 PM
arsenm retitled this revision from to DAGCombiner: Relax alignment restriction when changing store type.
arsenm updated this object.
arsenm added a subscriber: llvm-commits.
arsenm updated this object.Mar 9 2016, 9:06 PM
arsenm edited edge metadata.
arsenm updated this object.
arsenm updated this revision to Diff 50239.Mar 9 2016, 11:08 PM

Fix missing most of the patch

Adding ARM reviewers as suggested by Owen.

t.p.northover edited edge metadata.Apr 7 2016, 1:17 PM

I think the ARM change is probably fine. There's real ARM code designed to transform a VMOVDRR/VSTR into two STRs (for legitimate, if debatable reasons: vmov was really slow on some cores), it just doesn't happen to trigger if the type is a vector.

Tim.

arsenm updated this revision to Diff 53498.Apr 12 2016, 5:21 PM
arsenm edited edge metadata.

Include ARM/x86 test update

tstellarAMD accepted this revision.Apr 21 2016, 10:22 AM
tstellarAMD edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Apr 21 2016, 10:22 AM
arsenm closed this revision.Apr 22 2016, 2:12 PM

r267217