)]}'
{
  "commit": "ec33d63beddc5ba8fc7618792ccef13bd2fb8bc1",
  "tree": "336eaed869a04c7eeffc1a113512d9f74342cb29",
  "parents": [
    "9225ecd793ed88a94c1f3754f7a45d2dfc74e47a"
  ],
  "author": {
    "name": "Jakub Jelinek",
    "email": "jakub@redhat.com",
    "time": "Fri Jul 31 08:53:52 2026 +0200"
  },
  "committer": {
    "name": "Jakub Jelinek",
    "email": "jakub@gcc.gnu.org",
    "time": "Fri Jul 31 09:33:55 2026 +0200"
  },
  "message": "match.pd: Fix up ((C \u003c\u003c A) \u0026 D) !\u003d 0 simplification [PR126476]\n\nThis simplification for power of two @1 and @2 folds to false (resp.\nto true for the \u003d\u003d version) if @1 is larger than @2 (in unsigned\ncomparison), because @1 \u0026 @2 is known to be zero (i.e. for shift count 0)\nand for shift count larger than that it will be zero too, either because\n@1 \u003c\u003c @0 is even larger, or if @0 is too large @1 \u003c\u003c @0 overflows to zero.\nThis is the case of e.g. ((4 \u003c\u003c x) \u0026 2) !\u003d 0, which is always false.\nNow, this PR is about a different problem, if @1 is smaller than @2, say\n((1 \u003c\u003c x) \u0026 256) !\u003d 0, but x has a very narrow type, say unsigned _BitInt(3),\nthen the largest possible value of x is 7 and ((1 \u003c\u003c 7) \u0026 256) is\nstill 0, 1 \u003c\u003c 7 is 128 and so still smaller than 256.\nSo, if c1 - c2 doesn\u0027t fit into the shift count type\n(resp. for the other case c2 - c1), it will be also always false (resp.\ntrue).\nTrying to improve it and using range of x (aka @0) is not needed,\nthis simplification folds it into @0 !\u003d (c1 - c2) and so will be folded\nlater.  Just the case where c1 - c2 overflows is problematic because\nwe\u0027ve lost the details (unless we\u0027d promote both operands or something).\nAnother possible way to do this would be build_int_cst and check for\nthe overflow flags, but I think this is shorter.\n\n2026-07-31  Jakub Jelinek  \u003cjakub@redhat.com\u003e\n\n\tPR tree-optimization/126476\n\t* match.pd (((C \u003c\u003c A) \u0026 D) !\u003d 0 -\u003e A \u003d\u003d 0,\n\t((C \u003c\u003c A) \u0026 D) \u003d\u003d 0 -\u003e A !\u003d 0): Fold to false/true if\n\tc1 - c2 resp. c2 - c1 doesn\u0027t fit into TREE_TYPE (@0).\n\n\t* gcc.dg/torture/bitint-103.c: New test.\n\nReviewed-by: Richard Biener \u003crguenth@suse.de\u003e\n(cherry picked from commit 5c62a2771f2c7d5301ee6456f1817098c2fea113)\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "761b765745310710edf1bd4d0cb47e07e955a080",
      "old_mode": 33188,
      "old_path": "gcc/match.pd",
      "new_id": "42a6c2c75a96a6155035e834a49c56e64d250fb5",
      "new_mode": 33188,
      "new_path": "gcc/match.pd"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "54c0fc0b1d0f9a873c55a7dea4d9e62a4e21b36b",
      "new_mode": 33188,
      "new_path": "gcc/testsuite/gcc.dg/torture/bitint-103.c"
    }
  ]
}
