[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine.llx 2004-09-20-BadLoadCombine2.llx
Chris Lattner
lattner at cs.uiuc.edu
Mon Sep 20 03:14:41 PDT 2004
Changes in directory llvm/test/Regression/Transforms/InstCombine:
2004-09-20-BadLoadCombine.llx added (r1.1)
2004-09-20-BadLoadCombine2.llx added (r1.1)
---
Log message:
Two testcases for invalid transformations that instcombine is doing
---
Diffs of the changes: (+44 -0)
Index: llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine.llx
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine.llx:1.1
*** /dev/null Mon Sep 20 05:14:38 2004
--- llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine.llx Mon Sep 20 05:14:27 2004
***************
*** 0 ****
--- 1,20 ----
+ ; RUN: llvm-as < %s | opt -instcombine -mem2reg | llvm-dis | not grep 'int 1'
+
+ ; When propagating the load through the select, make sure that the load is
+ ; inserted where the original load was, not where the select is. Not doing
+ ; so could produce incorrect results!
+
+ implementation
+
+ int %test(bool %C) {
+ %X = alloca int
+ %X2 = alloca int
+ store int 1, int* %X
+ store int 2, int* %X2
+
+ %Y = select bool %C, int* %X, int* %X2
+ store int 3, int* %X
+ %Z = load int* %Y
+ ret int %Z
+ }
+
Index: llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine2.llx
diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine2.llx:1.1
*** /dev/null Mon Sep 20 05:14:41 2004
--- llvm/test/Regression/Transforms/InstCombine/2004-09-20-BadLoadCombine2.llx Mon Sep 20 05:14:27 2004
***************
*** 0 ****
--- 1,24 ----
+ ; RUN: llvm-as < %s | opt -instcombine -mem2reg -simplifycfg | llvm-dis | \
+ ; RUN: grep -v store | not grep 'int 1'
+
+ ; Test to make sure that instcombine does not accidentally propagate the load
+ ; into the PHI, which would break the program.
+
+ int %test(bool %C) {
+ entry:
+ %X = alloca int
+ %X2 = alloca int
+ store int 1, int* %X
+ store int 2, int* %X2
+ br bool %C, label %cond_true.i, label %cond_continue.i
+
+ cond_true.i:
+ br label %cond_continue.i
+
+ cond_continue.i:
+ %mem_tmp.i.0 = phi int* [ %X, %cond_true.i ], [ %X2, %entry ]
+ store int 3, int* %X
+ %tmp.3 = load int* %mem_tmp.i.0
+ ret int %tmp.3
+ }
+
More information about the llvm-commits
mailing list