@@ -2788,7 +2788,10 @@ (define_operator_list COND_TERNARY
(plus:c @0 (lshift:s @0 INTEGER_CST@1))
(if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
&& tree_fits_uhwi_p (@1)
- && tree_to_uhwi (@1) < element_precision (type))
+ && tree_to_uhwi (@1) < element_precision (type)
+ && (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ || optab_handler (smul_optab,
+ TYPE_MODE (type)) != CODE_FOR_nothing))
(with { tree t = type;
if (!TYPE_OVERFLOW_WRAPS (t)) t = unsigned_type_for (t);
wide_int w = wi::set_bit_in_zero (tree_to_uhwi (@1),
@@ -2804,7 +2807,10 @@ (define_operator_list COND_TERNARY
&& tree_fits_uhwi_p (@1)
&& tree_to_uhwi (@1) < element_precision (type)
&& tree_fits_uhwi_p (@2)
- && tree_to_uhwi (@2) < element_precision (type))
+ && tree_to_uhwi (@2) < element_precision (type)
+ && (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ || optab_handler (smul_optab,
+ TYPE_MODE (type)) != CODE_FOR_nothing))
(with { tree t = type;
if (!TYPE_OVERFLOW_WRAPS (t)) t = unsigned_type_for (t);
unsigned int prec = element_precision (type);
@@ -0,0 +1,13 @@
+/* PR tree-optimization/99544 */
+/* { dg-do compile } */
+/* { dg-options "-Os -fopenmp" } */
+
+long
+foo (long a, long b, long c)
+{
+ long d, e;
+ #pragma omp teams distribute parallel for simd firstprivate (a, b, c) lastprivate(e)
+ for (d = a; d < b; d++)
+ e = c + d * 5;
+ return e;
+}