[Bug target/84011] Optimize switch table with -fPIE

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 24 13:35:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84011

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
This patch works on the testcase:

diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index c2538908340..a1e85407bf3 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -827,16 +827,9 @@ check_final_bb (gswitch *swtch, struct switch_conv_info
*info)
              else
                {
                  reloc = initializer_constant_valid_p (val, TREE_TYPE (val));
-                 if ((flag_pic && reloc != null_pointer_node)
-                     || (!flag_pic && reloc == NULL_TREE))
-                   {
-                     if (reloc)
-                       reason
-                         = "value from a case would need runtime relocations";
-                     else
-                       reason
-                         = "value from a case is not a valid initializer";
-                   }
+                 if (reloc == NULL_TREE)
+                   reason
+                     = "value from a case is not a valid initializer";
                }
              if (reason)
                {


More information about the Gcc-bugs mailing list