https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127985
Bug ID: 127985
Summary: [17 Regression] Recent match.pd simplification
breaking saturation discovery on RISC-V
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: law at gcc dot gnu.org
Target Milestone: ---
This change:
commit ff133b4cd2202fc7a5be5cd9dc935c0a75fb6b68
Author: Uttam Bhadauriya <[email protected]>
Date: Fri Oct 16 09:44:17 2026 -0600
[PATCH v4] tree-optimization: Simplify (a & -a) < 0 to a == INT_MIN
[PR126627]
Hello,
apologies for the formatting and rebase issue, I am sending v4 of the
patch to address the same.
From 987b64d5230398390f926a91612ea5c0a5dcb781 Mon Sep 17 00:00:00 2001
From: Uttam Singh Bhadauriya <[email protected]>
Date: Fri, 16 Oct 2026 17:58:52 +0530
Subject: [PATCH v4] tree-optimization: Simplify (a & -a) < 0 to a ==
INT_MIN
[PR126627]
[ ... ]
Is causing regressions on RISC-V:
Tests that now fail, but worked before (74 tests):
gcc: gcc.target/riscv/sat/sat_s_add_imm-1-i16.c -O2 scan-assembler-not
.L[0-9]+
gcc: gcc.target/riscv/sat/sat_s_add_imm-1-i16.c -O2 scan-tree-dump-times
optimized ".SAT_ADD " 2
[ ... ]
They can be easily seen with a cross compiler targetting riscv64-elf and
compiling the attached testcase with "-O2 -march=rv64gc -mabi=lp64d"
We should be seeing a SAT_ADD the .optimized dump, but instead we get the
branchy form:
;; basic block 2, loop depth 0
;; pred: ENTRY
if (x_5(D) == -32768)
goto <bb 4>; [1.40%]
else
goto <bb 3>; [98.60%]
;; succ: 4
;; 3
;; basic block 3, loop depth 0
;; pred: 2
x.0_1 = (unsigned short) x_5(D);
_2 = x.0_1 + 65535;
[ ... ]