summaryrefslogtreecommitdiffstats
path: root/llvm/test/FrontendC
diff options
context:
space:
mode:
authorStuart Hastings <stuart@apple.com>2010-07-27 23:15:25 +0000
committerStuart Hastings <stuart@apple.com>2010-07-27 23:15:25 +0000
commita7f1d4a2ba12e24615210b469e5021678f611b9e (patch)
tree3ecb734cb27ee6e61522d31b956dae1ee7cc92f1 /llvm/test/FrontendC
parent038abf7db029e3912073c886e51d423c0fb9c1c5 (diff)
downloadbcm5719-llvm-a7f1d4a2ba12e24615210b469e5021678f611b9e.tar.gz
bcm5719-llvm-a7f1d4a2ba12e24615210b469e5021678f611b9e.zip
Testcase for r109556. Radar 8198362.
llvm-svn: 109557
Diffstat (limited to 'llvm/test/FrontendC')
-rw-r--r--llvm/test/FrontendC/2010-07-27-MinNoFoldConst.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/test/FrontendC/2010-07-27-MinNoFoldConst.c b/llvm/test/FrontendC/2010-07-27-MinNoFoldConst.c
new file mode 100644
index 00000000000..7cd8b4c4376
--- /dev/null
+++ b/llvm/test/FrontendC/2010-07-27-MinNoFoldConst.c
@@ -0,0 +1,18 @@
+// RUN: %llvmgcc -S %s -o - | FileCheck %s
+extern int printf(const char *, ...);
+static void bad(unsigned int v1, unsigned int v2) {
+ printf("%u\n", 1631381461u * (((v2 - 1273463329u <= v1 - 1273463329u) ? v2 : v1) - 1273463329u) + 121322179u);
+}
+// Radar 8198362
+// GCC FE wants to convert the above to
+// 1631381461u * MIN(v2 - 1273463329u, v1 - 1273463329u)
+// and then to
+// MIN(1631381461u * v2 - 4047041419, 1631381461u * v1 - 4047041419)
+//
+// 1631381461u * 1273463329u = 2077504466193943669, but 32-bit overflow clips
+// this to 4047041419. This breaks the comparision implicit in the MIN().
+// Two multiply operations suggests the bad optimization is happening;
+// one multiplication, after the MIN(), is correct.
+// CHECK: mul
+// CHECK-NOT: mul
+// CHECK: ret
OpenPOWER on IntegriCloud