]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't process undefined range.
authorAndrew MacLeod <amacleod@redhat.com>
Sun, 2 Oct 2022 22:43:35 +0000 (18:43 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 3 Oct 2022 14:02:34 +0000 (10:02 -0400)
No need to continue processing an undefined range.

gcc/
PR tree-optimization/107109
* range-op.cc (adjust_op1_for_overflow): Don't process undefined.
gcc/testsuite/
* gcc.dg/pr107109.c: New.

gcc/range-op.cc
gcc/testsuite/gcc.dg/pr107109.c [new file with mode: 0644]

index 7ef980315b66aba09aa3f4353c39a30dfefed051..4f647abd91c1ebc481a8256336a5fd7b48be0c39 100644 (file)
@@ -1370,6 +1370,8 @@ static void
 adjust_op1_for_overflow (irange &r, const irange &op2, relation_kind rel,
                         bool add_p)
 {
+  if (r.undefined_p ())
+    return;
   tree type = r.type ();
   // Check for unsigned overflow and calculate the overflow part.
   signop s = TYPE_SIGN (type);
diff --git a/gcc/testsuite/gcc.dg/pr107109.c b/gcc/testsuite/gcc.dg/pr107109.c
new file mode 100644 (file)
index 0000000..e3036f6
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+int printf(const char *, ...);
+int a, b;
+void c() {
+  int d, e;
+ L:
+  a = (b && a) ^ 2756578370;
+  d = ~a + (e ^ d) ^ 2756578370;
+  if (!d)
+    printf("%d", a);
+  d = a / e;
+  goto L;
+}
+int main() {
+  if (a)
+    c();
+  return 0;
+}
+