[PATCH] D81153: [Test] Add regression test for PR46195.

Ricky Zhou via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 05:57:25 PDT 2020


rickyz updated this revision to Diff 268446.
rickyz added a comment.

(One more typo fix, sorry.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81153/new/

https://reviews.llvm.org/D81153

Files:
  llvm/test/CodeGen/X86/bug46195.ll


Index: llvm/test/CodeGen/X86/bug46195.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/bug46195.ll
@@ -0,0 +1,59 @@
+; RUN: llc < %s -O1 -o /dev/null -debug-only=isel 2>&1 | FileCheck %s
+;
+; Verify that DAGCombiner preserves the correct dependency chain for
+; promoted loads.
+;
+; Generated from the following example, compiled with -O1:
+;
+; struct S {
+;   int x;
+;   unsigned short y;
+; };
+;
+; extern void maybe_mutate(struct S *ptr);
+;
+; void translate(struct S *ptr) {
+;   unsigned short c = ptr->y;
+;   maybe_mutate(ptr);
+;   ptr->y = 2 | 0x200 | (c & (0x3f | 0x8000));
+; }
+
+source_filename = "repro.c"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.S = type { i32, i16 }
+
+define dso_local void @translate(%struct.S* %ptr) local_unnamed_addr #0 {
+entry:
+  %y = getelementptr inbounds %struct.S, %struct.S* %ptr, i64 0, i32 1
+  %0 = load i16, i16* %y, align 4, !tbaa !2
+  call void @maybe_mutate(%struct.S* %ptr) #2
+  %1 = and i16 %0, -32707
+  %2 = or i16 %1, 514
+  store i16 %2, i16* %y, align 4, !tbaa !2
+  ret void
+}
+
+declare dso_local void @maybe_mutate(%struct.S*) #2
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project b28167928d2722e8774da3fce8b3307a0fa27245)"}
+!2 = !{!3, !7, i64 4}
+!3 = !{!"S", !4, i64 0, !7, i64 4}
+!4 = !{!"int", !5, i64 0}
+!5 = !{!"omnipotent char", !6, i64 0}
+!6 = !{!"Simple C/C++ TBAA"}
+!7 = !{!"short", !5, i64 0}
+
+; Verify that the load of `y` is ordered before the call to
+; `maybe_mutate()`.
+;
+; CHECK: Optimized legalized selection DAG: %bb.0 'translate:entry'
+; CHECK: SelectionDAG has {{.*}} nodes:
+; CHECK-DAG: {{.*}}callseq_start [[LOAD:t[0-9]+]]:1,
+; CHECK-DAG: [[LOAD]]: i32,ch = load<(load 2 from %ir.y,
+; CHECK: ===== Instruction selection begins: %bb.0 'entry'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81153.268446.patch
Type: text/x-patch
Size: 2028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/2093cc3e/attachment.bin>


More information about the llvm-commits mailing list