summaryrefslogtreecommitdiff
path: root/test/FrontendC/2008-11-08-InstCombineSelect.c
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-11-09 23:17:42 +0000
committerBill Wendling <isanbard@gmail.com>2008-11-09 23:17:42 +0000
commit1fb43c32edd3b3eb9e4ece9240578984c5914d65 (patch)
tree1c8e45159064131e0ad2016d5bdcb382f2a2a87a /test/FrontendC/2008-11-08-InstCombineSelect.c
parent47ed475dec2fdd3a434af2021cfdcbd7538b3e27 (diff)
downloadllvm-1fb43c32edd3b3eb9e4ece9240578984c5914d65.tar.gz
llvm-1fb43c32edd3b3eb9e4ece9240578984c5914d65.tar.bz2
llvm-1fb43c32edd3b3eb9e4ece9240578984c5914d65.tar.xz
The method of doing the matching with a 'select' instruction was wrong. The
original code was matching like this: if (match(A, m_Not(m_Value(B)))) B was already matched as a 'select' instruction. However, this isn't matching what we think it's matching. It would match B as a 'Value', so basically anything would match to it. In this case, a Constant matched. B was replaced with a constant representation. And then the wrong value would be used in the SelectInst::Create statement, causing a crash. After thinking on this for a moment, and after Nick L. told me how the pattern matching stuff was supposed to work, the solution was to match NOT an m_Value, but an m_Select. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FrontendC/2008-11-08-InstCombineSelect.c')
-rw-r--r--test/FrontendC/2008-11-08-InstCombineSelect.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/FrontendC/2008-11-08-InstCombineSelect.c b/test/FrontendC/2008-11-08-InstCombineSelect.c
new file mode 100644
index 0000000000..70c8d3a224
--- /dev/null
+++ b/test/FrontendC/2008-11-08-InstCombineSelect.c
@@ -0,0 +1,17 @@
+// RUN: %llvmgcc %s -S -emit-llvm -O2 -o -
+// PR3028
+
+int g_187;
+int g_204;
+int g_434;
+
+int func_89 (void)
+{
+ return 1;
+}
+
+void func_20 (int p_22)
+{
+ if (1 & p_22 | g_204 & (1 < g_187) - func_89 ())
+ g_434 = 1;
+}