[llvm-commits] [llvm] r109557 - /llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c

Stuart Hastings stuart at apple.com
Tue Jul 27 16:15:26 PDT 2010


Author: stuart
Date: Tue Jul 27 18:15:25 2010
New Revision: 109557

URL: http://llvm.org/viewvc/llvm-project?rev=109557&view=rev
Log:
Testcase for r109556.  Radar 8198362.

Added:
    llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c

Added: llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c?rev=109557&view=auto
==============================================================================
--- llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c (added)
+++ llvm/trunk/test/FrontendC/2010-07-27-MinNoFoldConst.c Tue Jul 27 18:15:25 2010
@@ -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





More information about the llvm-commits mailing list