From 20babb112c8d8aab89a5e86347e2bfdb90603ce8 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 25 Feb 2009 06:52:48 +0000 Subject: [PATCH] Add a totally synthetic situation I came up with while looking at a bug in related code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65437 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/README.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 09e5433578c..341c5c1ff47 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -1690,6 +1690,7 @@ For example: store of float into { {{}}, float } could be turned into a store to the float directly. //===---------------------------------------------------------------------===// + #include double foo(double a) { return sin(a); } @@ -1704,3 +1705,19 @@ vs: foo: jmp sin +//===---------------------------------------------------------------------===// + +Instcombine should replace the load with a constant in: + + static const char x[4] = {'a', 'b', 'c', 'd'}; + + unsigned int y(void) { + return *(unsigned int *)x; + } + +It currently only does this transformation when the size of the constant +is the same as the size of the integer (so, try x[5]) and the last byte +is a null (making it a C string). There's no need for these restrictions. + +//===---------------------------------------------------------------------===// +