summaryrefslogtreecommitdiff
path: root/test/FrontendC/2010-07-27-MinNoFoldConst.c
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
commit3c73a6b650e838d20814e51cb693c8902ae2b21f (patch)
tree821ac3043d916edd40641cd4f616398f82d18ab5 /test/FrontendC/2010-07-27-MinNoFoldConst.c
parentb344a346f1431bc942f96d0e0b8b87ee8f1b0475 (diff)
downloadllvm-3c73a6b650e838d20814e51cb693c8902ae2b21f.tar.gz
llvm-3c73a6b650e838d20814e51cb693c8902ae2b21f.tar.bz2
llvm-3c73a6b650e838d20814e51cb693c8902ae2b21f.tar.xz
Testcase for r109556. Radar 8198362.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FrontendC/2010-07-27-MinNoFoldConst.c')
-rw-r--r--test/FrontendC/2010-07-27-MinNoFoldConst.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/FrontendC/2010-07-27-MinNoFoldConst.c b/test/FrontendC/2010-07-27-MinNoFoldConst.c
new file mode 100644
index 0000000000..7cd8b4c437
--- /dev/null
+++ b/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